22 #ifndef LELY_CO_DEV_H_
23 #define LELY_CO_DEV_H_
30 #define CO_DEFSTRUCT_ID 0x0023
53 #define CO_NUM_NETWORKS 127
56 #define CO_NUM_NODES 127
59 #define CO_BAUD_1000 0x0001
62 #define CO_BAUD_800 0x0002
65 #define CO_BAUD_500 0x0004
68 #define CO_BAUD_250 0x0008
71 #define CO_BAUD_125 0x0020
74 #define CO_BAUD_50 0x0040
77 #define CO_BAUD_20 0x0080
80 #define CO_BAUD_10 0x0100
83 #define CO_BAUD_AUTO 0x0200
110 co_unsigned16_t idx, co_unsigned8_t subidx,
void *data);
113 void *__co_dev_alloc(
void);
114 void __co_dev_free(
void *ptr);
118 void __co_dev_fini(
struct __co_dev *dev);
184 co_unsigned16_t *idx);
234 co_unsigned8_t subidx);
258 #if !LELY_NO_CO_OBJ_NAME
298 #if !LELY_NO_CO_OBJ_NAME
331 #if !LELY_NO_CO_OBJ_NAME
424 co_unsigned8_t subidx);
443 const void *ptr,
size_t n);
445 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
446 co_##b##_t co_dev_get_val_##c(const co_dev_t *dev, \
447 co_unsigned16_t idx, co_unsigned8_t subidx); \
448 size_t co_dev_set_val_##c(co_dev_t *dev, co_unsigned16_t idx, \
449 co_unsigned8_t subidx, co_##b##_t c);
450 #include <lely/co/def/basic.def>
451 #undef LELY_CO_DEFINE_TYPE
470 co_unsigned8_t *psubidx,
const uint_least8_t *begin,
471 const uint_least8_t *end);
493 co_unsigned8_t subidx, uint_least8_t *begin,
534 co_unsigned16_t *pmax,
const char *filename);
552 co_unsigned16_t max,
void **ptr);
569 co_unsigned16_t max,
const char *filename);
617 co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx);
662 co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx);
void co_dev_sam_mpdo_event(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Checks if the specified sub-object in the object dictionary of a CANopen device can be mapped into a ...
void co_dev_get_tpdo_event_ind(const co_dev_t *dev, co_dev_tpdo_event_ind_t **pind, void **pdata)
Retrieves the indication function invoked by co_dev_tpdo_event() when an event is indicated for (a su...
co_sub_t * co_dev_find_sub(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Finds a sub-object in the object dictionary of a CANopen device.
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.
co_dev_t * co_dev_create(co_unsigned8_t id)
Creates a new CANopen device.
int co_dev_read_dcf(co_dev_t *dev, co_unsigned16_t *pmin, co_unsigned16_t *pmax, void *const *ptr)
Reads the values of a range of objects from a memory buffer, in the concise DCF format,...
size_t co_dev_read_sub(co_dev_t *dev, co_unsigned16_t *pidx, co_unsigned8_t *psubidx, const uint_least8_t *begin, const uint_least8_t *end)
Reads a value from a memory buffer, in the concise DCF format, and stores it in a sub-object in the o...
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID 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.
const void * co_dev_get_val(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Returns a pointer to the current value of a CANopen sub-object.
void co_dev_get_sam_mpdo_event_ind(const co_dev_t *dev, co_dev_sam_mpdo_event_ind_t **pind, void **pdata)
Retrieves the indication function invoked by co_dev_sam_mpdo_event() when an event is indicated for (...
void co_dev_set_product_code(co_dev_t *dev, co_unsigned32_t product_code)
Sets the product code of a CANopen device.
void co_dev_tpdo_event_ind_t(co_unsigned16_t num, void *data)
The type of a CANopen Transmit-PDO event indication function, invoked by co_dev_tpdo_event() when an ...
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.
int co_dev_insert_obj(co_dev_t *dev, co_obj_t *obj)
Inserts an object into the object dictionary of a CANopen device.
void co_dev_set_vendor_id(co_dev_t *dev, co_unsigned32_t vendor_id)
Sets the vendor ID of a CANopen device.
const char * co_dev_get_name(const co_dev_t *dev)
Returns the name of a CANopen device.
int co_dev_set_id(co_dev_t *dev, co_unsigned8_t id)
Sets the node-ID of a CANopen device.
int co_dev_set_netid(co_dev_t *dev, co_unsigned8_t id)
Sets the network-ID of a CANopen device.
void co_dev_set_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number of a CANopen device.
co_unsigned16_t co_dev_get_rate(const co_dev_t *dev)
Returns the (pending) baudrate of a CANopen device (in kbit/s).
int co_dev_write_dcf(const co_dev_t *dev, co_unsigned16_t min, co_unsigned16_t max, void **ptr)
Loads the values of a range of objects in the object dictionary of a CANopen device,...
co_obj_t * co_dev_first_obj(const co_dev_t *dev)
Finds the first object (with the lowest index) in the object dictionary of a CANopen device.
int co_dev_remove_obj(co_dev_t *dev, co_obj_t *obj)
Removes an object from the object dictionary a CANopen device.
int co_dev_get_lss(const co_dev_t *dev)
Returns 1 if LSS is supported and 0 if not.
void co_dev_set_sam_mpdo_event_ind(co_dev_t *dev, co_dev_sam_mpdo_event_ind_t *ind, void *data)
Sets the indication function invoked by co_dev_sam_mpdo_event() when an event is indicated for (a sub...
co_obj_t * co_dev_last_obj(const co_dev_t *dev)
Finds the last object (with the highest index) in the object dictionary of a CANopen device.
co_unsigned8_t co_dev_get_netid(const co_dev_t *dev)
Returns the network-ID of a CANopen device.
co_unsigned32_t co_dev_get_vendor_id(const co_dev_t *dev)
Returns the vendor ID of a CANopen device.
void co_dev_set_lss(co_dev_t *dev, int lss)
Sets the LSS support flag.
int co_dev_set_order_code(co_dev_t *dev, const char *order_code)
Sets the order code of a CANopen 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_dev_get_product_name(const co_dev_t *dev)
Returns a pointer to the product name of a CANopen device.
int co_dev_write_dcf_file(const co_dev_t *dev, co_unsigned16_t min, co_unsigned16_t max, const char *filename)
Loads the values of a range of objects in the object dictionary of a CANopen device,...
void co_dev_destroy(co_dev_t *dev)
Destroys a CANopen device, including all objects in its object dictionary.
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.
void co_dev_tpdo_event(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Checks if the specified sub-object in the object dictionary of a CANopen device can be mapped into a ...
void co_dev_set_rate(co_dev_t *dev, co_unsigned16_t rate)
Sets the (pending) baudrate of a CANopen device.
void co_dev_sam_mpdo_event_ind_t(co_unsigned16_t num, co_unsigned16_t idx, co_unsigned8_t subidx, void *data)
The type of a CANopen source address mode multiplex PDO event indication function,...
size_t co_dev_set_val(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.
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_unsigned32_t co_dev_get_product_code(const co_dev_t *dev)
Returns the product code of a CANopen device.
int co_dev_set_product_name(co_dev_t *dev, const char *product_name)
Sets the product name 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.
void co_dev_set_tpdo_event_ind(co_dev_t *dev, co_dev_tpdo_event_ind_t *ind, void *data)
Sets the indication function invoked by co_dev_tpdo_event() when an event is indicated for (a sub-obj...
int co_dev_read_dcf_file(co_dev_t *dev, co_unsigned16_t *pmin, co_unsigned16_t *pmax, const char *filename)
Reads the values of a range of objects from a file, in the concise DCF format, and stores them in the...
const char * co_dev_get_vendor_name(const co_dev_t *dev)
Returns a pointer to the vendor name of a CANopen device.
size_t co_dev_write_sub(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, uint_least8_t *begin, uint_least8_t *end)
Loads the value of a sub-object from the object dictionary of a CANopen device, and writes it to a me...
const char * co_dev_get_order_code(const co_dev_t *dev)
Returns a pointer to the order code of a CANopen device.
int co_dev_set_name(co_dev_t *dev, const char *name)
Sets the name of a CANopen device.
co_unsigned32_t co_dev_get_revision(const co_dev_t *dev)
Returns the revision number of a CANopen device.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
co_unsigned32_t product_code
The product code.
char * product_name
A pointer to the product name.
co_unsigned16_t rate
The (pending) baudrate (in kbit/s).
char * vendor_name
A pointer to the vendor name.
char * order_code
A pointer to the order code.
unsigned baud
The supported bit rates.
int lss
A flag specifying whether LSS is supported (1) or not (0).
co_unsigned32_t vendor_id
The vendor ID.
co_unsigned32_t revision
The revision number.
co_unsigned32_t dummy
The data types supported for mapping dummy entries in PDOs.
char * name
A pointer to the name of the device.
co_unsigned32_t product_code
Product code.
co_unsigned32_t revision
Revision number.
co_unsigned8_t n
Highest sub-index supported.
co_unsigned32_t vendor_id
Vendor-ID.
co_unsigned32_t serial_nr
Serial number.
This header file is part of the CANopen library; it contains the CANopen type definitions.