22#ifndef LELY_CO_DEV_HPP_
23#define LELY_CO_DEV_HPP_
25#if !defined(__cplusplus) || LELY_NO_CXX
26#error "include <lely/co/dev.h> for the C interface"
52 return __co_dev_alloc();
56 free(
void* ptr)
noexcept {
62 return __co_dev_init(p,
id);
83 explicit CODev(
const char* filename) :
c_base(filename) {}
85 CODev(
const char* begin,
const char* end,
floc*
at = 0)
91 getNetid()
const noexcept {
101 getId()
const noexcept {
115 ::std::vector<co_unsigned16_t>
117 std::vector<co_unsigned16_t> idx(getIdx(0, 0));
118 getIdx(idx.size(), idx.data());
123 insert(
COObj* obj)
noexcept {
128 remove(
COObj* obj)
noexcept {
143 getName()
const noexcept {
148 setName(
const char* name)
noexcept {
153 getVendorName()
const noexcept {
158 setVendorName(
const char* vendor_name)
noexcept {
163 getVendorId()
const noexcept {
173 getProductName()
const noexcept {
178 setProductName(
const char* product_name)
noexcept {
183 getProductCode()
const noexcept {
193 getRevision()
const noexcept {
203 getOrderCode()
const noexcept {
208 setOrderCode(
const char* order_code)
noexcept {
213 getBaud()
const noexcept {
218 setBaud(
unsigned int baud)
noexcept {
223 getRate()
const noexcept {
233 getLSS()
const noexcept {
238 setLSS(
bool lss)
noexcept {
243 getDummy()
const noexcept {
252 template <co_
unsigned16_t N>
255 return *
reinterpret_cast<const COVal<N>*
>(
261 ::std::size_t n)
noexcept {
265 template <co_
unsigned16_t N>
269 return setVal(idx, subidx, val.address(), val.size());
294 reinterpret_cast<void*
const*
>(&val));
299 const char* filename)
noexcept {
311 const char* filename)
const noexcept {
327 setTPDOEventInd(
F* f)
noexcept {
329 static_cast<void*
>(f));
334 setTPDOEventInd(
C* obj)
noexcept {
336 static_cast<void*
>(obj));
This header file is part of the utilities library; it contains the C callback wrapper declarations.
This header file is part of the utilities library; it contains the C to C++ interface declarations.
An opaque CANopen device type.
An opaque CANopen object type.
An opaque CANopen sub-object type.
The base class for a C++ interface to an incomplete C type.
This header file is part of the CANopen library; it contains the device description declarations.
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_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.
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.
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.
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.
const char * co_dev_get_product_name(const co_dev_t *dev)
Returns a pointer to the product 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_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.
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_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number of a CANopen device.
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_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,...
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.
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_name(const co_dev_t *dev)
Returns the 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_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.
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.
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_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...
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.
A location in a text file.
A class template supplying a uniform interface to certain attributes of C types.
This header file is part of the CANopen library; it contains the C++ interface of the CANopen value d...