23 #ifndef LELY_CO_NMT_HPP_ 24 #define LELY_CO_NMT_HPP_ 27 #error "include <lely/co/nmt.h> for the C interface" 35 inline co_unsigned32_t
36 cfgHb(CODev& dev, co_unsigned8_t
id, co_unsigned16_t ms) noexcept {
51 return __co_nmt_alloc();
54 free(
void* ptr) noexcept {
60 return __co_nmt_init(p, net, dev);
77 getNet()
const noexcept {
81 getDev()
const noexcept {
97 setCsInd(F* f) noexcept {
101 template <class C, typename c_mem_fn<co_nmt_cs_ind_t*, C>::type M>
103 setCsInd(C* obj) noexcept {
105 static_cast<void*>(obj));
120 setNgInd(F* f) noexcept {
124 template <class C, typename c_mem_fn<co_nmt_ng_ind_t*, C>::type M>
126 setNgInd(C* obj) noexcept {
128 static_cast<void*>(obj));
132 onNg(co_unsigned8_t
id,
int state,
int reason) noexcept {
148 setLgInd(F* f) noexcept {
152 template <class C, typename c_mem_fn<co_nmt_lg_ind_t*, C>::type M>
154 setLgInd(C* obj) noexcept {
156 static_cast<void*>(obj));
160 onLg(
int state) noexcept {
176 setHbInd(F* f) noexcept {
180 template <class C, typename c_mem_fn<co_nmt_hb_ind_t*, C>::type M>
182 setHbInd(C* obj) noexcept {
184 static_cast<void*>(obj));
188 onHb(co_unsigned8_t
id,
int state,
int reason) noexcept {
204 setStInd(F* f) noexcept {
208 template <class C, typename c_mem_fn<co_nmt_st_ind_t*, C>::type M>
210 setStInd(C* obj) noexcept {
212 static_cast<void*>(obj));
216 onSt(co_unsigned8_t
id, co_unsigned8_t st) noexcept {
232 setLSSReq(F* f) noexcept {
234 static_cast<void*>(f));
237 template <class C, typename c_mem_fn<co_nmt_lss_req_t*, C>::type M>
239 setLSSReq(C* obj) noexcept {
241 static_cast<void*>(obj));
256 setBootInd(F* f) noexcept {
258 static_cast<void*>(f));
261 template <class C, typename c_mem_fn<co_nmt_boot_ind_t*, C>::type M>
263 setBootInd(C* obj) noexcept {
265 static_cast<void*>(obj));
280 setCfgInd(F* f) noexcept {
282 static_cast<void*>(f));
285 template <class C, typename c_mem_fn<co_nmt_cfg_ind_t*, C>::type M>
287 setCfgInd(C* obj) noexcept {
289 static_cast<void*>(obj));
304 setDnInd(F* f) noexcept {
306 static_cast<void*>(f));
309 template <class C, typename c_mem_fn<co_nmt_sdo_ind_t*, C>::type M>
311 setDnInd(C* obj) noexcept {
313 static_cast<void*>(obj));
328 setUpInd(F* f) noexcept {
330 static_cast<void*>(f));
333 template <class C, typename c_mem_fn<co_nmt_sdo_ind_t*, C>::type M>
335 setUpInd(C* obj) noexcept {
337 static_cast<void*>(obj));
352 setSyncInd(F* f) noexcept {
354 static_cast<void*>(f));
357 template <class C, typename c_mem_fn<co_nmt_sync_ind_t*, C>::type M>
359 setSyncInd(C* obj) noexcept {
361 static_cast<void*>(obj));
365 onSync(co_unsigned8_t cs = 0) noexcept {
370 onErr(co_unsigned16_t eec, co_unsigned8_t er,
371 const uint8_t msef[5] = 0) noexcept {
376 getId()
const noexcept {
381 setId(co_unsigned8_t
id) noexcept {
386 getSt()
const noexcept {
391 isMaster()
const noexcept {
396 getTimeout()
const noexcept {
401 setTimeout(
int timeout) noexcept {
406 csReq(co_unsigned8_t cs, co_unsigned8_t
id = 0) noexcept {
416 bootReq(co_unsigned8_t
id,
int timeout) noexcept {
421 isBooting(co_unsigned8_t
id)
const noexcept {
427 void* data) noexcept {
433 cfgReq(co_unsigned8_t
id,
int timeout, F* f) noexcept {
435 static_cast<void*>(f));
438 template <class C, typename c_mem_fn<co_nmt_cfg_con_t*, C>::type M>
440 cfgReq(co_unsigned8_t
id,
int timeout, C* obj) noexcept {
442 static_cast<void*>(obj));
446 cfgRes(co_unsigned8_t
id, co_unsigned32_t ac) noexcept {
451 ngReq(co_unsigned8_t
id, co_unsigned16_t gt, co_unsigned8_t ltf) noexcept {
456 csInd(co_unsigned8_t cs) noexcept {
461 commErrInd() noexcept {
466 nodeErrInd(co_unsigned8_t
id) noexcept {
471 getRPDO(co_unsigned16_t n)
const noexcept {
476 getTPDO(co_unsigned16_t n)
const noexcept {
481 getSSDO(co_unsigned8_t n)
const noexcept {
486 getCSDO(co_unsigned8_t n)
const noexcept {
491 getSync()
const noexcept {
496 getTime()
const noexcept {
501 getEmcy()
const noexcept {
506 getLSS()
const noexcept {
516 #endif // !LELY_CO_NMT_HPP_ int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
int co_nmt_set_id(co_nmt_t *nmt, co_unsigned8_t id)
Sets the pending node-ID.
void co_nmt_get_up_ind(const co_nmt_t *nmt, co_nmt_sdo_ind_t **pind, void **pdata)
Retrieves the indication function used to notify the user of the progress of the current SDO upload r...
co_sync_t * co_nmt_get_sync(const co_nmt_t *nmt)
Returns a pointer to the SYNC producer/consumer service.
void co_nmt_on_ng(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason)
Implements the default behavior when a node guarding event occurs (see sections 7.2.8.2.2.1 and 7.2.8.3.2.1 in CiA 301 version 4.2.0).
void co_nmt_comm_err_ind(co_nmt_t *nmt)
Indicates the occurrence of a communication error and invokes the specified error behavior (object 10...
co_unsigned8_t co_nmt_get_id(const co_nmt_t *nmt)
Returns the pending node-ID.
void co_nmt_set_cfg_ind(co_nmt_t *nmt, co_nmt_cfg_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen NMT 'configuration request' process is received...
void co_nmt_get_sync_ind(const co_nmt_t *nmt, co_nmt_sync_ind_t **pind, void **pdata)
Retrieves the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/pr...
int co_nmt_boot_req(co_nmt_t *nmt, co_unsigned8_t id, int timeout)
Requests the NMT 'boot slave' process for the specified node.
void co_nmt_lss_req_t(co_nmt_t *nmt, co_lss_t *lss, void *data)
The type of a CANopen LSS request function, invoked by an NMT master before booting the slaves (see F...
co_unsigned32_t co_dev_cfg_hb(co_dev_t *dev, co_unsigned8_t id, co_unsigned16_t ms)
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer hea...
int co_nmt_cfg_req(co_nmt_t *nmt, co_unsigned8_t id, int timeout, co_nmt_cfg_con_t *con, void *data)
Issues the NMT 'configuration request' for the specified node.
void co_nmt_get_hb_ind(const co_nmt_t *nmt, co_nmt_hb_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a heartbeat event occurs.
int co_nmt_is_booting(const co_nmt_t *nmt, co_unsigned8_t id)
Returns 1 if the NMT 'boot slave' process is currently running for the specified node, and 0 if not.
void co_nmt_on_hb(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason)
Implements the default behavior when a heartbeat event occurs (see sections 7.2.8.2.2.3 and 7.2.8.3.2.2 in CiA 301 version 4.2.0).
void co_nmt_set_sync_ind(co_nmt_t *nmt, co_nmt_sync_ind_t *ind, void *data)
Sets the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/process...
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
void co_nmt_set_up_ind(co_nmt_t *nmt, co_nmt_sdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO upload reques...
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
int co_nmt_cs_ind(co_nmt_t *nmt, co_unsigned8_t cs)
Processes an NMT command from the master or the application.
int co_nmt_cfg_res(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac)
Indicates the result of the 'update configuration' step of an NMT 'request configuration' request for...
void co_nmt_set_hb_ind(co_nmt_t *nmt, co_nmt_hb_ind_t *ind, void *data)
Sets the indication function invoked when a heartbeat event occurs.
void co_nmt_set_dn_ind(co_nmt_t *nmt, co_nmt_sdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO download requ...
An opaque CANopen Client-SDO service type.
The base class for a C++ interface to an incomplete C type.
An opaque CANopen device type.
void co_nmt_set_ng_ind(co_nmt_t *nmt, co_nmt_ng_ind_t *ind, void *data)
Sets the indication function invoked when a node guarding event occurs.
An opaque CANopen LSS master/slave service type.
int co_nmt_ng_req(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t gt, co_unsigned8_t ltf)
Request the node guarding service for the specified node, even if it is not in the network list...
void co_nmt_set_lss_req(co_nmt_t *nmt, co_nmt_lss_req_t *ind, void *data)
Sets the request function invoked to perform LSS when booting an NMT master.
void co_nmt_get_cfg_ind(const co_nmt_t *nmt, co_nmt_cfg_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a CANopen NMT 'configuration request' is received...
void co_nmt_get_lg_ind(const co_nmt_t *nmt, co_nmt_lg_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a life guarding event occurs.
An opaque CANopen EMCY producer/consumer service type.
co_ssdo_t * co_nmt_get_ssdo(const co_nmt_t *nmt, co_unsigned8_t n)
Returns a pointer to a Server-SDO service.
co_time_t * co_nmt_get_time(const co_nmt_t *nmt)
Returns a pointer to the TIME producer/consumer service.
void co_nmt_st_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, void *data)
The type of a CANopen NMT state change indication function, invoked when a state change is detected b...
void co_nmt_boot_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es, void *data)
The type of a CANopen NMT 'boot slave' indication function, invoked when the 'boot slave' process com...
void co_nmt_set_st_ind(co_nmt_t *nmt, co_nmt_st_ind_t *ind, void *data)
Sets the indication function invoked when a state change is detected.
void co_nmt_get_lss_req(const co_nmt_t *nmt, co_nmt_lss_req_t **pind, void **pdata)
Retrieves the request function invoked to perform LSS when booting an NMT master. ...
void co_nmt_cs_ind_t(co_nmt_t *nmt, co_unsigned8_t cs, void *data)
The type of a CANopen NMT command indication function, invoked when an NMT command is received (and a...
void co_nmt_on_sync(co_nmt_t *nmt, co_unsigned8_t cnt)
Implements the default behavior after a SYNC object is received or transmitted.
An opaque CANopen Receive-PDO service type.
A CANopen NMT master/slave service.
co_rpdo_t * co_nmt_get_rpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Receive-PDO service.
int co_nmt_get_timeout(const co_nmt_t *nmt)
Returns the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes...
void co_nmt_sdo_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The type of an SDO request progress indication function, invoked by a CANopen NMT master to notify th...
co_csdo_t * co_nmt_get_csdo(const co_nmt_t *nmt, co_unsigned8_t n)
Returns a pointer to a Client-SDO service.
void co_nmt_get_boot_ind(const co_nmt_t *nmt, co_nmt_boot_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a CANopen NMT 'boot slave' process completes...
void co_nmt_get_ng_ind(const co_nmt_t *nmt, co_nmt_ng_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a node guarding event occurs.
can_net_t * co_nmt_get_net(const co_nmt_t *nmt)
Returns a pointer to the CAN network of an NMT master/slave service.
void co_nmt_hb_ind_t(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The type of a CANopen NMT heartbeat indication function, invoked when a heartbeat event occurs (see s...
An opaque CANopen Server-SDO service type.
void co_nmt_set_lg_ind(co_nmt_t *nmt, co_nmt_lg_ind_t *ind, void *data)
Sets the indication function invoked when a life guarding event occurs.
co_emcy_t * co_nmt_get_emcy(const co_nmt_t *nmt)
Returns a pointer to the EMCY producer/consumer service.
An opaque CANopen Transmit-PDO service type.
int co_nmt_lss_con(co_nmt_t *nmt)
Confirms the completion of the process when booting an NMT master.
co_tpdo_t * co_nmt_get_tpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Transmit-PDO service.
void co_nmt_on_lg(co_nmt_t *nmt, int state)
Implements the default behavior when a life guarding event occurs (see section 7.2.8.2.2.2 in CiA 301 version 4.2.0).
void co_nmt_cfg_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_csdo_t *sdo, void *data)
The type of a CANopen NMT 'update configuration' indication function, invoked when a configuration re...
void co_nmt_get_st_ind(const co_nmt_t *nmt, co_nmt_st_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a state change is detected.
void co_nmt_set_cs_ind(co_nmt_t *nmt, co_nmt_cs_ind_t *ind, void *data)
Sets the indication function invoked when an NMT command is received.
void co_nmt_set_boot_ind(co_nmt_t *nmt, co_nmt_boot_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen NMT 'boot slave' process completes.
int co_nmt_node_err_ind(co_nmt_t *nmt, co_unsigned8_t id)
Indicates the occurrence of an error event and triggers the error handling process (see Fig...
void co_nmt_get_dn_ind(const co_nmt_t *nmt, co_nmt_sdo_ind_t **pind, void **pdata)
Retrieves the indication function used to notify the user of the progress of the current SDO download...
void co_nmt_cfg_con_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac, void *data)
The type of a CANopen NMT 'configuration request' confirmation callback function, invoked when a conf...
An opaque CANopen NMT master/slave service type.
int co_nmt_is_master(const co_nmt_t *nmt)
Returns 1 if the specified CANopen NMT service is a master, and 0 if not.
co_unsigned8_t co_nmt_get_st(const co_nmt_t *nmt)
Returns the current state of a CANopen NMT service (one of CO_NMT_ST_BOOTUP, CO_NMT_ST_STOP, CO_NMT_ST_START, CO_NMT_ST_RESET_NODE, CO_NMT_ST_RESET_COMM or CO_NMT_ST_PREOP).
This header file is part of the CANopen library; it contains the network management (NMT) declaration...
void co_nmt_lg_ind_t(co_nmt_t *nmt, int state, void *data)
The type of a CANopen NMT life guarding indication function, invoked when a life guarding event occur...
Global namespace for the Lely Industries N.V. libraries.
An opaque CAN network interface type.
An opaque CANopen SYNC producer/consumer service type.
co_dev_t * co_nmt_get_dev(const co_nmt_t *nmt)
Returns a pointer to the CANopen device of an NMT master/slave service.
void co_nmt_on_err(co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const uint8_t msef[5])
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and ...
void co_nmt_ng_ind_t(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The type of a CANopen NMT node guarding indication function, invoked when a node guarding event occur...
void co_nmt_set_timeout(co_nmt_t *nmt, int timeout)
Sets the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes...
void co_nmt_on_st(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st)
Implements the default behavior when a state change is detected by the node guarding or heartbeat pro...
An opaque CANopen TIME producer/consumer service type.
void co_nmt_sync_ind_t(co_nmt_t *nmt, co_unsigned8_t cnt, void *data)
The type of a SYNC indication function, invoked by co_nmt_on_sync() after PDOs are transmitted/proces...
A class template supplying a uniform interface to certain attributes of C types.
void co_nmt_get_cs_ind(const co_nmt_t *nmt, co_nmt_cs_ind_t **pind, void **pdata)
Retrieves the indication function invoked when an NMT command is received.