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 99 void *__co_dev_alloc(
void);
100 void __co_dev_free(
void *ptr);
102 void __co_dev_fini(
struct __co_dev *dev);
163 co_unsigned16_t *idx);
213 co_unsigned8_t subidx);
391 co_unsigned8_t subidx);
410 const void *ptr,
size_t n);
412 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \ 413 co_##b##_t co_dev_get_val_##c(const co_dev_t *dev, \ 414 co_unsigned16_t idx, co_unsigned8_t subidx); \ 415 size_t co_dev_set_val_##c(co_dev_t *dev, co_unsigned16_t idx, \ 416 co_unsigned8_t subidx, co_##b##_t c); 417 #include <lely/co/def/basic.def> 418 #undef LELY_CO_DEFINE_TYPE 437 co_unsigned8_t *psubidx,
const uint_least8_t *begin,
438 const uint_least8_t *end);
459 co_unsigned8_t subidx, uint_least8_t *begin,
500 co_unsigned16_t *pmax,
const char *filename);
518 co_unsigned16_t max,
void **ptr);
535 co_unsigned16_t max,
const char *filename);
583 co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx);
589 #endif // !LELY_CO_DEV_H_ int lss
A flag specifying whether LSS is supported (1) or not (0).
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_rate(co_dev_t *dev, co_unsigned16_t rate)
Sets the (pending) baudrate of a CANopen device.
co_unsigned8_t n
Highest sub-index supported.
co_unsigned32_t co_dev_get_product_code(const co_dev_t *dev)
Returns the product code of a CANopen device.
void co_dev_set_product_code(co_dev_t *dev, co_unsigned32_t product_code)
Sets the product code of a CANopen device.
char * order_code
A pointer to the order code.
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.
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, and writes them to a file, in the concise DCF format.
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...
co_unsigned32_t co_dev_get_revision(const co_dev_t *dev)
Returns the revision number of a CANopen device.
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...
unsigned baud
The supported bit rates.
const char * co_dev_get_name(const co_dev_t *dev)
Returns the name of a CANopen device.
char * name
A pointer to the name of the 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 ...
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.
void co_dev_set_lss(co_dev_t *dev, int lss)
Sets the LSS support flag.
co_unsigned8_t co_dev_get_netid(const co_dev_t *dev)
Returns the network-ID of a CANopen device.
co_unsigned32_t product_code
Product code.
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
const char * co_dev_get_product_name(const co_dev_t *dev)
Returns a pointer to the product name of a CANopen device.
co_unsigned32_t vendor_id
Vendor-ID.
void co_dev_set_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number 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...
char * product_name
A pointer to the product name.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef.h> and defines any missing functionality.
int co_dev_set_product_name(co_dev_t *dev, const char *product_name)
Sets the product name of a CANopen device.
co_unsigned32_t dummy
The data types supported for mapping dummy entries in PDOs.
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...
void co_dev_set_baud(co_dev_t *dev, unsigned int baud)
Sets the supported bit rates of a CANopen device.
co_unsigned32_t revision
Revision number.
const char * co_dev_get_vendor_name(const co_dev_t *dev)
Returns a pointer to the vendor name 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_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, and writes them to a memory buffer, in the concise DCF format.
int co_dev_set_name(co_dev_t *dev, const char *name)
Sets the name 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_unsigned32_t serial_nr
Serial number.
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.
const char * co_dev_get_order_code(const co_dev_t *dev)
Returns a pointer to the order code of a CANopen device.
char * vendor_name
A pointer to the vendor name.
int co_dev_set_order_code(co_dev_t *dev, const char *order_code)
Sets the order code 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.
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_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_dummy(co_dev_t *dev, co_unsigned32_t dummy)
Sets the data types supported by a CANopen device for mapping dummy entries in PDOs.
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_BAUD_800, CO_BAUD_500, CO_BAUD_250, CO_BAUD_125, CO_BAUD_50, CO_BAUD_20, CO_BAUD_10 and CO_BAUD_AUTO).
void co_dev_destroy(co_dev_t *dev)
Destroys a CANopen device, including all objects in its object dictionary.
int co_dev_get_lss(const co_dev_t *dev)
Returns 1 if LSS is supported and 0 if not.
int co_dev_set_id(co_dev_t *dev, co_unsigned8_t id)
Sets the node-ID 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 ...
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...
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, and stores them in the object dictionary of a CANopen device.
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_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_unsigned16_t rate
The (pending) baudrate (in kbit/s).
int co_dev_remove_obj(co_dev_t *dev, co_obj_t *obj)
Removes an object from the object dictionary a CANopen device.
This header file is part of the CANopen library; it contains the CANopen type definitions.
co_unsigned16_t co_dev_get_rate(const co_dev_t *dev)
Returns the (pending) baudrate of a CANopen device (in kbit/s).
co_unsigned32_t co_dev_get_vendor_id(const co_dev_t *dev)
Returns the vendor ID of a CANopen device.
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...