22 #ifndef LELY_CO_DEV_HPP_ 23 #define LELY_CO_DEV_HPP_ 26 #error "include <lely/co/dev.h> for the C interface" 51 return __co_dev_alloc();
54 free(
void* ptr) noexcept {
59 init(
pointer p, co_unsigned8_t
id) noexcept {
60 return __co_dev_init(p,
id);
80 explicit CODev(co_unsigned8_t
id = 0xff) :
c_base(
id) {}
82 explicit CODev(
const char* filename) :
c_base(filename) {}
84 CODev(
const char* begin,
const char* end,
floc* at = 0)
85 :
c_base(begin, end, at) {}
90 getNetid()
const noexcept {
95 setNetid(co_unsigned8_t
id) noexcept {
100 getId()
const noexcept {
105 setId(co_unsigned8_t
id) noexcept {
110 getIdx(co_unsigned16_t maxidx, co_unsigned16_t* idx)
const noexcept {
114 ::std::vector<co_unsigned16_t>
116 std::vector<co_unsigned16_t> idx(getIdx(0, 0));
117 getIdx(idx.size(), idx.data());
122 insert(
COObj* obj) noexcept {
126 remove(
COObj* obj) noexcept {
131 find(co_unsigned16_t idx)
const noexcept {
136 find(co_unsigned16_t idx, co_unsigned8_t subidx)
const noexcept {
141 getName()
const noexcept {
146 setName(
const char* name) noexcept {
151 getVendorName()
const noexcept {
156 setVendorName(
const char* vendor_name) noexcept {
161 getVendorId()
const noexcept {
166 setVendorId(co_unsigned32_t vendor_id) noexcept {
171 getProductName()
const noexcept {
176 setProductName(
const char* product_name) noexcept {
181 getProductCode()
const noexcept {
186 setProductCode(co_unsigned32_t product_code) noexcept {
191 getRevision()
const noexcept {
196 setRevision(co_unsigned32_t revision) noexcept {
201 getOrderCode()
const noexcept {
206 setOrderCode(
const char* order_code) noexcept {
211 getBaud()
const noexcept {
216 setBaud(
unsigned int baud) noexcept {
221 getRate()
const noexcept {
226 setRate(co_unsigned16_t rate) noexcept {
231 getLSS()
const noexcept {
236 setLSS(
bool lss) noexcept {
241 getDummy()
const noexcept {
246 setDummy(co_unsigned32_t dummy) noexcept {
250 template <co_
unsigned16_t N>
252 getVal(co_unsigned16_t idx, co_unsigned8_t subidx)
const noexcept {
253 return *
reinterpret_cast<const COVal<N>*
>(
258 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
259 ::std::size_t n) noexcept {
263 template <co_
unsigned16_t N>
265 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
267 return setVal(idx, subidx, val.address(), val.size());
272 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
const T& val) noexcept {
273 return setVal<co_type_traits_T<T>::index>(idx, subidx, val);
277 readSub(co_unsigned16_t* pidx, co_unsigned8_t* psubidx,
const uint8_t* begin,
278 const uint8_t* end) noexcept {
283 writeSub(co_unsigned16_t idx, co_unsigned8_t subidx, uint8_t* begin,
284 uint8_t* end = 0)
const noexcept {
289 readDCF(co_unsigned16_t* pmin, co_unsigned16_t* pmax,
292 reinterpret_cast<void* const*>(&val));
296 readDCF(co_unsigned16_t* pmin, co_unsigned16_t* pmax,
297 const char* filename) noexcept {
302 writeDCF(co_unsigned16_t min, co_unsigned16_t max,
308 writeDCF(co_unsigned16_t min, co_unsigned16_t max,
const char* filename)
const 319 #endif // !LELY_CO_DEV_HPP_ void co_dev_set_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number of a CANopen device.
void co_dev_set_lss(co_dev_t *dev, int lss)
Sets the LSS support flag.
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_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.
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...
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.
A location in a text file.
int co_dev_remove_obj(co_dev_t *dev, co_obj_t *obj)
Removes an object from the object dictionary a CANopen device.
const char * co_dev_get_name(const co_dev_t *dev)
Returns the name of a CANopen device.
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
The base class for a C++ interface to an incomplete C type.
An opaque CANopen device type.
size_t co_dev_read_sub(co_dev_t *dev, co_unsigned16_t *pidx, co_unsigned8_t *psubidx, const uint8_t *begin, const uint8_t *end)
Reads a value from a memory buffer, in the concise DCF format, and stores it in a sub-object in the o...
void co_dev_set_product_code(co_dev_t *dev, co_unsigned32_t product_code)
Sets the product 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.
co_unsigned32_t co_dev_get_vendor_id(const co_dev_t *dev)
Returns the vendor ID of a CANopen device.
This header file is part of the CANopen library; it contains the C++ interface of the CANopen value d...
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.
An opaque CANopen object type.
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.
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_set_netid(co_dev_t *dev, co_unsigned8_t id)
Sets the network-ID of a CANopen device.
This header file is part of the utilities library; it contains the C to C++ interface declarations...
An opaque CANopen sub-object type.
int co_dev_insert_obj(co_dev_t *dev, co_obj_t *obj)
Inserts an object into 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.
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_revision(const co_dev_t *dev)
Returns the revision number of a CANopen device.
size_t co_dev_write_sub(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, uint8_t *begin, uint8_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_rate(co_dev_t *dev, co_unsigned16_t rate)
Sets the (pending) baudrate of a CANopen device.
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).
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.
This header file is part of the CANopen library; it contains the device description declarations...
const char * co_dev_get_order_code(const co_dev_t *dev)
Returns a pointer to the order code of a CANopen device.
A CANopen value containing an arbitrary large block of data.
const char * co_dev_get_vendor_name(const co_dev_t *dev)
Returns a pointer to the vendor name 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.
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_set_id(co_dev_t *dev, co_unsigned8_t id)
Sets the node-ID 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.
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.
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...
Global namespace for the Lely Industries N.V. libraries.
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.
int co_dev_set_name(co_dev_t *dev, const char *name)
Sets the name of 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_vendor_id(co_dev_t *dev, co_unsigned32_t vendor_id)
Sets the vendor ID 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_unsigned32_t co_dev_get_product_code(const co_dev_t *dev)
Returns the product code of a CANopen device.
A class template supplying a uniform interface to certain attributes of C types.