49#define CO_ARRAY_HDR_OFFSET \
50 ALIGN(sizeof(struct co_array_hdr), _Alignof(union co_val))
52static inline struct co_array_hdr *co_array_get_hdr(
const void *val);
54static int co_array_alloc(
void *val,
size_t size);
55static void co_array_free(
void *val);
56static void co_array_init(
void *val,
size_t size);
57static void co_array_fini(
void *val);
59static size_t co_array_sizeof(
const void *val);
69 co_array_init(val, 0);
75#define LELY_CO_DEFINE_TYPE(a, b, c, d) \
76 case CO_DEFTYPE_##a: \
77 u->c = (co_##b##_t)CO_##a##_INIT; \
79#include <lely/co/def/basic.def>
80#include <lely/co/def/time.def>
82#include <lely/co/def/array.def>
84#undef LELY_CO_DEFINE_TYPE
97 co_array_init(val, 0);
103#define LELY_CO_DEFINE_TYPE(a, b, c, d) \
104 case CO_DEFTYPE_##a: \
105 u->c = (co_##b##_t)CO_##a##_MIN; \
107#include <lely/co/def/basic.def>
108#include <lely/co/def/time.def>
110#include <lely/co/def/array.def>
112#undef LELY_CO_DEFINE_TYPE
125 co_array_init(val, 0);
131#define LELY_CO_DEFINE_TYPE(a, b, c, d) \
132 case CO_DEFTYPE_##a: \
133 u->c = (co_##b##_t)CO_##a##_MAX; \
135#include <lely/co/def/basic.def>
136#include <lely/co/def/time.def>
138#include <lely/co/def/array.def>
140#undef LELY_CO_DEFINE_TYPE
162 if (co_array_alloc(val, n + 1) == -1)
165 co_array_init(val, n);
184 if (co_array_alloc(val, n + 1) == -1)
187 co_array_init(val, n);
216 if (co_array_alloc(val, 2 * (n + 1)) == -1)
219 co_array_init(val, 2 * n);
235 if (co_array_alloc(val, n) == -1)
238 co_array_init(val, n);
240 memcpy(*val, dom, n);
276 ? co_array_sizeof(val)
282co_val_make(co_unsigned16_t type,
void *val,
const void *ptr,
size_t n)
288 n = ptr ? strlen(ptr) : 0;
363 *(
char **)src = NULL;
369co_val_cmp(co_unsigned16_t type,
const void *v1,
const void *v2)
396 cmp = strncmp(p1, p2,
MIN(n1, n2));
399 cmp = memcmp(p1, p2,
MIN(n1, n2));
405 cmp = memcmp(p1, p2,
MIN(n1, n2));
410 cmp = (n1 > n2) - (n1 < n2);
413 const union co_val *u1 = v1;
414 const union co_val *u2 = v2;
425 cmp = uint16_cmp(&u1->t.days, &u2->t.days);
427 cmp = uint32_cmp(&u1->t.ms, &u2->t.ms);
430 cmp = uint16_cmp(&u1->td.days, &u2->td.days);
432 cmp = uint32_cmp(&u1->td.ms, &u2->td.ms);
451co_val_read(co_unsigned16_t type,
void *val,
const uint_least8_t *begin,
452 const uint_least8_t *end)
454 assert(begin || begin == end);
455 assert(end >= begin);
457 size_t n = end - begin;
477 char16_t *us = *(
char16_t **)val;
479 for (
size_t i = 0; i + 1 < n; i += 2)
499 u->b = (*begin != 0);
505 u->i8 = *(
const co_integer8_t *)begin;
523 u->u8 = *(
const co_unsigned8_t *)begin;
541 u->r32 = ldle_flt32(begin);
549 & UINT32_C(0x0fffffff);
557 co_unsigned24_t u24 = 0;
558 for (
size_t i = 0; i < 3; i++)
559 u24 |= (co_unsigned24_t)*begin++
570 u->r64 = ldle_flt64(begin);
576 co_unsigned40_t u40 = 0;
577 for (
size_t i = 0; i < 5; i++)
578 u40 |= (co_unsigned40_t)*begin++
589 co_unsigned48_t u48 = 0;
590 for (
size_t i = 0; i < 6; i++)
591 u48 |= (co_unsigned48_t)*begin++
602 co_unsigned56_t u56 = 0;
603 for (
size_t i = 0; i < 7; i++)
604 u56 |= (co_unsigned56_t)*begin++
622 for (
size_t i = 0; i < 3; i++)
623 u->u24 |= (co_unsigned24_t)*begin++
632 for (
size_t i = 0; i < 5; i++)
633 u->u40 |= (co_unsigned40_t)*begin++
642 for (
size_t i = 0; i < 6; i++)
643 u->u48 |= (co_unsigned48_t)*begin++
652 for (
size_t i = 0; i < 7; i++)
653 u->u56 |= (co_unsigned56_t)*begin++
709 size_t n = (size_t)size;
715 char *vs = *(
char **)val;
722 uint_least8_t *os = *(uint_least8_t **)val;
729 char16_t *us = *(
char16_t **)val;
733 const uint_least8_t *begin =
734 (
const uint_least8_t *)us;
736 for (
size_t i = 0; i + 1 < n; i += 2)
742 void *dom = *(
void **)val;
753 n =
MIN(n, (
size_t)size);
755 assert(n <=
sizeof(tmp));
758 const uint_least8_t *begin = (
const uint_least8_t *)&tmp;
759 const uint_least8_t *end = begin + n;
770 co_unsigned32_t ac = 0;
772 const uint_least8_t *begin = ptr;
773 const uint_least8_t *end = begin ? begin + n : NULL;
791co_val_write(co_unsigned16_t type,
const void *val, uint_least8_t *begin,
801 if (begin && (!end || end - begin >= (ptrdiff_t)n)) {
807 const char16_t *us = ptr;
808 for (
size_t i = 0; i + 1 < n; i += 2)
818 const union co_val *u = val;
821 if (begin && (!end || end - begin >= 1)) {
823 *(co_boolean_t *)begin = 1;
825 *(co_boolean_t *)begin = 0;
829 if (begin && (!end || end - begin >= 1))
830 *(co_integer8_t *)begin = u->i8;
833 if (begin && (!end || end - begin >= 2))
837 if (begin && (!end || end - begin >= 4))
841 if (begin && (!end || end - begin >= 1))
842 *(co_unsigned8_t *)begin = u->u8;
845 if (begin && (!end || end - begin >= 2))
849 if (begin && (!end || end - begin >= 4))
853 if (begin && (!end || end - begin >= 4))
854 stle_flt32(begin, u->r32);
858 if (begin && (!end || end - begin >= 6)) {
859 stle_u32(begin, u->t.ms & UINT32_C(0x0fffffff));
864 if (begin && (!end || end - begin >= 3)) {
865 co_unsigned24_t u24 = u->i24 < 0
867 : (co_unsigned24_t)u->i24;
868 for (
size_t i = 0; i < 3; i++)
869 *begin++ = (u24 >> 8 * i) & 0xff;
873 if (begin && (!end || end - begin >= 8))
874 stle_flt64(begin, u->r64);
877 if (begin && (!end || end - begin >= 5)) {
878 co_unsigned40_t u40 = u->i40 < 0
880 : (co_unsigned40_t)u->i40;
881 for (
size_t i = 0; i < 5; i++)
882 *begin++ = (u40 >> 8 * i) & 0xff;
886 if (begin && (!end || end - begin >= 6)) {
887 co_unsigned48_t u48 = u->i48 < 0
889 : (co_unsigned48_t)u->i48;
890 for (
size_t i = 0; i < 6; i++)
891 *begin++ = (u48 >> 8 * i) & 0xff;
895 if (begin && (!end || end - begin >= 7)) {
896 co_unsigned56_t u56 = u->i56 < 0
898 : (co_unsigned56_t)u->i56;
899 for (
size_t i = 0; i < 7; i++)
900 *begin++ = (u56 >> 8 * i) & 0xff;
904 if (begin && (!end || end - begin >= 8))
908 if (begin && (!end || end - begin >= 3)) {
909 for (
size_t i = 0; i < 3; i++)
910 *begin++ = (u->u24 >> 8 * i) & 0xff;
914 if (begin && (!end || end - begin >= 5)) {
915 for (
size_t i = 0; i < 5; i++)
916 *begin++ = (u->u40 >> 8 * i) & 0xff;
920 if (begin && (!end || end - begin >= 6)) {
921 for (
size_t i = 0; i < 6; i++)
922 *begin++ = (u->u48 >> 8 * i) & 0xff;
926 if (begin && (!end || end - begin >= 7)) {
927 for (
size_t i = 0; i < 7; i++)
928 *begin++ = (u->u56 >> 8 * i) & 0xff;
932 if (begin && (!end || end - begin >= 8))
979 const char16_t *us = ptr;
980 for (
size_t i = 0; i + 1 < n; i += 2) {
981 uint_least8_t tmp[2];
996 uint_least8_t *begin = (uint_least8_t *)&tmp;
997 uint_least8_t *end = begin +
sizeof(tmp);
1010co_val_lex(co_unsigned16_t type,
void *val,
const char *begin,
const char *end,
1014 assert(!end || end >= begin);
1020 const char *cp = begin;
1033 "boolean truth value overflow");
1036 *(co_boolean_t *)val = u.u8;
1051 "8-bit signed integer underflow");
1054 && u.i8 == INT8_MAX) {
1061 "8-bit signed integer overflow");
1064 *(co_integer8_t *)val = u.i8;
1073 && u.i16 == INT16_MIN) {
1080 "16-bit signed integer underflow");
1083 && u.i16 == INT16_MAX) {
1090 "16-bit signed integer overflow");
1093 *(co_integer16_t *)val = u.i16;
1102 && u.i32 == INT32_MIN) {
1109 "32-bit signed integer underflow");
1112 && u.i32 == INT32_MAX) {
1119 "32-bit signed integer overflow");
1122 *(co_integer32_t *)val = u.i32;
1137 "8-bit unsigned integer overflow");
1140 *(co_unsigned8_t *)val = u.u8;
1149 && u.u16 == UINT16_MAX) {
1156 "16-bit unsigned integer overflow");
1159 *(co_unsigned16_t *)val = u.u16;
1168 && u.u32 == UINT32_MAX) {
1175 "32-bit unsigned integer overflow");
1178 *(co_unsigned32_t *)val = u.u32;
1186 && u.u32 == UINT_LEAST32_MAX)
1188 "32-bit unsigned integer overflow");
1196 *(co_real32_t *)val = u.r32;
1205 "unable to create value of type VISIBLE_STRING");
1209 char *vs = *(
void **)val;
1222 "unable to create value of type OCTET_STRING");
1226 uint_least8_t *os = *(
void **)val;
1239 "unable to create value of type UNICODE_STRING");
1243 char16_t *us = *(
void **)val;
1246 for (
size_t i = 0; i + 1 < n; i += 2)
1247 us[i / 2] = letoh16(us[i / 2]);
1258 cp +=
lex_ctype(&isblank, cp, end, NULL);
1264 *(co_time_of_day_t *)val = u.t;
1272 "unable to create value of type DOMAIN");
1275 void *dom = *(
void **)val;
1290 "24-bit signed integer underflow");
1295 "24-bit signed integer overflow");
1298 *(co_integer24_t *)val = u.i32;
1306 && u.u64 == UINT_LEAST64_MAX)
1308 "64-bit unsigned integer overflow");
1316 *(co_real64_t *)val = u.r64;
1327 "40-bit signed integer underflow");
1332 "40-bit signed integer overflow");
1335 *(co_integer40_t *)val = u.i64;
1346 "48-bit signed integer underflow");
1351 "48-bit signed integer overflow");
1354 *(co_integer48_t *)val = u.i64;
1365 "56-bit signed integer underflow");
1370 "56-bit signed integer overflow");
1373 *(co_integer56_t *)val = u.i64;
1382 && u.i64 == INT64_MIN) {
1389 "64-bit signed integer underflow");
1392 && u.i64 == INT64_MAX) {
1399 "64-bit signed integer overflow");
1402 *(co_integer64_t *)val = u.i64;
1413 "24-bit unsigned integer overflow");
1416 *(co_unsigned24_t *)val = u.u32;
1427 "40-bit unsigned integer overflow");
1430 *(co_unsigned40_t *)val = u.u64;
1441 "48-bit unsigned integer overflow");
1444 *(co_unsigned48_t *)val = u.u64;
1455 "56-bit unsigned integer overflow");
1458 *(co_unsigned56_t *)val = u.u64;
1467 && u.u64 == UINT64_MAX) {
1474 "64-bit unsigned integer overflow");
1477 *(co_unsigned64_t *)val = u.u64;
1490co_val_print(co_unsigned16_t type,
const void *val,
char **pbegin,
char *end)
1511 char16_t *us = malloc(n);
1516 for (
size_t i = 0; i + 1 < n; i += 2)
1517 us[i / 2] =
htole16(us[i / 2]);
1531 const union co_val *u = val;
1543 return print_fmt(pbegin, end,
"0x%02" PRIx8, u->u8);
1545 return print_fmt(pbegin, end,
"0x%04" PRIx16, u->u16);
1547 return print_fmt(pbegin, end,
"0x%08" PRIx32, u->u32);
1561 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1571 return print_fmt(pbegin, end,
"0x%06" PRIx32, u->u24);
1573 return print_fmt(pbegin, end,
"0x%010" PRIx64, u->u40);
1575 return print_fmt(pbegin, end,
"0x%012" PRIx64, u->u48);
1577 return print_fmt(pbegin, end,
"0x%014" PRIx64, u->u56);
1579 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1588co_array_get_hdr(
const void *val)
1592 char *ptr = *(
char **)val;
1593 return ptr ? (
void *)(ptr - CO_ARRAY_HDR_OFFSET) : NULL;
1597co_array_alloc(
void *val,
size_t size)
1619 *(
char **)val = (
char *)hdr + CO_ARRAY_HDR_OFFSET;
1621 *(
char **)val = NULL;
1629co_array_free(
void *val)
1641co_array_init(
void *val,
size_t size)
1644 assert(val || !
size);
1647 memset(*(
char **)val, 0, hdr->
capacity);
1654co_array_fini(
void *val)
1657 co_array_init(val, 0);
1661 *(
char **)val = NULL;
1666co_array_sizeof(
const void *val)
1668 const struct co_array_hdr *hdr = co_array_get_hdr(val);
1670 return hdr ? hdr->
size : 0;
This header file is part of the utilities library; it contains the comparison function definitions.
This header file is part of the utilities library; it contains the diagnostic declarations.
size_t floc_lex(struct floc *at, const char *begin, const char *end)
Increments a file location by reading characters from a memory buffer.
void diag_if(enum diag_severity severity, int errc, const struct floc *at, const char *format,...)
Emits a diagnostic message occurring at a location in a text file.
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
void stle_u64(uint_least8_t dst[8], uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
uint_least16_t htole16(uint_least16_t x)
Converts a 16-bit unsigned integer from host to little-endian byte order.
uint_least32_t ldle_u32(const uint_least8_t src[4])
Loads a 32-bit unsigned integer in little-endian byte order.
void stle_i64(uint_least8_t dst[8], int_least64_t x)
Stores a 64-bit signed integer in little-endian byte order.
int_least32_t ldle_i32(const uint_least8_t src[4])
Loads a 32-bit signed integer in little-endian byte order.
int_least16_t ldle_i16(const uint_least8_t src[2])
Loads a 16-bit signed integer in little-endian byte order.
int_least64_t ldle_i64(const uint_least8_t src[8])
Loads a 64-bit signed integer in little-endian byte order.
uint_least16_t ldle_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in little-endian byte order.
void stle_i16(uint_least8_t dst[2], int_least16_t x)
Stores a 16-bit signed integer in little-endian byte order.
uint_least64_t ldle_u64(const uint_least8_t src[8])
Loads a 64-bit unsigned integer in little-endian byte order.
void stle_i32(uint_least8_t dst[4], int_least32_t x)
Stores a 32-bit signed integer in little-endian byte order.
void stle_u16(uint_least8_t dst[2], uint_least16_t x)
Stores a 16-bit unsigned integer in little-endian byte order.
void stle_u32(uint_least8_t dst[4], uint_least32_t x)
Stores a 32-bit unsigned integer in little-endian byte order.
@ ERRNUM_RANGE
Result too large.
@ ERRNUM_NOMEM
Not enough space.
@ ERRNUM_INVAL
Invalid argument.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
This header file is part of the utilities library; it contains the read file buffer declarations.
intmax_t frbuf_get_size(frbuf_t *buf)
Returns the size (in bytes) of the a read file buffer, or -1 on error.
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
intmax_t frbuf_get_pos(frbuf_t *buf)
Returns the current offset (in bytes) of a read file buffer with respect to the beginning of the file...
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size)
Reads bytes from the current position in a read file buffer.
This header file is part of the utilities library; it contains the (atomic) write file buffer declara...
ssize_t fwbuf_write(fwbuf_t *buf, const void *ptr, size_t size)
Writes bytes to the current position in a write file buffer.
void fwbuf_destroy(fwbuf_t *buf)
Destroys a write file buffer.
int fwbuf_commit(fwbuf_t *buf)
Commits all changes to a write file buffer to disk if all previous file operations were successful,...
fwbuf_t * fwbuf_create(const char *filename)
Creates a new (atomic) write file buffer.
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
#define CO_SDO_AC_ERROR
SDO abort code: General error.
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
#define MIN(a, b)
Returns the minimum of a and b.
This header file is part of the utilities library; it contains the lexer function declarations.
size_t lex_c99_i16(const char *begin, const char *end, struct floc *at, int_least16_t *pi16)
Lexes a C99 int_least16_t from a memory buffer.
size_t lex_ctype(int(*ctype)(int), const char *begin, const char *end, struct floc *at)
Greedily lexes a sequence of characters of the specified class from a memory buffer.
size_t lex_c99_u8(const char *begin, const char *end, struct floc *at, uint_least8_t *pu8)
Lexes a C99 uint_least8_t from a memory buffer.
size_t lex_base64(const char *begin, const char *end, struct floc *at, void *ptr, size_t *pn)
Lexes and decodes the Base64 representation of binary data from a memory buffer.
size_t lex_c99_str(const char *begin, const char *end, struct floc *at, char *s, size_t *pn)
Lexes a UTF-8 encoded Unicode string from a memory buffer.
size_t lex_c99_i8(const char *begin, const char *end, struct floc *at, int_least8_t *pi8)
Lexes a C99 int_least8_t from a memory buffer.
size_t lex_c99_u32(const char *begin, const char *end, struct floc *at, uint_least32_t *pu32)
Lexes a C99 uint_least32_t from a memory buffer.
size_t lex_c99_u64(const char *begin, const char *end, struct floc *at, uint_least64_t *pu64)
Lexes a C99 uint_least64_t from a memory buffer.
size_t lex_c99_i32(const char *begin, const char *end, struct floc *at, int_least32_t *pi32)
Lexes a C99 int_least32_t from a memory buffer.
size_t lex_c99_u16(const char *begin, const char *end, struct floc *at, uint_least16_t *pu16)
Lexes a C99 uint_least16_t from a memory buffer.
size_t lex_c99_i64(const char *begin, const char *end, struct floc *at, int_least64_t *pi64)
Lexes a C99 int_least64_t from a memory buffer.
This header file is part of the utilities library; it contains the printing function declarations.
size_t print_c99_i8(char **pbegin, char *end, int_least8_t i8)
Prints a C99 int_least8_t to a memory buffer.
size_t print_c99_str(char **pbegin, char *end, const char *s, size_t n)
Prints a UTF-8 encoded Unicode string to a memory buffer.
size_t print_char(char **pbegin, char *end, int c)
Prints a single character to a memory buffer.
size_t print_c99_u8(char **pbegin, char *end, uint_least8_t u8)
Prints a C99 uint_least8_t to a memory buffer.
size_t print_c99_i32(char **pbegin, char *end, int_least32_t i32)
Prints a C99 int_least32_t to a memory buffer.
size_t print_c99_u32(char **pbegin, char *end, uint_least32_t u32)
Prints a C99 uint_least32_t to a memory buffer.
size_t print_base64(char **pbegin, char *end, const void *ptr, size_t n)
Prints the Base64 representation of binary data to a memory buffer.
size_t print_c99_i16(char **pbegin, char *end, int_least16_t i16)
Prints a C99 int_least16_t to a memory buffer.
size_t print_c99_i64(char **pbegin, char *end, int_least64_t i64)
Prints a C99 int_least64_t to a memory buffer.
size_t print_c99_u16(char **pbegin, char *end, uint_least16_t u16)
Prints a C99 uint_least16_t to a memory buffer.
size_t print_fmt(char **pbegin, char *end, const char *format,...)
Prints a formatted string to a memory buffer.
This is the internal header file of the CANopen library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
This header file is part of the C11 and POSIX compatibility library; it includes <string....
An read file buffer struct.
An (atomic) write file buffer struct.
The header directly preceding the bytes in a CANopen array.
size_t size
The current size (in bytes).
size_t capacity
The total capacity (in bytes).
A location in a text file.
#define CO_DEFTYPE_UNICODE_STRING
The data type (and object index) of an array of (16-bit) Unicode characters.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
#define CO_DEFTYPE_INTEGER24
The data type (and object index) of a 24-bit signed integer.
#define CO_DEFTYPE_UNSIGNED48
The data type (and object index) of a 48-bit unsigned integer.
#define CO_DEFTYPE_INTEGER48
The data type (and object index) of a 48-bit signed integer.
#define CO_DEFTYPE_VISIBLE_STRING
The data type (and object index) of an array of visible characters.
#define CO_DEFTYPE_UNSIGNED40
The data type (and object index) of a 40-bit unsigned integer.
int co_type_is_array(co_unsigned16_t type)
Returns 1 if the specified (static) data type is an array, and 0 if not.
#define CO_DEFTYPE_INTEGER56
The data type (and object index) of a 56-bit signed integer.
#define CO_DEFTYPE_UNSIGNED64
The data type (and object index) of a 64-bit unsigned integer.
#define CO_DEFTYPE_INTEGER8
The data type (and object index) of an 8-bit signed integer.
#define CO_DEFTYPE_DOMAIN
The data type (and object index) of an arbitrary large block of data.
#define CO_DEFTYPE_UNSIGNED24
The data type (and object index) of a 24-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_REAL64
The data type (and object index) of a 64-bit IEEE-754 floating-point number.
#define CO_DEFTYPE_BOOLEAN
The data type (and object index) of a boolean truth value.
#define CO_DEFTYPE_INTEGER40
The data type (and object index) of a 40-bit signed integer.
#define CO_DEFTYPE_TIME_OF_DAY
The data type (and object index) of a 48-bit structure representing the absolute time.
size_t co_type_sizeof(co_unsigned16_t type)
Returns the native size (in bytes) of a value of the specified data type, or 1 if it is not a static ...
#define CO_DEFTYPE_INTEGER32
The data type (and object index) of a 32-bit signed integer.
#define CO_DEFTYPE_INTEGER64
The data type (and object index) of a 64-bit signed integer.
#define CO_DEFTYPE_UNSIGNED56
The data type (and object index) of a 56-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
#define CO_DEFTYPE_INTEGER16
The data type (and object index) of a 16-bit signed integer.
#define CO_DEFTYPE_OCTET_STRING
The data type (and object index) of an array of octets.
#define CO_DEFTYPE_REAL32
The data type (and object index) of a 32-bit IEEE-754 floating-point number.
#define CO_DEFTYPE_TIME_DIFF
The data type (and object index) of a 48-bit structure representing a time difference.
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types....
ptrdiff_t ssize_t
Used for a count of bytes or an error indication.
A union of the CANopen static data types.
This header file is part of the utilities library; it contains (16-bit) Unicode string functions.
int str16ncmp(const char16_t *s1, const char16_t *s2, size_t n)
Compares two (16-bit) Unicode strings.
char16_t * str16ncpy(char16_t *dst, const char16_t *src, size_t n)
Copies n (16-bit) Unicode characters from the string at src to dst.
size_t str16len(const char16_t *s)
Returns the number of (16-bit) Unicode characters, excluding the terminating null bytes,...
size_t co_val_read_frbuf(co_unsigned16_t type, void *val, frbuf_t *buf)
Reads a value of the specified data type from the current position in a read file buffer.
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.
int co_val_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
size_t co_val_move(co_unsigned16_t type, void *dst, void *src)
Moves one value to another.
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.
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).
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.
int co_val_init_dom(void **val, const void *dom, size_t n)
Initializes an arbitrary large block of data (CO_DEFTYPE_DOMAIN).
size_t co_val_copy(co_unsigned16_t type, void *dst, const void *src)
Copies one value to another.
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.
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).
int co_val_init_vs_n(char **val, const char *vs, size_t n)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
size_t co_val_read_file(co_unsigned16_t type, void *val, const char *filename)
Reads a value of the specified data type from a file.
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_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.
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.
int co_val_init_min(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its lower limit.
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.
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.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
int co_val_init_vs(char **val, const char *vs)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
size_t co_val_write_file(co_unsigned16_t type, const void *val, const char *filename)
Writes a value of the specified data type to a file.
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.
size_t co_val_write_fwbuf(co_unsigned16_t type, const void *val, fwbuf_t *buf)
Writes a value of the specified data type to the current position in a write file buffer.
int co_val_init_max(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its upper limit.
This header file is part of the CANopen library; it contains the CANopen value declarations.
#define CO_INTEGER8_MIN
The minimum value of an 8-bit signed integer.
#define CO_INTEGER64_MAX
The maximum value of a 64-bit signed integer.
#define CO_INTEGER32_MAX
The maximum value of a 32-bit signed integer.
#define CO_INTEGER24_MAX
The maximum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_UNSIGNED8_MAX
The maximum value of an 8-bit unsigned integer.
#define CO_INTEGER16_MAX
The maximum value of a 16-bit signed integer.
#define CO_ARRAY_CAPACITY
The default capacity (in bytes) of a statically allocated CANopen array.
#define CO_UNSIGNED32_MAX
The maximum value of a 32-bit unsigned integer.
#define CO_INTEGER48_MAX
The maximum value of a 48-bit signed integer (encoded as an int64_t).
#define CO_INTEGER24_MIN
The minimum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_BOOLEAN_MAX
The maximum value of a boolean truth value (true).
#define CO_UNSIGNED64_MAX
The maximum value of a 64-bit unsigned integer.
#define CO_INTEGER32_MIN
The minimum value of a 32-bit signed integer.
#define CO_INTEGER40_MAX
The maximum value of a 40-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED40_MAX
The maximum value of a 40-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER64_MIN
The minimum value of a 64-bit signed integer.
#define CO_UNSIGNED56_MAX
The maximum value of a 56-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER48_MIN
The minimum value of a 48-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED48_MAX
The maximum value of a 48-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER56_MAX
The maximum value of a 56-bit signed integer (encoded as an int64_t).
#define CO_INTEGER40_MIN
The minimum value of a 40-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED24_MAX
The maximum value of a 24-bit unsigned integer (encoded as a uint32_t).
#define CO_INTEGER16_MIN
The minimum value of a 16-bit signed integer.
#define CO_INTEGER56_MIN
The minimum value of a 56-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED16_MAX
The maximum value of a 16-bit unsigned integer.
#define CO_INTEGER8_MAX
The maximum value of an 8-bit signed integer.