23 #ifndef LELY_CO_NMT_HPP_
24 #define LELY_CO_NMT_HPP_
26 #if !defined(__cplusplus) || LELY_NO_CXX
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();
55 free(
void* ptr) noexcept {
61 return __co_nmt_init(p, net, dev);
78 getNet()
const noexcept {
83 getDev()
const noexcept {
99 setCsInd(F* f) noexcept {
103 template <class C, typename c_mem_fn<co_nmt_cs_ind_t*, C>::type M>
105 setCsInd(C* obj) noexcept {
107 static_cast<void*
>(obj));
122 setNgInd(F* f) noexcept {
126 template <class C, typename c_mem_fn<co_nmt_ng_ind_t*, C>::type M>
128 setNgInd(C* obj) noexcept {
130 static_cast<void*
>(obj));
134 onNg(co_unsigned8_t
id,
int state,
int reason) noexcept {
150 setLgInd(F* f) noexcept {
154 template <class C, typename c_mem_fn<co_nmt_lg_ind_t*, C>::type M>
156 setLgInd(C* obj) noexcept {
158 static_cast<void*
>(obj));
162 onLg(
int state) noexcept {
178 setHbInd(F* f) noexcept {
182 template <class C, typename c_mem_fn<co_nmt_hb_ind_t*, C>::type M>
184 setHbInd(C* obj) noexcept {
186 static_cast<void*
>(obj));
190 onHb(co_unsigned8_t
id,
int state,
int reason) noexcept {
206 setStInd(F* f) noexcept {
210 template <class C, typename c_mem_fn<co_nmt_st_ind_t*, C>::type M>
212 setStInd(C* obj) noexcept {
214 static_cast<void*
>(obj));
218 onSt(co_unsigned8_t
id, co_unsigned8_t st) noexcept {
234 setLSSReq(F* f) noexcept {
236 static_cast<void*
>(f));
239 template <class C, typename c_mem_fn<co_nmt_lss_req_t*, C>::type M>
241 setLSSReq(C* obj) noexcept {
243 static_cast<void*
>(obj));
258 setBootInd(F* f) noexcept {
260 static_cast<void*
>(f));
263 template <class C, typename c_mem_fn<co_nmt_boot_ind_t*, C>::type M>
265 setBootInd(C* obj) noexcept {
267 static_cast<void*
>(obj));
282 setCfgInd(F* f) noexcept {
284 static_cast<void*
>(f));
287 template <class C, typename c_mem_fn<co_nmt_cfg_ind_t*, C>::type M>
289 setCfgInd(C* obj) noexcept {
291 static_cast<void*
>(obj));
306 setDnInd(F* f) noexcept {
308 static_cast<void*
>(f));
311 template <class C, typename c_mem_fn<co_nmt_sdo_ind_t*, C>::type M>
313 setDnInd(C* obj) noexcept {
315 static_cast<void*
>(obj));
330 setUpInd(F* f) noexcept {
332 static_cast<void*
>(f));
335 template <class C, typename c_mem_fn<co_nmt_sdo_ind_t*, C>::type M>
337 setUpInd(C* obj) noexcept {
339 static_cast<void*
>(obj));
354 setSyncInd(F* f) noexcept {
356 static_cast<void*
>(f));
359 template <class C, typename c_mem_fn<co_nmt_sync_ind_t*, C>::type M>
361 setSyncInd(C* obj) noexcept {
363 static_cast<void*
>(obj));
367 onSync(co_unsigned8_t cs = 0) noexcept {
372 onErr(co_unsigned16_t eec, co_unsigned8_t er,
373 const co_unsigned8_t msef[5] = 0) noexcept {
378 onTPDOEvent(co_unsigned16_t n = 0) noexcept {
383 onTPDOEventLock() noexcept {
388 onTPDOEventUnlock() noexcept {
393 getId()
const noexcept {
398 setId(co_unsigned8_t
id) noexcept {
403 getSt()
const noexcept {
408 isMaster()
const noexcept {
413 getTimeout()
const noexcept {
418 setTimeout(
int timeout) noexcept {
423 csReq(co_unsigned8_t cs, co_unsigned8_t
id = 0) noexcept {
433 bootReq(co_unsigned8_t
id,
int timeout) noexcept {
438 isBooting(co_unsigned8_t
id)
const noexcept {
444 void* data) noexcept {
450 cfgReq(co_unsigned8_t
id,
int timeout, F* f) noexcept {
452 static_cast<void*
>(f));
455 template <class C, typename c_mem_fn<co_nmt_cfg_con_t*, C>::type M>
457 cfgReq(co_unsigned8_t
id,
int timeout, C* obj) noexcept {
459 static_cast<void*
>(obj));
463 cfgRes(co_unsigned8_t
id, co_unsigned32_t ac) noexcept {
468 ngReq(co_unsigned8_t
id, co_unsigned16_t gt, co_unsigned8_t ltf) noexcept {
473 csInd(co_unsigned8_t cs) noexcept {
478 commErrInd() noexcept {
483 nodeErrInd(co_unsigned8_t
id) noexcept {
488 getRPDO(co_unsigned16_t n)
const noexcept {
493 getTPDO(co_unsigned16_t n)
const noexcept {
498 getSSDO(co_unsigned8_t n)
const noexcept {
503 getCSDO(co_unsigned8_t n)
const noexcept {
508 getSync()
const noexcept {
513 getTime()
const noexcept {
518 getEmcy()
const noexcept {
523 getLSS()
const noexcept {
An opaque CAN network interface type.
An opaque CANopen Client-SDO service type.
An opaque CANopen device type.
An opaque CANopen EMCY producer/consumer service type.
An opaque CANopen LSS master/slave service type.
An opaque CANopen NMT master/slave service type.
An opaque CANopen Receive-PDO service type.
An opaque CANopen Server-SDO service type.
An opaque CANopen SYNC producer/consumer service type.
An opaque CANopen Transmit-PDO service type.
An opaque CANopen TIME producer/consumer service type.
The base class for a C++ interface to an incomplete C type.
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
This header file is part of the CANopen library; it contains the network management (NMT) declaration...
co_tpdo_t * co_nmt_get_tpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Transmit-PDO service.
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_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...
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...
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...
int co_nmt_cs_ind(co_nmt_t *nmt, co_unsigned8_t cs)
Processes an NMT command from the master or the application.
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.
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.
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...
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...
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_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_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.
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_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...
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....
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...
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...
co_ssdo_t * co_nmt_get_ssdo(const co_nmt_t *nmt, co_unsigned8_t n)
Returns a pointer to a Server-SDO service.
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_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_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.
void co_nmt_on_tpdo_event(co_nmt_t *nmt, co_unsigned16_t n)
Implements the default behavior when an event is indicated for an event-driven (asynchronous) Transmi...
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_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.
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_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...
co_rpdo_t * co_nmt_get_rpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Receive-PDO service.
void co_nmt_on_tpdo_event_lock(co_nmt_t *nmt)
Postpones the transmission of PDOs triggered by co_nmt_on_tpdo_event() until a matching call to co_nm...
void co_nmt_on_err(co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and ...
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_on_tpdo_event_unlock(co_nmt_t *nmt)
Undoes the effect of a single call to co_nmt_on_tpdo_event_lock() and possibly triggers the transmiss...
co_unsigned8_t co_nmt_get_id(const co_nmt_t *nmt)
Returns the pending node-ID.
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.
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_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,...
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_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....
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.
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_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_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...
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_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...
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_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_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,...
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_timeout(co_nmt_t *nmt, int timeout)
Sets the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
co_sync_t * co_nmt_get_sync(const co_nmt_t *nmt)
Returns a pointer to the SYNC producer/consumer service.
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.
co_emcy_t * co_nmt_get_emcy(const co_nmt_t *nmt)
Returns a pointer to the EMCY producer/consumer service.
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.
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...
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.
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
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...
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...
int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
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.
int co_nmt_set_id(co_nmt_t *nmt, co_unsigned8_t id)
Sets the pending node-ID.
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....
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.
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.
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.
int co_nmt_lss_con(co_nmt_t *nmt)
Confirms the completion of the process when booting an NMT master.
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...
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...
co_time_t * co_nmt_get_time(const co_nmt_t *nmt)
Returns a pointer to the TIME producer/consumer service.
A CANopen NMT master/slave service.
A class template supplying a uniform interface to certain attributes of C types.