Lely core libraries  2.2.5
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 #ifndef LELY_NO_CO_OBJ_NAME
65  const char *name;
66 #endif
68  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 #ifndef LELY_NO_CO_OBJ_NAME
81  const char *name;
82 #endif
84  co_unsigned8_t subidx;
86  co_unsigned16_t type;
87 #ifndef LELY_NO_CO_OBJ_LIMITS
89  union co_val min;
91  union co_val max;
92 #endif
93 #ifndef LELY_NO_CO_OBJ_DEFAULT
95  union co_val def;
96 #endif
98  union co_val val;
100  unsigned long access : 5;
102  unsigned long pdo_mapping : 1;
104  unsigned long 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_
This header file is part of the CANopen library; it contains the device description declarations.
This header file is part of the CANopen library; it contains the object dictionary declarations.
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:108
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:406
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:83
A CANopen device.
Definition: dev.c:41
A static CANopen device.
Definition: sdev.h:30
co_unsigned8_t id
The node-ID.
Definition: sdev.h:32
co_unsigned16_t nobj
The number of objects in objs.
Definition: sdev.h:56
int lss
A flag specifying whether LSS is supported (1) or not (0).
Definition: sdev.h:52
const char * product_name
A pointer to the product name.
Definition: sdev.h:40
const char * vendor_name
A pointer to the vendor name.
Definition: sdev.h:36
co_unsigned32_t dummy
The data types supported for mapping dummy entries in PDOs.
Definition: sdev.h:54
co_unsigned16_t rate
The (pending) baudrate (in kbit/s).
Definition: sdev.h:50
unsigned baud
The supported bit rates.
Definition: sdev.h:48
co_unsigned32_t product_code
The product code.
Definition: sdev.h:42
co_unsigned32_t vendor_id
The vendor ID.
Definition: sdev.h:38
const char * name
A pointer to the name of the device.
Definition: sdev.h:34
const char * order_code
A pointer to the order code.
Definition: sdev.h:46
co_unsigned32_t revision
The revision number.
Definition: sdev.h:44
const struct co_sobj * objs
An array of objects.
Definition: sdev.h:58
A static CANopen object.
Definition: sdev.h:62
const struct co_ssub * subs
An array of sub-objects.
Definition: sdev.h:74
const char * name
A pointer to the name of the object.
Definition: sdev.h:65
co_unsigned16_t idx
The object index.
Definition: sdev.h:68
co_unsigned8_t nsub
The number of sub-objects in subs.
Definition: sdev.h:72
co_unsigned8_t code
The object code.
Definition: sdev.h:70
A static CANopen sub-object.
Definition: sdev.h:78
unsigned long pdo_mapping
A flag indicating if it is possible to map this object into a PDO.
Definition: sdev.h:102
union co_val min
The lower limit of val.
Definition: sdev.h:89
union co_val def
The default value of val.
Definition: sdev.h:95
unsigned long access
The access type.
Definition: sdev.h:100
co_unsigned8_t subidx
The object sub-index.
Definition: sdev.h:84
const char * name
A pointer to the name of the sub-object.
Definition: sdev.h:81
union co_val val
The sub-object value.
Definition: sdev.h:98
unsigned long flags
The object flags.
Definition: sdev.h:104
co_unsigned16_t type
The data type.
Definition: sdev.h:86
union co_val max
The upper limit of val.
Definition: sdev.h:91
A union of the CANopen static data types.
Definition: val.h:163
This header file is part of the CANopen library; it contains the CANopen value declarations.