Lely core libraries
2.2.5
|
Go to the documentation of this file.
22 #ifndef LELY_CO_DEV_HPP_
23 #define LELY_CO_DEV_HPP_
26 #error "include <lely/co/dev.h> for the C interface"
52 return __co_dev_alloc();
56 free(
void* ptr) noexcept {
61 init(
pointer p, co_unsigned8_t
id) noexcept {
62 return __co_dev_init(p,
id);
81 explicit CODev(co_unsigned8_t
id = 0xff) :
c_base(
id) {}
83 explicit CODev(
const char* filename) :
c_base(filename) {}
85 CODev(
const char* begin,
const char* end,
floc* at = 0)
86 :
c_base(begin, end, at) {}
91 getNetid()
const noexcept {
96 setNetid(co_unsigned8_t
id) noexcept {
101 getId()
const noexcept {
106 setId(co_unsigned8_t
id) noexcept {
111 getIdx(co_unsigned16_t maxidx, co_unsigned16_t* idx)
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 {
133 find(co_unsigned16_t idx)
const noexcept {
138 find(co_unsigned16_t idx, co_unsigned8_t subidx)
const 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 {
168 setVendorId(co_unsigned32_t vendor_id) noexcept {
173 getProductName()
const noexcept {
178 setProductName(
const char* product_name) noexcept {
183 getProductCode()
const noexcept {
188 setProductCode(co_unsigned32_t product_code) noexcept {
193 getRevision()
const noexcept {
198 setRevision(co_unsigned32_t revision) 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 {
228 setRate(co_unsigned16_t rate) noexcept {
233 getLSS()
const noexcept {
238 setLSS(
bool lss) noexcept {
243 getDummy()
const noexcept {
248 setDummy(co_unsigned32_t dummy) noexcept {
252 template <co_
unsigned16_t N>
254 getVal(co_unsigned16_t idx, co_unsigned8_t subidx)
const noexcept {
255 return *
reinterpret_cast<const COVal<N>*
>(
260 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
261 ::std::size_t n) noexcept {
265 template <co_
unsigned16_t N>
267 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
269 return setVal(idx, subidx, val.address(), val.size());
274 setVal(co_unsigned16_t idx, co_unsigned8_t subidx,
const T& val) noexcept {
275 return setVal<co_type_traits_T<T>::index>(idx, subidx, val);
279 readSub(co_unsigned16_t* pidx, co_unsigned8_t* psubidx,
280 const uint_least8_t* begin,
const uint_least8_t* end) noexcept {
285 writeSub(co_unsigned16_t idx, co_unsigned8_t subidx, uint_least8_t* begin,
286 uint_least8_t* end = 0)
const noexcept {
291 readDCF(co_unsigned16_t* pmin, co_unsigned16_t* pmax,
294 reinterpret_cast<void* const*
>(&val));
298 readDCF(co_unsigned16_t* pmin, co_unsigned16_t* pmax,
299 const char* filename) noexcept {
304 writeDCF(co_unsigned16_t min, co_unsigned16_t max,
310 writeDCF(co_unsigned16_t min, co_unsigned16_t max,
const char* filename)
const
327 setTPDOEventInd(F* f) noexcept {
329 static_cast<void*
>(f));
332 template <class C, typename c_mem_fn<co_dev_tpdo_event_ind_t*, C>::type M>
334 setTPDOEventInd(C* obj) noexcept {
336 static_cast<void*
>(obj));
340 TPDOEvent(co_unsigned16_t idx, co_unsigned8_t subidx) noexcept {
350 #endif // !LELY_CO_DEV_HPP_
int co_dev_remove_obj(co_dev_t *dev, co_obj_t *obj)
Removes an object from the object dictionary a CANopen device.
The base class for a C++ interface to an incomplete C type.
An opaque CANopen object type.
A CANopen value containing an arbitrary large block of data.
co_unsigned32_t co_dev_get_vendor_id(const co_dev_t *dev)
Returns the vendor ID 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).
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_rate(co_dev_t *dev, co_unsigned16_t rate)
Sets the (pending) baudrate 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...
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.
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_product_code(co_dev_t *dev, co_unsigned32_t product_code)
Sets 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_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_set_lss(co_dev_t *dev, int lss)
Sets the LSS support flag.
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.
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 ...
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...
co_unsigned8_t co_dev_get_netid(const co_dev_t *dev)
Returns the network-ID 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.
A class template supplying a uniform interface to certain attributes of C types.
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_order_code(co_dev_t *dev, const char *order_code)
Sets the order code 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...
void co_dev_set_revision(co_dev_t *dev, co_unsigned32_t revision)
Sets the revision number 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 char * co_dev_get_order_code(const co_dev_t *dev)
Returns a pointer to the order code 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.
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_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_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,...
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...
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.
int co_dev_set_name(co_dev_t *dev, const char *name)
Sets the 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.
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,...
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,...
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.
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...
int co_dev_set_id(co_dev_t *dev, co_unsigned8_t id)
Sets the node-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.
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_unsigned32_t co_dev_get_product_code(const co_dev_t *dev)
Returns the product code of a CANopen device.
An opaque CANopen device type.
An opaque CANopen sub-object type.
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.