Lely core libraries  2.3.4
sdev.h
Go to the documentation of this file.
1 
22 #ifndef LELY_CO_SDEV_H_
23 #define LELY_CO_SDEV_H_
24 
25 #include <lely/co/dev.h>
26 #include <lely/co/obj.h>
27 #include <lely/co/val.h>
28 
30 struct co_sdev {
32  co_unsigned8_t id;
34  const char *name;
36  const char *vendor_name;
38  co_unsigned32_t vendor_id;
40  const char *product_name;
42  co_unsigned32_t product_code;
44  co_unsigned32_t revision;
46  const char *order_code;
48  unsigned baud : 10;
50  co_unsigned16_t rate;
52  int lss;
54  co_unsigned32_t dummy;
56  co_unsigned16_t nobj;
58  const struct co_sobj *objs;
59 };
60 
62 struct co_sobj {
63 #if !LELY_NO_CO_OBJ_NAME
64  const char *name;
66 #endif
67  co_unsigned16_t idx;
70  co_unsigned8_t code;
72  co_unsigned8_t nsub;
74  const struct co_ssub *subs;
75 };
76 
78 struct co_ssub {
79 #if !LELY_NO_CO_OBJ_NAME
80  const char *name;
82 #endif
83  co_unsigned8_t subidx;
86  co_unsigned16_t type;
87 #if !LELY_NO_CO_OBJ_LIMITS
88  union co_val min;
91  union co_val max;
92 #endif
93 #if !LELY_NO_CO_OBJ_DEFAULT
94  union co_val def;
96 #endif
97  union co_val val;
100  uint_least32_t access : 5;
102  uint_least32_t pdo_mapping : 1;
104  uint_least32_t flags : 26;
105 };
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
111 struct __co_dev *__co_dev_init_from_sdev(
112  struct __co_dev *dev, const struct co_sdev *sdev);
113 
120 co_dev_t *co_dev_create_from_sdev(const struct co_sdev *sdev);
121 
137 int snprintf_c99_sdev(char *s, size_t n, const co_dev_t *dev);
138 
152 int asprintf_c99_sdev(char **ps, const co_dev_t *dev);
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif // !LELY_CO_SDEV_H_
co_ssub::def
union co_val def
The default value of val.
Definition: sdev.h:95
co_sdev::vendor_name
const char * vendor_name
A pointer to the vendor name.
Definition: sdev.h:36
co_sdev::product_code
co_unsigned32_t product_code
The product code.
Definition: sdev.h:42
dev.h
co_ssub::val
union co_val val
The sub-object value.
Definition: sdev.h:98
val.h
co_ssub
A static CANopen sub-object.
Definition: sdev.h:78
co_ssub::name
const char * name
A pointer to the name of the sub-object.
Definition: sdev.h:81
co_ssub::flags
uint_least32_t flags
The object flags.
Definition: sdev.h:104
co_sdev::dummy
co_unsigned32_t dummy
The data types supported for mapping dummy entries in PDOs.
Definition: sdev.h:54
co_sdev::objs
const struct co_sobj * objs
An array of objects.
Definition: sdev.h:58
co_sdev::lss
int lss
A flag specifying whether LSS is supported (1) or not (0).
Definition: sdev.h:52
co_sdev::name
const char * name
A pointer to the name of the device.
Definition: sdev.h:34
co_sobj::code
co_unsigned8_t code
The object code.
Definition: sdev.h:70
co_sdev::product_name
const char * product_name
A pointer to the product name.
Definition: sdev.h:40
co_sdev::vendor_id
co_unsigned32_t vendor_id
The vendor ID.
Definition: sdev.h:38
co_sdev::rate
co_unsigned16_t rate
The (pending) baudrate (in kbit/s).
Definition: sdev.h:50
co_sdev::id
co_unsigned8_t id
The node-ID.
Definition: sdev.h:32
co_ssub::access
uint_least32_t access
The access type.
Definition: sdev.h:100
co_sdev
A static CANopen device.
Definition: sdev.h:30
co_ssub::max
union co_val max
The upper limit of val.
Definition: sdev.h:91
co_sobj::name
const char * name
A pointer to the name of the object.
Definition: sdev.h:65
co_val
A union of the CANopen static data types.
Definition: val.h:273
co_sdev::baud
unsigned baud
The supported bit rates.
Definition: sdev.h:48
snprintf_c99_sdev
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...
Definition: sdev.c:116
co_sdev::order_code
const char * order_code
A pointer to the order code.
Definition: sdev.h:46
asprintf_c99_sdev
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,...
Definition: sdev.c:414
co_ssub::type
co_unsigned16_t type
The data type.
Definition: sdev.h:86
__co_dev
A CANopen device.
Definition: dev.h:30
co_sobj::nsub
co_unsigned8_t nsub
The number of sub-objects in subs.
Definition: sdev.h:72
co_ssub::min
union co_val min
The lower limit of val.
Definition: sdev.h:89
co_sdev::revision
co_unsigned32_t revision
The revision number.
Definition: sdev.h:44
co_sobj::idx
co_unsigned16_t idx
The object index.
Definition: sdev.h:68
co_ssub::pdo_mapping
uint_least32_t pdo_mapping
A flag indicating if it is possible to map this object into a PDO.
Definition: sdev.h:102
obj.h
co_sobj
A static CANopen object.
Definition: sdev.h:62
co_sdev::nobj
co_unsigned16_t nobj
The number of objects in objs.
Definition: sdev.h:56
co_ssub::subidx
co_unsigned8_t subidx
The object sub-index.
Definition: sdev.h:84
co_sobj::subs
const struct co_ssub * subs
An array of sub-objects.
Definition: sdev.h:74
co_dev_create_from_sdev
co_dev_t * co_dev_create_from_sdev(const struct co_sdev *sdev)
Creates a CANopen device from a static device description.
Definition: sdev.c:89