Lely core libraries
2.2.5
|
Go to the documentation of this file.
22 #ifndef LELY_CO_VAL_H_
23 #define LELY_CO_VAL_H_
31 #define CO_BOOLEAN_MIN 0
34 #define CO_BOOLEAN_MAX 1
37 #define CO_INTEGER8_MIN INT8_MIN
40 #define CO_INTEGER8_MAX INT8_MAX
43 #define CO_INTEGER16_MIN INT16_MIN
46 #define CO_INTEGER16_MAX INT16_MAX
49 #define CO_INTEGER32_MIN INT32_MIN
52 #define CO_INTEGER32_MAX INT32_MAX
55 #define CO_UNSIGNED8_MIN 0
58 #define CO_UNSIGNED8_MAX UINT8_MAX
61 #define CO_UNSIGNED16_MIN 0
64 #define CO_UNSIGNED16_MAX UINT16_MAX
67 #define CO_UNSIGNED32_MIN 0
70 #define CO_UNSIGNED32_MAX UINT32_MAX
73 #define CO_REAL32_MIN (-FLT_MAX)
76 #define CO_REAL32_MAX FLT_MAX
79 #define CO_TIME_OF_DAY_MIN \
85 #define CO_TIME_OF_DAY_MAX \
87 UINT32_C(0x0fffffff), UINT16_MAX \
91 #define CO_TIME_DIFF_MIN CO_TIME_OF_DAY_MIN
94 #define CO_TIME_DIFF_MAX CO_TIME_OF_DAY_MAX
97 #define CO_INTEGER24_MIN (-INT32_C(0x00800000))
100 #define CO_INTEGER24_MAX INT32_C(0x007fffff)
103 #define CO_REAL64_MIN (-DBL_MAX)
106 #define CO_REAL64_MAX DBL_MAX
109 #define CO_INTEGER40_MIN (-INT64_C(0x0000008000000000))
112 #define CO_INTEGER40_MAX INT64_C(0x0000007fffffffff)
115 #define CO_INTEGER48_MIN (-INT64_C(0x0000800000000000))
118 #define CO_INTEGER48_MAX INT64_C(0x00007fffffffffff)
121 #define CO_INTEGER56_MIN (-INT64_C(0x0080000000000000))
124 #define CO_INTEGER56_MAX INT64_C(0x007fffffffffffff)
127 #define CO_INTEGER64_MIN INT64_MIN
130 #define CO_INTEGER64_MAX INT64_MAX
133 #define CO_UNSIGNED24_MIN 0
136 #define CO_UNSIGNED24_MAX UINT32_C(0x00ffffff)
139 #define CO_UNSIGNED40_MIN 0
142 #define CO_UNSIGNED40_MAX UINT64_C(0x000000ffffffffff)
145 #define CO_UNSIGNED48_MIN 0
148 #define CO_UNSIGNED48_MAX UINT64_C(0x0000ffffffffffff)
151 #define CO_UNSIGNED56_MIN 0
154 #define CO_UNSIGNED56_MAX UINT64_C(0x00ffffffffffffff)
157 #define CO_UNSIGNED64_MIN 0
160 #define CO_UNSIGNED64_MAX UINT64_MAX
164 #define LELY_CO_DEFINE_TYPE(a, b, c, d) co_##b##_t c;
165 #include <lely/co/def/type.def>
166 #undef LELY_CO_DEFINE_TYPE
169 #if __STDC_VERSION__ >= 199901L
171 #define _CO_ARRAY(...) __VA_ARGS__
174 #define CO_VISIBLE_STRING_C(c) \
179 char vs[sizeof(c)]; \
181 }){ .size = sizeof(c) - 1, .u = { .vs = c } }) \
185 #define CO_OCTET_STRING_C(c) \
190 uint_least8_t os[sizeof(c)]; \
192 }){ .size = sizeof(c) - 1, .u = { .os = c } }) \
196 #define CO_UNICODE_STRING_C(...) _CO_UNICODE_STRING_C(_CO_ARRAY(__VA_ARGS__))
199 #define _CO_UNICODE_STRING_C(c) \
204 char16_t us[sizeof((char16_t[])c) / sizeof(char16_t)]; \
206 }){ .size = sizeof((char16_t[])c) - sizeof(char16_t), \
207 .u = { .us = c } }) \
215 #define CO_DOMAIN_C(type, ...) _CO_DOMAIN_C(type, _CO_ARRAY(__VA_ARGS__))
217 #define _CO_DOMAIN_C(type, c) \
222 type dom[sizeof((type[])c) / sizeof(type)]; \
224 }){ .size = sizeof((type[])c), .u = { .dom = c } }) \
227 #endif // __STDC_VERSION__ >= 199901L
331 int co_val_init_os(uint_least8_t **val,
const uint_least8_t *os,
size_t n);
442 size_t co_val_make(co_unsigned16_t type,
void *val,
const void *ptr,
size_t n);
462 size_t co_val_copy(co_unsigned16_t type,
void *dst,
const void *src);
483 size_t co_val_move(co_unsigned16_t type,
void *dst,
void *src);
498 int co_val_cmp(co_unsigned16_t type,
const void *v1,
const void *v2);
520 size_t co_val_read(co_unsigned16_t type,
void *val,
const uint_least8_t *begin,
521 const uint_least8_t *end);
541 co_unsigned16_t type,
void *val,
const void *ptr,
size_t n);
562 size_t co_val_write(co_unsigned16_t type,
const void *val, uint_least8_t *begin,
585 size_t co_val_lex(co_unsigned16_t type,
void *val,
const char *begin,
586 const char *end,
struct floc *at);
606 size_t co_val_print(co_unsigned16_t type,
const void *val,
char **pbegin,
613 #endif // !LELY_CO_VAL_H_
size_t co_val_read(co_unsigned16_t type, void *val, const uint_least8_t *begin, const uint_least8_t *end)
Reads a value of the specified data type from a memory buffer.
size_t co_val_copy(co_unsigned16_t type, void *dst, const void *src)
Copies one value to another.
int co_val_init_max(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its upper limit.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
int co_val_init_vs_n(char **val, const char *vs, size_t n)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
int co_val_init_min(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its lower limit.
const void * co_val_addressof(co_unsigned16_t type, const void *val)
Returns the address of the first byte in a value of the specified data type.
size_t co_val_move(co_unsigned16_t type, void *dst, void *src)
Moves one value to another.
A location in a text file.
int co_val_init_vs(char **val, const char *vs)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
size_t co_val_print(co_unsigned16_t type, const void *val, char **pbegin, char *end)
Prints a value of the specified data type to a memory buffer.
co_unsigned32_t co_val_read_sdo(co_unsigned16_t type, void *val, const void *ptr, size_t n)
Reads a value of the specified data type from an SDO buffer.
size_t co_val_sizeof(co_unsigned16_t type, const void *val)
Returns the size (in bytes) of a value of the specified data type.
size_t co_val_make(co_unsigned16_t type, void *val, const void *ptr, size_t n)
Constructs a value of the specified data type.
int co_val_init_us(char16_t **val, const char16_t *us)
Initializes an array of (16-bit) Unicode characters (CO_DEFTYPE_UNICODE_STRING).
int co_val_init_os(uint_least8_t **val, const uint_least8_t *os, size_t n)
Initializes an array of octets (CO_DEFTYPE_OCTET_STRING).
int co_val_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.
A union of the CANopen static data types.
size_t co_val_lex(co_unsigned16_t type, void *val, const char *begin, const char *end, struct floc *at)
Lexes a value of the specified data type from a memory buffer.
int co_val_init_dom(void **val, const void *dom, size_t n)
Initializes an arbitrary large block of data (CO_DEFTYPE_DOMAIN).
int co_val_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
int co_val_init_us_n(char16_t **val, const char16_t *us, size_t n)
Initializes an array of (16-bit) Unicode characters (CO_DEFTYPE_UNICODE_STRING).
size_t co_val_write(co_unsigned16_t type, const void *val, uint_least8_t *begin, uint_least8_t *end)
Writes a value of the specified data type to a memory buffer.