Lely core libraries
2.3.4
|
Go to the documentation of this file.
49 static int snprintf_c99_sobj(
char *s,
size_t n,
const co_obj_t *obj);
50 static int snprintf_c99_ssub(
char *s,
size_t n,
const co_sub_t *sub);
51 static int snprintf_c99_sval(
52 char *s,
size_t n, co_unsigned16_t type,
const void *val);
53 static int snprintf_c99_esc(
char *s,
size_t n,
const char *esc);
57 __co_dev_init_from_sdev(
struct __co_dev *dev,
const struct co_sdev *sdev)
68 if (!__co_dev_init(dev, sdev->
id)) {
73 if (co_sdev_load(sdev, dev) == -1) {
99 if (!__co_dev_init_from_sdev(dev, sdev)) {
130 r = snprintf(s, n,
"{\n\t.id = 0x%02x,\n",
co_dev_get_id(dev));
133 goto error_print_dev;
136 r =
MIN((
size_t)r, n);
142 r = snprintf(s, n,
"\t.name = CO_SDEV_STRING(\"");
145 goto error_print_dev;
148 r =
MIN((
size_t)r, n);
151 r = snprintf_c99_esc(s, n,
name);
154 goto error_print_dev;
157 r =
MIN((
size_t)r, n);
160 r = snprintf(s, n,
"\"),\n");
162 r = snprintf(s, n,
"\t.name = NULL,\n");
166 goto error_print_dev;
169 r =
MIN((
size_t)r, n);
175 r = snprintf(s, n,
"\t.vendor_name = CO_SDEV_STRING(\"");
178 goto error_print_dev;
181 r =
MIN((
size_t)r, n);
184 r = snprintf_c99_esc(s, n,
name);
187 goto error_print_dev;
190 r =
MIN((
size_t)r, n);
193 r = snprintf(s, n,
"\"),\n");
195 r = snprintf(s, n,
"\t.vendor_name = NULL,\n");
199 goto error_print_dev;
202 r =
MIN((
size_t)r, n);
206 r = snprintf(s, n,
"\t.vendor_id = 0x%08" PRIx32
",\n",
210 goto error_print_dev;
213 r =
MIN((
size_t)r, n);
219 r = snprintf(s, n,
"\t.product_name = CO_SDEV_STRING(\"");
222 goto error_print_dev;
225 r =
MIN((
size_t)r, n);
228 r = snprintf_c99_esc(s, n,
name);
231 goto error_print_dev;
234 r =
MIN((
size_t)r, n);
237 r = snprintf(s, n,
"\"),\n");
239 r = snprintf(s, n,
"\t.product_name = NULL,\n");
243 goto error_print_dev;
246 r =
MIN((
size_t)r, n);
251 "\t.product_code = 0x%08" PRIx32
252 ",\n\t.revision = 0x%08" PRIx32
",\n",
256 goto error_print_dev;
259 r =
MIN((
size_t)r, n);
265 r = snprintf(s, n,
"\t.order_code = CO_SDEV_STRING(\"");
268 goto error_print_dev;
271 r =
MIN((
size_t)r, n);
274 r = snprintf_c99_esc(s, n,
name);
277 goto error_print_dev;
280 r =
MIN((
size_t)r, n);
283 r = snprintf(s, n,
"\"),\n");
285 r = snprintf(s, n,
"\t.order_code = NULL,\n");
289 goto error_print_dev;
292 r =
MIN((
size_t)r, n);
296 r = snprintf(s, n,
"\t.baud = 0");
299 goto error_print_dev;
302 r =
MIN((
size_t)r, n);
306 #define LELY_CO_DEFINE_BAUD(x) \
307 if (baud & CO_BAUD_##x) { \
308 r = snprintf(s, n, "\n\t\t| CO_BAUD_" #x); \
311 goto error_print_dev; \
314 r = MIN((size_t)r, n); \
319 LELY_CO_DEFINE_BAUD(1000)
320 LELY_CO_DEFINE_BAUD(800)
321 LELY_CO_DEFINE_BAUD(500)
322 LELY_CO_DEFINE_BAUD(250)
323 LELY_CO_DEFINE_BAUD(125)
324 LELY_CO_DEFINE_BAUD(50)
325 LELY_CO_DEFINE_BAUD(20)
326 LELY_CO_DEFINE_BAUD(10)
327 LELY_CO_DEFINE_BAUD(AUTO)
329 #undef LELY_CO_DEFINE_BAUD
332 ",\n\t.rate = %d,\n\t.lss = %d,\n\t.dummy = 0x%08" PRIx32
338 goto error_print_dev;
341 r =
MIN((
size_t)r, n);
346 co_unsigned16_t *idx = malloc(maxidx *
sizeof(co_unsigned16_t));
349 goto error_malloc_idx;
353 r = snprintf(s, n,
"\t.nobj = %d,\n\t.objs = (const struct co_sobj[]){",
357 goto error_print_obj;
360 r =
MIN((
size_t)r, n);
364 for (
size_t i = 0; i < maxidx; i++) {
365 r = snprintf(s, n, i ?
", {\n" :
"{\n");
368 goto error_print_obj;
371 r =
MIN((
size_t)r, n);
377 goto error_print_obj;
380 r =
MIN((
size_t)r, n);
383 r = snprintf(s, n,
"\t}");
386 goto error_print_obj;
389 r =
MIN((
size_t)r, n);
394 r = snprintf(s, n,
"}\n}");
397 goto error_print_obj;
420 char *s = malloc(n + 1);
436 #endif // !LELY_NO_STDIO
444 #if !LELY_NO_CO_OBJ_NAME
454 #if !LELY_NO_CO_OBJ_NAME
462 #if !LELY_NO_CO_OBJ_NAME
474 for (
size_t i = 0; i < sdev->
nobj; i++) {
485 if (co_sobj_load(sobj, obj) == -1)
498 #if !LELY_NO_CO_OBJ_NAME
506 for (
size_t i = 0; i < sobj->
nsub; i++) {
517 if (co_ssub_load(ssub, sub) == -1)
530 #if !LELY_NO_CO_OBJ_NAME
541 #if !LELY_NO_CO_OBJ_LIMITS
553 #if !LELY_NO_CO_OBJ_DEFAULT
574 snprintf_c99_sobj(
char *s,
size_t n,
const co_obj_t *obj)
584 #if !LELY_NO_CO_OBJ_NAME
588 "#if !LELY_NO_CO_OBJ_NAME\n\t\t.name = CO_SDEV_STRING(\"");
592 r =
MIN((
size_t)r, n);
595 r = snprintf_c99_esc(s, n,
name);
599 r =
MIN((
size_t)r, n);
602 r = snprintf(s, n,
"\"),\n");
606 "#if !LELY_NO_CO_OBJ_NAME\n\t\t.name = NULL,\n");
607 #if !LELY_NO_CO_OBJ_NAME
613 r =
MIN((
size_t)r, n);
617 r = snprintf(s, n,
"#endif\n\t\t.idx = 0x%04x,\n\t\t.code = ",
622 r =
MIN((
size_t)r, n);
628 case CO_OBJECT_NULL: r = snprintf(s, n,
"CO_OBJECT_NULL,\n");
break;
631 r = snprintf(s, n,
"CO_OBJECT_DEFTYPE,\n");
634 r = snprintf(s, n,
"CO_OBJECT_DEFSTRUCT,\n");
636 case CO_OBJECT_VAR: r = snprintf(s, n,
"CO_OBJECT_VAR,\n");
break;
639 default: r = snprintf(s, n,
"0x%02x,\n", code);
break;
644 r =
MIN((
size_t)r, n);
648 co_unsigned8_t
subidx[0xff];
652 "\t\t.nsub = %d,\n\t\t.subs = (const struct co_ssub[]){",
657 r =
MIN((
size_t)r, n);
661 for (
size_t i = 0; i < maxsubidx; i++) {
662 r = snprintf(s, n, i ?
", {\n" :
"{\n");
666 r =
MIN((
size_t)r, n);
673 r =
MIN((
size_t)r, n);
676 r = snprintf(s, n,
"\t\t}");
680 r =
MIN((
size_t)r, n);
685 r = snprintf(s, n,
"}\n");
694 snprintf_c99_ssub(
char *s,
size_t n,
const co_sub_t *sub)
704 #if !LELY_NO_CO_OBJ_NAME
708 "#if !LELY_NO_CO_OBJ_NAME\n\t\t\t.name = CO_SDEV_STRING(\"");
712 r =
MIN((
size_t)r, n);
715 r = snprintf_c99_esc(s, n,
name);
719 r =
MIN((
size_t)r, n);
722 r = snprintf(s, n,
"\"),\n");
726 "#if !LELY_NO_CO_OBJ_NAME\n\t\t\t.name = NULL,\n");
727 #if !LELY_NO_CO_OBJ_NAME
733 r =
MIN((
size_t)r, n);
737 r = snprintf(s, n,
"#endif\n\t\t\t.subidx = 0x%02x,\n\t\t\t.type = ",
742 r =
MIN((
size_t)r, n);
748 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
749 case CO_DEFTYPE_##a: \
750 r = snprintf(s, n, "CO_DEFTYPE_" #a ",\n"); \
752 #include <lely/co/def/type.def>
753 #undef LELY_CO_DEFINE_TYPE
754 default: r = snprintf(s, n,
"0x%04x,\n",
type);
break;
759 r =
MIN((
size_t)r, n);
763 r = snprintf(s, n,
"#if !LELY_NO_CO_OBJ_LIMITS\n\t\t\t.min = ");
767 r =
MIN((
size_t)r, n);
770 #if !LELY_NO_CO_OBJ_LIMITS
775 r = snprintf_c99_sval(s, n, type, &min);
781 r =
MIN((
size_t)r, n);
785 r = snprintf(s, n,
",\n\t\t\t.max = ");
789 r =
MIN((
size_t)r, n);
792 #if !LELY_NO_CO_OBJ_LIMITS
797 r = snprintf_c99_sval(s, n, type, &max);
803 r =
MIN((
size_t)r, n);
808 ",\n#endif\n#if !LELY_NO_CO_OBJ_DEFAULT\n\t\t\t.def = ");
812 r =
MIN((
size_t)r, n);
815 #if !LELY_NO_CO_OBJ_DEFAULT
820 r = snprintf_c99_sval(s, n, type, &def);
826 r =
MIN((
size_t)r, n);
830 r = snprintf(s, n,
",\n#endif\n\t\t\t.val = ");
834 r =
MIN((
size_t)r, n);
837 #if !LELY_NO_CO_OBJ_FILE
852 r =
MIN((
size_t)r, n);
856 r = snprintf(s, n,
",\n\t\t\t.access = ");
860 r =
MIN((
size_t)r, n);
865 case CO_ACCESS_RO: r = snprintf(s, n,
"CO_ACCESS_RO,\n");
break;
866 case CO_ACCESS_WO: r = snprintf(s, n,
"CO_ACCESS_WO,\n");
break;
867 case CO_ACCESS_RW: r = snprintf(s, n,
"CO_ACCESS_RW,\n");
break;
868 case CO_ACCESS_RWR: r = snprintf(s, n,
"CO_ACCESS_RWR,\n");
break;
869 case CO_ACCESS_RWW: r = snprintf(s, n,
"CO_ACCESS_RWW,\n");
break;
871 default: r = snprintf(s, n,
"0x%x,\n", access);
break;
876 r =
MIN((
size_t)r, n);
880 r = snprintf(s, n,
"\t\t\t.pdo_mapping = %d,\n",
885 r =
MIN((
size_t)r, n);
889 r = snprintf(s, n,
"\t\t\t.flags = 0\n");
893 r =
MIN((
size_t)r, n);
897 #define LELY_CO_DEFINE_FLAGS(x) \
898 if (flags & CO_OBJ_FLAGS_##x) { \
899 r = snprintf(s, n, "\t\t\t\t| CO_OBJ_FLAGS_" #x "\n"); \
903 r = MIN((size_t)r, n); \
908 LELY_CO_DEFINE_FLAGS(READ)
909 LELY_CO_DEFINE_FLAGS(WRITE)
910 #if !LELY_NO_CO_OBJ_FILE
911 LELY_CO_DEFINE_FLAGS(UPLOAD_FILE)
912 LELY_CO_DEFINE_FLAGS(DOWNLOAD_FILE)
914 LELY_CO_DEFINE_FLAGS(MIN_NODEID)
915 LELY_CO_DEFINE_FLAGS(MAX_NODEID)
916 LELY_CO_DEFINE_FLAGS(DEF_NODEID)
917 LELY_CO_DEFINE_FLAGS(VAL_NODEID)
920 LELY_CO_DEFINE_FLAGS(PARAMETER_VALUE)
922 #undef LELY_CO_DEFINE_FLAGS
928 snprintf_c99_sval(
char *s,
size_t n, co_unsigned16_t type,
const void *val)
938 const union co_val *u = val;
941 r = snprintf(s, n,
"{ .b = %d }", !!u->b);
945 r = snprintf(s, n,
"{ .i8 = CO_INTEGER8_MIN }");
947 r = snprintf(s, n,
"{ .i8 = CO_INTEGER8_MAX }");
949 r = snprintf(s, n,
"{ .i8 = %" PRIi8
" }", u->i8);
954 r = snprintf(s, n,
"{ .i16 = CO_INTEGER16_MIN }");
956 r = snprintf(s, n,
"{ .i16 = CO_INTEGER16_MAX }");
958 r = snprintf(s, n,
"{ .i16 = %" PRIi16
" }", u->i16);
963 r = snprintf(s, n,
"{ .i32 = CO_INTEGER32_MIN }");
965 r = snprintf(s, n,
"{ .i32 = CO_INTEGER32_MAX }");
967 r = snprintf(s, n,
"{ .i32 = %" PRIi32
"l }", u->i32);
972 r = snprintf(s, n,
"{ .u8 = CO_UNSIGNED8_MIN }");
974 r = snprintf(s, n,
"{ .u8 = CO_UNSIGNED8_MAX }");
976 r = snprintf(s, n,
"{ .u8 = 0x%02" PRIx8
" }", u->u8);
981 r = snprintf(s, n,
"{ .u16 = CO_UNSIGNED16_MIN }");
983 r = snprintf(s, n,
"{ .u16 = CO_UNSIGNED16_MAX }");
985 r = snprintf(s, n,
"{ .u16 = 0x%04" PRIx16
"u }",
991 r = snprintf(s, n,
"{ .u32 = CO_UNSIGNED32_MIN }");
993 r = snprintf(s, n,
"{ .u32 = CO_UNSIGNED32_MAX }");
995 r = snprintf(s, n,
"{ .u32 = 0x%08" PRIx32
"lu }",
1001 r = snprintf(s, n,
"{ .r32 = CO_REAL32_MIN }");
1003 r = snprintf(s, n,
"{ .r32 = CO_REAL32_MAX }");
1005 r = snprintf(s, n,
"{ .r32 = %.*g }", DECIMAL_DIG,
1011 r = snprintf(s, n,
"{ .vs = CO_VISIBLE_STRING_C(\"");
1015 r =
MIN((
size_t)r, n);
1018 r = snprintf_c99_esc(s, n, u->vs);
1022 r =
MIN((
size_t)r, n);
1025 r = snprintf(s, n,
"\") }");
1027 r = snprintf(s, n,
"{ .vs = NULL }");
1033 "{ .os = CO_OCTET_STRING_C(\n\t\t\t\t\"");
1037 r =
MIN((
size_t)r, n);
1041 for (
size_t i = 0; i < size; i++) {
1043 r = snprintf(s, n, i && !(i % 8)
1044 ?
"\"\n\t\t\t\t\"\\x%02x"
1051 r =
MIN((
size_t)r, n);
1055 r = snprintf(s, n,
"\"\n\t\t\t) }");
1057 r = snprintf(s, n,
"{ .vs = NULL }");
1063 "{ .us = CO_UNICODE_STRING_C({\n\t\t\t\t");
1067 r =
MIN((
size_t)r, n);
1071 for (
size_t i = 0; i < size; i++) {
1073 r = snprintf(s, n, i && !(i % 4)
1074 ?
",\n\t\t\t\t0x%04x"
1075 : (i ?
", 0x%04x" :
"0x%04x"),
1081 r =
MIN((
size_t)r, n);
1085 r = snprintf(s, n,
"\n\t\t\t}) }");
1087 r = snprintf(s, n,
"{ .us = NULL }");
1093 ".ms = 0x%08" PRIx32
", "
1094 ".days = 0x%04" PRIx16
" "
1096 u->t.ms, u->t.days);
1101 ".ms = 0x%08" PRIx32
", "
1102 ".days = 0x%04" PRIx16
" "
1104 u->td.ms, u->td.days);
1109 "{ .dom = CO_DOMAIN_C(co_unsigned8_t, {\n\t\t\t\t");
1113 r =
MIN((
size_t)r, n);
1116 const co_unsigned8_t *bp = u->dom;
1118 for (
size_t i = 0; i < size; i++) {
1120 r = snprintf(s, n, i && !(i % 8)
1121 ?
",\n\t\t\t\t0x%02x"
1122 : (i ?
", 0x%02x" :
"0x%02x"),
1128 r =
MIN((
size_t)r, n);
1132 r = snprintf(s, n,
"\n\t\t\t}) }");
1134 r = snprintf(s, n,
"{ .dom = NULL }");
1139 r = snprintf(s, n,
"{ .i24 = CO_INTEGER24_MIN }");
1141 r = snprintf(s, n,
"{ .i24 = CO_INTEGER24_MAX }");
1143 r = snprintf(s, n,
"{ .i24 = %" PRIi32
"l }", u->i24);
1148 r = snprintf(s, n,
"{ .r64 = CO_REAL64_MIN }");
1150 r = snprintf(s, n,
"{ .r64 = CO_REAL64_MAX }");
1152 r = snprintf(s, n,
"{ .r64 = %.*g }", DECIMAL_DIG,
1158 r = snprintf(s, n,
"{ CO_INTEGER40_MIN }");
1160 r = snprintf(s, n,
"{ CO_INTEGER40_MAX }");
1162 r = snprintf(s, n,
"{ .i40 = %" PRIi64
"ll }", u->i40);
1167 r = snprintf(s, n,
"{ .i48 = CO_INTEGER48_MIN }");
1169 r = snprintf(s, n,
"{ .i48 = CO_INTEGER48_MAX }");
1171 r = snprintf(s, n,
"{ .i48 = %" PRIi64
"ll }", u->i48);
1176 r = snprintf(s, n,
"{ .i56 = CO_INTEGER56_MIN }");
1178 r = snprintf(s, n,
"{ .i56 = CO_INTEGER56_MAX }");
1180 r = snprintf(s, n,
"{ .i56 = %" PRIi64
"ll }", u->i56);
1185 r = snprintf(s, n,
"{ .i64 = CO_INTEGER64_MIN }");
1187 r = snprintf(s, n,
"{ .i64 = CO_INTEGER64_MAX }");
1189 r = snprintf(s, n,
"{ .i64 = %" PRIi64
"ll }", u->i64);
1194 r = snprintf(s, n,
"{ .u24 = CO_UNSIGNED24_MIN }");
1196 r = snprintf(s, n,
"{ .u24 = CO_UNSIGNED24_MAX }");
1198 r = snprintf(s, n,
"{ .u24 = 0x%06" PRIx32
"lu }",
1204 r = snprintf(s, n,
"{ .u40 = CO_UNSIGNED40_MIN }");
1206 r = snprintf(s, n,
"{ .u40 = CO_UNSIGNED40_MAX }");
1208 r = snprintf(s, n,
"{ .u40 = 0x%010" PRIx64
"llu }",
1214 r = snprintf(s, n,
"{ .u48 = CO_UNSIGNED48_MIN }");
1216 r = snprintf(s, n,
"{ .u48 = CO_UNSIGNED48_MAX }");
1218 r = snprintf(s, n,
"{ .u48 = 0x%012" PRIx64
"llu }",
1224 r = snprintf(s, n,
"{ .u56 = CO_UNSIGNED56_MIN }");
1226 r = snprintf(s, n,
"{ .u56 = CO_UNSIGNED56_MAX }");
1228 r = snprintf(s, n,
"{ .u56 = 0x%014" PRIx64
"llu }",
1234 r = snprintf(s, n,
"{ .u64 = CO_UNSIGNED64_MIN }");
1236 r = snprintf(s, n,
"{ .u64 = CO_UNSIGNED64_MAX }");
1238 r = snprintf(s, n,
"{ .u64 = 0x%016" PRIx64
"llu }",
1242 default: r = 0;
break;
1252 snprintf_c99_esc(
char *s,
size_t n,
const char *esc)
1265 size_t chars =
lex_utf8(esc, NULL, NULL, &c32);
1270 char buf[12] = {
'\0' };
1274 int r = snprintf(s, n,
"%s", buf);
1278 r =
MIN((
size_t)r, n);
1286 #endif // !LELY_NO_STDIO
1288 #endif // !LELY_NO_CO_SDEV
#define CO_DEFTYPE_UNSIGNED64
The data type (and object index) of a 64-bit unsigned integer.
void co_sub_set_flags(co_sub_t *sub, unsigned int flags)
Sets the object flags of a CANopen sub-object.
#define CO_DEFTYPE_INTEGER8
The data type (and object index) of an 8-bit signed integer.
union co_val def
The default value of val.
int co_val_init_max(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its upper limit.
const char * vendor_name
A pointer to the vendor name.
#define CO_OBJECT_DOMAIN
A large variable amount of data.
co_unsigned32_t product_code
The product code.
co_dev_t * co_dev_create_from_sdev(const struct co_sdev *sdev)
Creates a CANopen device from a static device description.
#define CO_INTEGER16_MIN
The minimum value of a 16-bit signed integer.
#define CO_DEFTYPE_INTEGER64
The data type (and object index) of a 64-bit signed integer.
#define CO_UNSIGNED32_MIN
The minimum value of a 32-bit unsigned integer.
int asprintf_c99_sdev(char **ps, const co_dev_t *dev)
Equivalent to snprintf_c99_sdev(), except that it allocates a string large enough to hold the output,...
union co_val val
The sub-object value.
#define CO_OBJECT_DEFTYPE
A type definitions.
#define CO_REAL64_MIN
The minimum value of a 64-bit IEEE-754 floating-point number.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
#define CO_OBJECT_ARRAY
A multiple data field object where each data field is a simple variable of the same basic data type.
#define CO_DEFTYPE_INTEGER40
The data type (and object index) of a 40-bit signed integer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
co_unsigned32_t co_dev_get_vendor_id(const co_dev_t *dev)
Returns the vendor ID of a CANopen device.
int co_obj_insert_sub(co_obj_t *obj, co_sub_t *sub)
Inserts a sub-object into a CANopen object.
co_unsigned16_t co_dev_get_rate(const co_dev_t *dev)
Returns the (pending) baudrate of a CANopen device (in kbit/s).
#define CO_DEFTYPE_INTEGER32
The data type (and object index) of a 32-bit signed integer.
A static CANopen sub-object.
void co_sub_set_pdo_mapping(co_sub_t *sub, int pdo_mapping)
Enables or disables PDO mapping a CANopen sub-object.
int co_val_init_min(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its lower limit.
#define CO_ACCESS_RWW
Read or write on process output.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
#define CO_INTEGER56_MAX
The maximum value of a 56-bit signed integer (encoded as an int64_t).
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.
const char * name
A pointer to the name of the sub-object.
unsigned baud
The supported bit rates.
#define MIN(a, b)
Returns the minimum of a and b.
void co_dev_set_rate(co_dev_t *dev, co_unsigned16_t rate)
Sets the (pending) baudrate of a CANopen device.
#define CO_INTEGER56_MIN
The minimum 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_UNSIGNED8_MIN
The minimum value of an 8-bit unsigned integer.
const char * co_dev_get_name(const co_dev_t *dev)
Returns the name of a CANopen device.
#define CO_DEFTYPE_TIME_DIFF
The data type (and object index) of a 48-bit structure representing a time difference.
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
const void * co_sub_get_val(const co_sub_t *sub)
Returns a pointer to the current value of a CANopen sub-object.
const char * co_dev_get_product_name(const co_dev_t *dev)
Returns a pointer to the product name of a CANopen device.
#define CO_DEFTYPE_BOOLEAN
The data type (and object index) of a boolean truth value.
#define CO_DEFTYPE_VISIBLE_STRING
The data type (and object index) of an array of visible characters.
size_t co_sub_set_min(co_sub_t *sub, const void *ptr, size_t n)
Sets the lower limit of a value of a CANopen sub-object.
void co_obj_destroy(co_obj_t *obj)
Destroys a CANopen object, including its sub-objects.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_DOMAIN
The data type (and object index) of an arbitrary large block of data.
void co_dev_set_product_code(co_dev_t *dev, co_unsigned32_t product_code)
Sets the product code of a CANopen device.
int co_sub_set_access(co_sub_t *sub, unsigned int access)
Sets the access type of a CANopen sub-object.
#define CO_INTEGER64_MIN
The minimum value of a 64-bit signed integer.
int co_sub_get_pdo_mapping(const co_sub_t *sub)
Returns 1 if it is possible to map the specified CANopen sub-object into a PDO, and 0 if not.
#define CO_UNSIGNED16_MIN
The minimum value of a 16-bit unsigned integer.
#define CO_INTEGER48_MIN
The minimum value of a 48-bit signed integer (encoded as an int64_t).
#define CO_ACCESS_RWR
Read or write on process input.
const void * co_sub_get_max(const co_sub_t *sub)
Returns a pointer to the upper limit of the value of a CANopen sub-object.
#define CO_UNSIGNED48_MIN
The minimum value of a 48-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER32_MIN
The minimum value of a 32-bit signed integer.
uint_least32_t flags
The object flags.
#define CO_REAL32_MIN
The minimum value of a 32-bit IEEE-754 floating-point number.
void co_dev_set_lss(co_dev_t *dev, int lss)
Sets the LSS support flag.
co_unsigned32_t dummy
The data types supported for mapping dummy entries in PDOs.
co_unsigned32_t co_dev_get_revision(const co_dev_t *dev)
Returns the revision number of a CANopen device.
const struct co_sobj * objs
An array of objects.
#define CO_OBJECT_DEFSTRUCT
A record type definition.
#define CO_DEFTYPE_OCTET_STRING
The data type (and object index) of an array of octets.
#define CO_DEFTYPE_INTEGER56
The data type (and object index) of a 56-bit signed integer.
#define CO_DEFTYPE_REAL64
The data type (and object index) of a 64-bit IEEE-754 floating-point number.
int lss
A flag specifying whether LSS is supported (1) or not (0).
const void * co_sub_get_min(const co_sub_t *sub)
Returns a pointer to the lower limit of the value of a CANopen sub-object.
const char * name
A pointer to the name of the device.
co_unsigned32_t co_dev_get_dummy(const co_dev_t *dev)
Returns the data types supported by a CANopen device for mapping dummy entries in PDOs (one bit for e...
const char * co_obj_get_name(const co_obj_t *obj)
Returns the name of a CANopen object.
co_unsigned8_t co_obj_get_subidx(const co_obj_t *obj, co_unsigned8_t maxsubidx, co_unsigned8_t *subidx)
Retrieves a list of sub-indices in a CANopen object.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
const void * co_sub_get_def(const co_sub_t *sub)
Returns a pointer to the default value of a CANopen sub-object.
size_t lex_utf8(const char *begin, const char *end, struct floc *at, char32_t *pc32)
Lexes a UTF-8 encoded Unicode character from a memory buffer.
#define CO_DEFTYPE_UNSIGNED56
The data type (and object index) of a 56-bit unsigned integer.
co_unsigned8_t code
The object code.
const char * product_name
A pointer to the product name.
const char * co_sub_get_name(const co_sub_t *sub)
Returns the name of a CANopen sub-object.
co_unsigned32_t vendor_id
The vendor ID.
#define CO_INTEGER8_MIN
The minimum value of an 8-bit signed integer.
#define CO_UNSIGNED56_MAX
The maximum value of a 56-bit unsigned integer (encoded as a uint64_t).
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
co_unsigned16_t rate
The (pending) baudrate (in kbit/s).
#define CO_ACCESS_WO
Write-only access.
#define CO_INTEGER40_MAX
The maximum value of a 40-bit signed integer (encoded as an int64_t).
#define CO_INTEGER48_MAX
The maximum value of a 48-bit signed integer (encoded as an int64_t).
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.
unsigned int co_sub_get_flags(const co_sub_t *sub)
Returns the object flags of a CANopen sub-object.
#define CO_UNSIGNED24_MAX
The maximum value of a 24-bit unsigned integer (encoded as a uint32_t).
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
co_unsigned16_t co_dev_get_idx(const co_dev_t *dev, co_unsigned16_t maxidx, co_unsigned16_t *idx)
Retrieves a list of object indices in the object dictionary of a CANopen device.
#define CO_UNSIGNED16_MAX
The maximum value of a 16-bit unsigned integer.
#define CO_ACCESS_RO
Read-only access.
#define CO_DEFTYPE_UNSIGNED24
The data type (and object index) of a 24-bit unsigned integer.
co_unsigned8_t id
The node-ID.
@ ERRNUM_INVAL
Invalid argument.
uint_least32_t access
The access type.
#define CO_OBJECT_VAR
A single value.
#define CO_UNSIGNED64_MAX
The maximum value of a 64-bit unsigned integer.
size_t co_sub_set_def(co_sub_t *sub, const void *ptr, size_t n)
Sets the default value of a CANopen sub-object.
#define CO_UNSIGNED64_MIN
The minimum value of a 64-bit unsigned integer.
#define CO_DEFTYPE_INTEGER48
The data type (and object index) of a 48-bit signed integer.
const char * co_dev_get_vendor_name(const co_dev_t *dev)
Returns a pointer to the vendor name of a CANopen device.
int co_dev_set_order_code(co_dev_t *dev, const char *order_code)
Sets the order code of a CANopen device.
size_t co_sub_set_max(co_sub_t *sub, const void *ptr, size_t n)
Sets the upper limit of a value of a CANopen sub-object.
void co_dev_set_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number of a CANopen device.
int co_dev_set_vendor_name(co_dev_t *dev, const char *vendor_name)
Sets the vendor name of a CANopen device.
#define CO_OBJECT_NULL
An object with no data fields.
union co_val max
The upper limit of val.
int snprintf_c99_sdev(char *s, size_t n, const co_dev_t *dev)
Prints a C99 static initializer code fragment for a static device description (struct co_sdev) to a s...
char * name
A pointer to the name of the device.
#define CO_INTEGER24_MAX
The maximum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_DEFTYPE_TIME_OF_DAY
The data type (and object index) of a 48-bit structure representing the absolute time.
#define CO_UNSIGNED40_MAX
The maximum value of a 40-bit unsigned integer (encoded as a uint64_t).
const char * name
A pointer to the name of the object.
A union of the CANopen static data types.
unsigned baud
The supported bit rates.
const char * co_dev_get_order_code(const co_dev_t *dev)
Returns a pointer to the order code of a CANopen device.
void co_dev_set_baud(co_dev_t *dev, unsigned int baud)
Sets the supported bit rates of a CANopen device.
const char * order_code
A pointer to the order code.
#define CO_ACCESS_RW
Read or write access.
#define CO_DEFTYPE_REAL32
The data type (and object index) of a 32-bit IEEE-754 floating-point number.
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
int co_dev_set_product_name(co_dev_t *dev, const char *product_name)
Sets the product name of a CANopen device.
co_unsigned16_t type
The data type.
co_unsigned8_t nsub
The number of sub-objects in subs.
#define CO_INTEGER64_MAX
The maximum value of a 64-bit signed integer.
int co_sub_set_name(co_sub_t *sub, const char *name)
Sets the name of a CANopen sub-object.
#define CO_UNSIGNED8_MAX
The maximum value of an 8-bit unsigned integer.
union co_val min
The lower limit of val.
co_sub_t * co_sub_create(co_unsigned8_t subidx, co_unsigned16_t type)
Creates a CANopen sub-object.
#define CO_OBJ_FLAGS_UPLOAD_FILE
If a read access is performed for the object, the data is stored in a file.
#define CO_OBJ_FLAGS_DOWNLOAD_FILE
If a write access is performed for the object, the data is stored in a file.
int co_obj_set_name(co_obj_t *obj, const char *name)
Sets the name of a CANopen object.
size_t print_c99_esc(char **pbegin, char *end, char32_t c32)
Prints a UTF-8 encoded Unicode character to a memory buffer.
co_unsigned32_t revision
The revision number.
#define CO_DEFTYPE_INTEGER16
The data type (and object index) of a 16-bit signed integer.
#define CO_DEFTYPE_UNICODE_STRING
The data type (and object index) of an array of (16-bit) Unicode characters.
co_unsigned8_t co_sub_get_subidx(const co_sub_t *sub)
Returns the sub-index of a CANopen sub-object.
co_unsigned16_t idx
The object index.
#define CO_REAL64_MAX
The maximum value of a 64-bit IEEE-754 floating-point number.
#define CO_DEFTYPE_INTEGER24
The data type (and object index) of a 24-bit signed integer.
uint_least32_t pdo_mapping
A flag indicating if it is possible to map this object into a PDO.
#define CO_REAL32_MAX
The maximum value of a 32-bit IEEE-754 floating-point number.
int co_dev_get_lss(const co_dev_t *dev)
Returns 1 if LSS is supported and 0 if not.
#define CO_ACCESS_CONST
Constant value.
#define CO_INTEGER24_MIN
The minimum value of a 24-bit signed integer (encoded as an int32_t).
void co_dev_set_vendor_id(co_dev_t *dev, co_unsigned32_t vendor_id)
Sets the vendor ID of a CANopen device.
int co_dev_set_name(co_dev_t *dev, const char *name)
Sets the name of a CANopen device.
#define CO_UNSIGNED24_MIN
The minimum value of a 24-bit unsigned integer (encoded as a uint32_t).
void co_dev_set_dummy(co_dev_t *dev, co_unsigned32_t dummy)
Sets the data types supported by a CANopen device for mapping dummy entries in PDOs.
co_unsigned16_t nobj
The number of objects in objs.
co_unsigned8_t subidx
The object sub-index.
#define CO_INTEGER16_MAX
The maximum value of a 16-bit signed integer.
unsigned int co_dev_get_baud(const co_dev_t *dev)
Returns the supported bit rates of a CANopen device (any combination of CO_BAUD_1000,...
co_obj_t * co_obj_create(co_unsigned16_t idx)
Creates a CANopen object.
#define CO_INTEGER8_MAX
The maximum value of an 8-bit signed integer.
unsigned int co_sub_get_access(const co_sub_t *sub)
Returns the access type of a CANopen sub-object.
#define CO_UNSIGNED32_MAX
The maximum value of a 32-bit unsigned integer.
co_unsigned8_t co_obj_get_code(const co_obj_t *obj)
Returns the object code of a CANopen object.
int co_dev_insert_obj(co_dev_t *dev, co_obj_t *obj)
Inserts an object into the object dictionary of a CANopen device.
#define CO_DEFTYPE_UNSIGNED40
The data type (and object index) of a 40-bit unsigned integer.
#define CO_INTEGER32_MAX
The maximum value of a 32-bit signed integer.
void co_sub_destroy(co_sub_t *sub)
Destroys a CANopen sub-object.
const struct co_ssub * subs
An array of sub-objects.
#define CO_OBJECT_RECORD
A multiple data field object where the data fields may be any combination of simple variables.
co_unsigned32_t co_dev_get_product_code(const co_dev_t *dev)
Returns the product code of a CANopen device.
#define CO_DEFTYPE_UNSIGNED48
The data type (and object index) of a 48-bit unsigned integer.
co_unsigned16_t co_obj_get_idx(const co_obj_t *obj)
Returns the index of a CANopen object.
size_t co_sub_set_val(co_sub_t *sub, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.
#define CO_UNSIGNED56_MIN
The minimum value of a 56-bit unsigned integer (encoded as a uint64_t).
#define CO_UNSIGNED40_MIN
The minimum value of a 40-bit unsigned integer (encoded as a uint64_t).
int co_obj_set_code(co_obj_t *obj, co_unsigned8_t code)
Sets the code (type) of a CANopen object.
co_obj_t * co_dev_find_obj(const co_dev_t *dev, co_unsigned16_t idx)
Finds an object in the object dictionary of a CANopen device.
#define CO_UNSIGNED48_MAX
The maximum value of a 48-bit unsigned integer (encoded as a uint64_t).