26 #ifndef LELY_NO_CO_MASTER
32 #ifndef LELY_NO_CO_EMCY
37 #ifndef LELY_NO_CO_RPDO
41 #ifndef LELY_NO_CO_TPDO
45 #ifndef LELY_NO_CO_MASTER
59 #ifndef LELY_NO_CO_MASTER
111 #ifndef LELY_NO_CO_DCF_RESTORE
123 #ifndef LELY_NO_CO_MASTER
135 #ifndef LELY_NO_CO_MASTER
174 #ifndef LELY_NO_CO_MASTER
181 #ifndef LELY_NO_CO_LSS
220 #ifndef LELY_NO_CO_TPDO
269 #ifndef LELY_NO_CO_MASTER
289 #ifndef LELY_NO_CO_MASTER
312 #ifndef LELY_NO_CO_MASTER
324 #ifndef LELY_NO_CO_MASTER
342 #ifndef LELY_NO_CO_MASTER
345 int reason,
void *data);
353 int reason,
void *data);
359 #ifndef LELY_NO_CO_MASTER
363 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *data);
367 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *data);
371 #ifndef LELY_CO_CO_TPDO
393 #ifndef LELY_NO_CO_MASTER
404 co_nmt_t *
nmt, co_unsigned8_t
id, co_unsigned8_t st,
char es);
423 #ifndef LELY_NO_CO_MASTER
437 co_unsigned8_t st,
char es);
443 #define LELY_CO_DEFINE_STATE(name, ...) \
444 static co_nmt_state_t *const name = &(co_nmt_state_t){ __VA_ARGS__ };
446 #ifndef LELY_NO_CO_MASTER
449 co_nmt_t *nmt, co_unsigned8_t
id, co_unsigned8_t st,
char es);
513 #ifndef LELY_NO_CO_MASTER
519 co_nmt_t *nmt, co_unsigned8_t
id, co_unsigned8_t st,
char es);
524 #ifdef LELY_NO_CO_MASTER
546 #ifdef LELY_NO_CO_MASTER
568 #ifdef LELY_NO_CO_MASTER
582 #undef LELY_CO_DEFINE_STATE
587 #ifndef LELY_NO_CO_MASTER
627 #ifndef LELY_NO_CO_MASTER
631 co_nmt_t *nmt, co_unsigned8_t
id, co_unsigned16_t *pms);
650 #define CO_NMT_PREOP_SRV \
651 (CO_NMT_STOP_SRV | CO_NMT_SRV_SDO | CO_NMT_SRV_SYNC | CO_NMT_SRV_TIME \
655 #define CO_NMT_START_SRV (CO_NMT_PREOP_SRV | CO_NMT_SRV_PDO)
658 #define CO_NMT_STOP_SRV CO_NMT_SRV_LSS
669 co_unsigned8_t n = co_obj_get_val_u8(obj_1016, 0x00);
670 co_unsigned8_t i = 0;
674 for (i = 1; i <= n; i++) {
675 co_unsigned32_t val_i = co_obj_get_val_u32(obj_1016, i);
676 co_unsigned8_t id_i = (val_i >> 16) & 0xff;
684 for (i = 1; i <= n; i++) {
685 co_unsigned32_t val_i = co_obj_get_val_u32(obj_1016, i);
686 co_unsigned8_t id_i = (val_i >> 16) & 0xff;
698 co_unsigned32_t val = ((co_unsigned32_t)
id << 16) | ms;
706 case 'A':
return "The CANopen device is not listed in object 1F81.";
708 return "No response received for upload request of object 1000.";
710 return "Value of object 1000 from CANopen device is different to value in object 1F84 (Device type).";
712 return "Value of object 1018 sub-index 01 from CANopen device is different to value in object 1F85 (Vendor-ID).";
714 return "Heartbeat event. No heartbeat message received from CANopen device.";
716 return "Node guarding event. No confirmation for guarding request received from CANopen device.";
718 return "Objects for program download are not configured or inconsistent.";
720 return "Software update is required, but not allowed because of configuration or current status.";
722 return "Software update is required, but program download failed.";
723 case 'J':
return "Configuration download failed.";
725 return "Heartbeat event during start error control service. No heartbeat message received from CANopen device during start error control service.";
726 case 'L':
return "NMT slave was initially operational.";
728 return "Value of object 1018 sub-index 02 from CANopen device is different to value in object 1F86 (Product code).";
730 return "Value of object 1018 sub-index 03 from CANopen device is different to value in object 1F87 (Revision number).";
732 return "Value of object 1018 sub-index 04 from CANopen device is different to value in object 1F88 (Serial number).";
733 default:
return "Unknown error status";
740 void *ptr = malloc(
sizeof(
struct __co_nmt));
747 __co_nmt_free(
void *ptr)
766 #ifndef LELY_NO_CO_DCF_RESTORE
770 goto error_write_dcf_node;
777 goto error_write_dcf_comm;
785 #ifndef LELY_NO_CO_MASTER
793 goto error_create_recv_000;
802 #ifndef LELY_NO_CO_MASTER
827 #ifndef LELY_NO_CO_MASTER
832 #ifndef LELY_NO_CO_LSS
878 #ifndef LELY_NO_CO_TPDO
880 for (
int i = 0; i < 512 /
LONG_BIT; i++)
907 #ifndef LELY_NO_CO_MASTER
920 #ifndef LELY_NO_CO_MASTER
952 error_create_recv_000:
955 error_write_dcf_comm:
956 #ifndef LELY_NO_CO_DCF_RESTORE
958 error_write_dcf_node:
969 #ifndef LELY_NO_CO_MASTER
981 #ifndef LELY_NO_CO_MASTER
1011 #ifndef LELY_NO_CO_TPDO
1016 #ifndef LELY_NO_CO_MASTER
1027 #ifndef LELY_NO_CO_MASTER
1037 #ifndef LELY_NO_CO_DCF_RESTORE
1050 goto error_alloc_nmt;
1053 if (!__co_nmt_init(
nmt, net, dev)) {
1055 goto error_init_nmt;
1112 #ifndef LELY_NO_CO_MASTER
1207 #ifndef LELY_NO_CO_MASTER
1245 #ifdef LELY_NO_CO_MASTER
1257 #ifndef LELY_NO_CO_MASTER
1259 #ifndef LELY_NO_CO_LSS
1394 #ifndef LELY_NO_CO_TPDO
1395 for (co_unsigned16_t i = 0; i <
nmt->
srv.
ntpdo; i++) {
1400 #ifndef LELY_NO_CO_RPDO
1401 for (co_unsigned16_t i = 0; i <
nmt->
srv.
nrpdo; i++) {
1413 const co_unsigned8_t msef[5])
1418 #ifdef LELY_NO_CO_EMCY
1427 if ((eec & 0xff00) == 0x8100)
1432 #ifndef LELY_NO_CO_TPDO
1484 for (
int i = 0; i < 512 /
LONG_BIT; i++) {
1486 co_unsigned16_t n = i *
LONG_BIT + 1;
1539 #ifdef LELY_NO_CO_MASTER
1550 #ifndef LELY_NO_CO_MASTER
1595 trace(
"NMT: sending command specifier %d to node %d", cs,
id);
1614 #ifndef LELY_NO_CO_LSS
1654 trace(
"NMT: booting slave %d",
id);
1659 goto error_create_boot;
1667 goto error_boot_req;
1724 trace(
"NMT: starting update configuration process for node %d",
id);
1729 goto error_create_cfg;
1801 if (!slave->
timer) {
1832 trace(
"NMT: received command specifier %d", cs);
1845 switch (co_dev_get_val_u8(
nmt->
dev, 0x1029, 0x01)) {
1854 #ifndef LELY_NO_CO_MASTER
1877 mandatory ?
"mandatory" :
"optional",
id);
1884 }
else if (mandatory && (
nmt->
startup & 0x10)) {
1974 #ifndef LELY_NO_CO_MASTER
1990 if (!slave->
est && (!
es ||
es ==
'L'))
1999 co_unsigned16_t ms = 0;
2023 if (!
es ||
es ==
'L') {
2031 co_unsigned16_t
gt = (slave->
assignment >> 16) & 0xffff;
2035 "unable to guard node %02X",
2040 trace(
"NMT: slave %d finished booting with error status %c",
id,
2075 co_unsigned16_t ms = 0;
2081 trace(
"NMT: update configuration process completed for slave %d",
id);
2104 static co_unsigned32_t
2113 co_unsigned32_t ac = 0;
2126 co_unsigned16_t gt = val.u16;
2127 co_unsigned16_t gt_old = co_sub_get_val_u16(sub);
2144 static co_unsigned32_t
2153 co_unsigned32_t ac = 0;
2166 co_unsigned8_t ltf = val.u8;
2167 co_unsigned8_t ltf_old = co_sub_get_val_u8(sub);
2184 static co_unsigned32_t
2193 co_unsigned32_t ac = 0;
2205 if (subidx > nmt->
nhb) {
2211 if (val.u32 == co_sub_get_val_u32(sub))
2214 co_unsigned8_t
id = (val.u32 >> 16) & 0xff;
2215 co_unsigned16_t ms = val.u32 & 0xffff;
2225 co_unsigned32_t val_i = co_obj_get_val_u32(obj_1016, i);
2226 co_unsigned8_t id_i = (val_i >> 16) & 0xff;
2227 co_unsigned16_t ms_i = val_i & 0xffff;
2230 if (id_i ==
id && ms_i) {
2235 #ifndef LELY_NO_CO_MASTER
2254 static co_unsigned32_t
2263 co_unsigned32_t ac = 0;
2276 co_unsigned16_t ms = val.u16;
2277 co_unsigned16_t ms_old = co_sub_get_val_u16(sub);
2294 #ifndef LELY_NO_CO_MASTER
2295 static co_unsigned32_t
2304 co_unsigned32_t ac = 0;
2318 co_unsigned8_t
id = subidx == 0x80 ? 0 : subidx;
2327 if (!nmt->
master || val.u32 != UINT32_C(0x666e6f63)) {
2379 static co_unsigned32_t
2387 co_unsigned32_t ac = 0;
2400 co_unsigned32_t startup = val.u32;
2401 co_unsigned32_t startup_old = co_sub_get_val_u32(sub);
2402 if (startup == startup_old)
2406 if ((startup ^ startup_old) != 0x5f) {
2417 #ifndef LELY_NO_CO_MASTER
2418 static co_unsigned32_t
2427 co_unsigned32_t ac = 0;
2441 co_unsigned8_t
id = subidx == 0x80 ? 0 : subidx;
2483 #ifndef LELY_NO_CO_MASTER
2491 co_unsigned8_t cs = msg->
data[0];
2492 co_unsigned8_t
id = msg->
data[1];
2507 assert(msg->
id > 0x700 && msg->
id <= 0x77f);
2512 assert(nmt->
gt && nmt->
ltf);
2529 #ifndef LELY_NO_CO_MASTER
2534 co_unsigned8_t
id = (msg->
id - 0x700) & 0x7f;
2541 co_unsigned8_t st = msg->
data[0];
2554 if (slave->
boot || slave->
cfg)
2558 if (!slave->
gt || !slave->
ltf)
2569 if (slave->
rtr >= slave->
ltf) {
2571 "NMT: node guarding time out resolved for node %d",
2583 "NMT: node guarding state change occurred for node %d",
2591 "NMT: node guarding state change resolved for node %d",
2599 if (st != slave->
rst)
2607 #ifndef LELY_NO_CO_MASTER
2614 assert(slave->
gt && slave->
ltf);
2619 co_unsigned8_t
id = slave -
nmt->
slaves + 1;
2632 if (slave->
rtr <= slave->
ltf && ++slave->
rtr == slave->
ltf) {
2634 "NMT: node guarding time out occurred for node %d",
2660 }
else if (nmt->
gt && nmt->
ltf) {
2670 #ifndef LELY_NO_CO_MASTER
2679 co_unsigned16_t inhibit = co_dev_get_val_u16(nmt->
dev, 0x102a, 0x00);
2696 struct timespec now = { 0, 0 };
2702 assert(msg.
len == 2);
2714 co_unsigned8_t st = 0;
2715 switch (msg.
data[0]) {
2720 co_unsigned8_t
id = msg.
data[1];
2750 #ifndef LELY_NO_CO_MASTER
2764 #ifndef LELY_NO_CO_MASTER
2800 #ifndef LELY_NO_CO_MASTER
2804 size_t size,
size_t nbyte,
void *
data)
2816 size_t size,
size_t nbyte,
void *
data)
2828 #ifndef LELY_CO_CO_TPDO
2865 #ifndef LELY_NO_CO_MASTER
2879 co_nmt_t *nmt, co_unsigned8_t
id, co_unsigned8_t st,
char es)
2898 default:
return NULL;
2907 diag(
DIAG_INFO, 0,
"NMT: entering reset application state");
2909 #ifndef LELY_NO_CO_MASTER
2927 #ifndef LELY_NO_CO_DCF_RESTORE
2931 "unable to reset application parameters");
2948 diag(
DIAG_INFO, 0,
"NMT: entering reset communication state");
2950 #ifndef LELY_NO_CO_MASTER
2971 "unable to reset communication parameters");
2980 "unable to store communication parameters");
2984 nmt->
startup = co_dev_get_val_u32(nmt->
dev, 0x1f80, 0x00);
2985 #ifndef LELY_NO_CO_MASTER
3006 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
3026 default:
return NULL;
3061 default:
return NULL;
3072 #ifndef LELY_NO_CO_MASTER
3100 default:
return NULL;
3104 #ifndef LELY_NO_CO_MASTER
3107 co_nmt_t *nmt, co_unsigned8_t
id, co_unsigned8_t st,
char es)
3120 int wait = nmt->
halt;
3121 for (co_unsigned8_t
id = 1; !wait &&
id <=
CO_NUM_NODES;
id++)
3125 trace(
"NMT: all mandatory slaves started successfully");
3139 #ifndef LELY_NO_CO_TPDO
3141 for (
int i = 0; i < 512 /
LONG_BIT; i++)
3151 #ifndef LELY_NO_CO_MASTER
3158 for (co_unsigned8_t
id = 1; boot &&
id <=
CO_NUM_NODES;
id++) {
3172 for (co_unsigned8_t
id = 1;
id <=
CO_NUM_NODES;
id++) {
3184 && (!slave->
es || slave->
es ==
'L')
3208 default:
return NULL;
3241 default:
return NULL;
3250 #ifndef LELY_NO_CO_MASTER
3257 #ifndef LELY_NO_CO_MASTER
3269 for (co_unsigned8_t
id = 1; !keep &&
id <=
CO_NUM_NODES;
id++)
3276 for (co_unsigned8_t
id = 1;
id <=
CO_NUM_NODES;
id++) {
3297 trace(
"NMT: waiting for mandatory slaves to start");
3319 nmt->
gt = co_dev_get_val_u16(
nmt->
dev, 0x100c, 0x00);
3321 nmt->
ms = co_dev_get_val_u16(
nmt->
dev, 0x1017, 0x00);
3327 nmt->
ms ?
"heartbeat production"
3353 #ifndef LELY_NO_CO_MASTER
3375 if (
nmt->
ms || lt) {
3386 struct timespec interval = { ms / 1000, (ms % 1000) * 1000000 };
3419 nmt->
nhb = co_obj_get_val_u8(obj_1016, 0x00);
3420 nmt->
hbs = calloc(nmt->
nhb,
sizeof(*nmt->
hbs));
3421 if (!nmt->
hbs && nmt->
nhb) {
3425 "unable to create heartbeat consumers");
3429 for (co_unsigned8_t i = 0; i < nmt->
nhb; i++) {
3433 "unable to create heartbeat consumer 0x%02X",
3434 (co_unsigned8_t)(i + 1));
3438 co_unsigned32_t val = co_obj_get_val_u32(obj_1016, i + 1);
3439 co_unsigned8_t
id = (val >> 16) & 0xff;
3440 co_unsigned16_t ms = val & 0xffff;
3451 for (
size_t i = 0; i < nmt->
nhb; i++)
3458 #ifndef LELY_NO_CO_MASTER
3470 for (co_unsigned8_t i = 0; i < nmt->
nhb; i++) {
3471 co_unsigned32_t val = co_obj_get_val_u32(obj_1016, i + 1);
3472 if (
id == ((val >> 16) & 0xff)) {
3474 *pms = val & 0xffff;
3489 for (co_unsigned8_t
id = 1;
id <=
CO_NUM_NODES;
id++) {
3494 "unable to create CAN frame receiver");
3506 co_unsigned8_t n = co_obj_get_val_u8(obj_1f81, 0x00);
3516 for (co_unsigned8_t
id = 1;
id <=
CO_NUM_NODES;
id++) {
3522 slave->
timer = NULL;
3552 for (co_unsigned8_t
id = 1;
id <=
CO_NUM_NODES;
id++) {
3557 int mandatory = !!(slave->
assignment & 0x08);
3559 if (!res && mandatory)
3563 if (!mandatory && !(slave->
assignment & 0x10))
This header file is part of the CAN library; it contains the CAN frame buffer declarations.
size_t can_buf_reserve(struct can_buf *buf, size_t n)
Resizes a CAN frame buffer, if necessary, to make room for at least n additional frames.
#define CAN_BUF_INIT
The static initializer for struct can_buf.
size_t can_buf_read(struct can_buf *buf, struct can_msg *ptr, size_t n)
Reads, and removes, frames from a CAN frame buffer.
size_t can_buf_peek(struct can_buf *buf, struct can_msg *ptr, size_t n)
Reads, but does not remove, frames from a CAN frame buffer.
void can_buf_fini(struct can_buf *buf)
Finalizes a CAN frame buffer.
size_t can_buf_write(struct can_buf *buf, const struct can_msg *ptr, size_t n)
Writes frames to a CAN frame buffer.
@ CAN_FLAG_RTR
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames).
#define CAN_MSG_INIT
The static initializer for can_msg.
This header file is part of the CANopen library; it contains the device description declarations.
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.
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_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID 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_id(co_dev_t *dev, co_unsigned8_t id)
Sets the node-ID of a CANopen device.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
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,...
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.
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...
This header file is part of the CANopen library; it contains the Client-SDO declarations.
co_unsigned8_t co_csdo_get_num(const co_csdo_t *sdo)
Returns the SDO number of a Client-SDO.
This header file is part of the utilities library; it contains the diagnostic declarations.
@ DIAG_INFO
An informational message.
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
This header file is part of the CANopen library; it contains the emergency (EMCY) object declarations...
int co_emcy_push(co_emcy_t *emcy, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Pushes a CANopen EMCY message to the stack and broadcasts it if the EMCY producer service is active.
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
@ ERRNUM_PERM
Operation not permitted.
@ ERRNUM_INVAL
Invalid argument.
@ ERRNUM_INPROGRESS
Operation in progress.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
#define LONG_BIT
The number of bits in a long.
This header file is part of the CANopen library; it contains the object dictionary declarations.
co_unsigned8_t co_sub_get_subidx(const co_sub_t *sub)
Returns the sub-index of a CANopen sub-object.
co_unsigned16_t co_obj_get_idx(const co_obj_t *obj)
Returns the index of a CANopen object.
co_unsigned32_t co_sub_dn_ind_val(co_sub_t *sub, co_unsigned16_t type, const void *val)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
int co_sub_dn(co_sub_t *sub, void *val)
Downloads (moves) a value into a CANopen sub-object if the refuse-write-on-download flag (CO_OBJ_FLAG...
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
void co_obj_set_dn_ind(co_obj_t *obj, co_sub_dn_ind_t *ind, void *data)
Sets the download indication function for a CANopen object.
co_obj_t * co_sub_get_obj(const co_sub_t *sub)
Returns the a pointer to the CANopen object containing the specified sub-object.
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
int co_sdo_req_dn_val(struct co_sdo_req *req, co_unsigned16_t type, void *val, co_unsigned32_t *pac)
Copies the next segment of the specified CANopen SDO download request to the internal buffer and,...
#define CO_SDO_AC_PARAM
SDO abort code: General parameter incompatibility reason.
#define CO_SDO_AC_DATA_DEV
SDO abort code: Data cannot be transferred or stored to the application because of the present device...
#define CO_SDO_AC_NO_OBJ
SDO abort code: Object does not exist in the object dictionary.
#define CO_SDO_AC_NO_DATA
SDO abort code: No data available.
#define CO_SDO_AC_NO_SUB
SDO abort code: Sub-index does not exist.
#define CO_SDO_AC_DATA_CTL
SDO abort code: Data cannot be transferred or stored to the application because of local control.
#define CO_SDO_AC_PARAM_VAL
SDO abort code: Invalid value for parameter (download only).
#define CO_SDO_AC_NO_WRITE
SDO abort code: Attempt to write a read only object.
#define MIN(a, b)
Returns the minimum of a and b.
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
int can_net_send(can_net_t *net, const struct can_msg *msg)
Sends a CAN frame from a network interface.
void can_timer_start(can_timer_t *timer, can_net_t *net, const struct timespec *start, const struct timespec *interval)
Starts a CAN timer and registers it with a network interface.
void can_net_get_time(const can_net_t *net, struct timespec *tp)
Retrieves the current time of a CAN network interface.
void can_timer_set_func(can_timer_t *timer, can_timer_func_t *func, void *data)
Sets the callback function invoked when a CAN timer is triggered.
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface.
void can_recv_set_func(can_recv_t *recv, can_recv_func_t *func, void *data)
Sets the callback function used to process CAN frames with a receiver.
void can_recv_destroy(can_recv_t *recv)
Destroys a CAN frame receiver.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
void can_timer_timeout(can_timer_t *timer, can_net_t *net, int timeout)
Starts a CAN timer and registers it with a network interface.
void can_recv_start(can_recv_t *recv, can_net_t *net, uint_least32_t id, uint_least8_t flags)
Registers a CAN frame receiver with a network interface and starts processing frames.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
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_destroy(co_nmt_t *nmt)
Destroys a CANopen NMT master/slave service.
static int co_nmt_ec_timer(const struct timespec *tp, void *data)
The CAN timer callback function for life guarding or heartbeat production.
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...
co_nmt_t * co_nmt_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen NMT master/slave service.
static co_nmt_state_t *const co_nmt_reset_node_state
The NMT 'reset application' state.
static int co_nmt_ec_update(co_nmt_t *nmt)
Updates and (de)activates the life guarding or heartbeat production services.
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.
static void co_nmt_ec_fini(co_nmt_t *nmt)
Finalizes the error control services.
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...
static co_unsigned32_t co_1f80_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for (all sub-objects of) CANopen object 1F80 (NMT startup).
static co_unsigned32_t co_100d_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for CANopen object 100D (Life time factor).
static co_nmt_state_t * co_nmt_start_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'operational' state.
static void co_nmt_dn_ind(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The SDO download progress indication function.
static co_nmt_state_t *const co_nmt_start_state
The NMT 'operational' state.
static void co_nmt_emit_cs(co_nmt_t *nmt, co_unsigned8_t cs)
Invokes the 'NMT command received' transition function of the current state of an NMT master/slave se...
static co_nmt_state_t *const co_nmt_preop_state
The NMT 'pre-operational' state.
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.
#define CO_NMT_START_SRV
The services enabled in the NMT 'operational' state.
static int co_nmt_ng_timer(const struct timespec *tp, void *data)
The CAN timer callback function for node guarding.
static co_unsigned32_t co_1f25_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for (all sub-objects of) CANopen object 1F25 (Configuration request)...
static void default_st_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, void *data)
The default state change event handler.
static co_nmt_state_t * co_nmt_bootup_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'boot-up' state.
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.
static int co_nmt_cs_timer(const struct timespec *tp, void *data)
The CAN timer callback function for sending buffered NMT messages.
void co_nmt_cfg_ind(co_nmt_t *nmt, co_unsigned8_t id, co_csdo_t *sdo)
The CANopen NMT 'update configuration' indication function, invoked when a configuration request is r...
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.
#define CO_NMT_STOP_SRV
The services enabled in the NMT 'stopped' state.
static co_nmt_state_t *const co_nmt_stop_state
The NMT 'stopped' state.
static co_nmt_state_t * co_nmt_reset_comm_on_enter(co_nmt_t *nmt)
The entry function of the 'reset communication' state.
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...
static void co_nmt_hb_fini(co_nmt_t *nmt)
Finalizes the heartbeat consumer services.
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...
static co_unsigned32_t co_1017_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for CANopen object 1017 (Producer heartbeat time).
static co_nmt_state_t * co_nmt_preop_on_enter(co_nmt_t *nmt)
The entry function of the 'pre-operational' state.
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_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.
static co_nmt_state_t * co_nmt_default_on_boot(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
The default 'boot slave completed' transition function.
static co_nmt_state_t *const co_nmt_init_state
The 'initializing' state.
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.
static int co_nmt_slaves_boot(co_nmt_t *nmt)
Starts the NMT 'boot slave' processes.
static co_nmt_hb_t * co_nmt_hb_find(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t *pms)
Find the heartbeat consumer for the specified node.
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...
static co_nmt_state_t * co_nmt_startup_slave(co_nmt_t *nmt)
The NMT slave startup procedure.
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.
static co_nmt_state_t * co_nmt_bootup_on_enter(co_nmt_t *nmt)
The entry function of the 'boot-up' state.
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.
static void co_nmt_slaves_init(co_nmt_t *nmt)
Initializes NMT slave management.
void co_nmt_cfg_con(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac)
The CANopen NMT 'configuration request' confirmation function, invoked when a configuration request c...
static void co_nmt_up_ind(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The SDO upload progress indication function.
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,...
static int co_nmt_recv_700(const struct can_msg *msg, void *data)
The CAN receive callback function for NMT error control (node guarding RTR) messages.
static int co_nmt_ec_send_res(co_nmt_t *nmt, co_unsigned8_t st)
Sends an NMT error control response message.
static co_nmt_state_t * co_nmt_start_on_enter(co_nmt_t *nmt)
The entry function of the 'operational' state.
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....
static void default_lg_ind(co_nmt_t *nmt, int state, void *data)
The default life guarding event handler.
static void co_nmt_hb_init(co_nmt_t *nmt)
Initializes the heartbeat consumer services.
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.
static int co_nmt_recv_000(const struct can_msg *msg, void *data)
The CAN receive callback function for NMT messages.
static void co_nmt_tpdo_event_ind(co_unsigned16_t n, void *data)
The Transmit-PDO event indication function.
#define CO_NMT_PREOP_SRV
The services enabled in the NMT 'pre-operational' state.
static co_nmt_state_t * co_nmt_startup(co_nmt_t *nmt)
The NMT startup procedure (see Fig. 1 & 2 in CiA 302-2 version 4.1.0).
static void co_nmt_emit_boot(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
Invokes the 'boot slave completed' transition function of the current state of an NMT master service.
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_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,...
static co_nmt_state_t * co_nmt_reset_node_on_enter(co_nmt_t *nmt)
The entry function of the 'reset application' state.
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...
static co_nmt_state_t *const co_nmt_bootup_state
The NMT 'boot-up' state.
static co_nmt_state_t * co_nmt_init_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'initializing' state.
static co_nmt_state_t * co_nmt_preop_on_boot(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
The 'boot slave completed' transition function of the 'pre-operational' state.
static co_nmt_state_t * co_nmt_preop_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'pre-operational' state.
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.
static void default_ng_ind(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The default node guarding event handler.
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.
static co_nmt_state_t * co_nmt_reset_comm_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'reset communication' state.
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.
static co_nmt_state_t * co_nmt_startup_master(co_nmt_t *nmt)
The NMT master startup procedure.
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....
const char * co_nmt_es2str(char es)
Returns a pointer to a string describing an NMT boot error status.
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.
static co_nmt_state_t * co_nmt_stop_on_cs(co_nmt_t *nmt, co_unsigned8_t cs)
The 'NMT command received' transition function of the 'stopped' state.
static void co_nmt_st_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st)
The indication function for state change events.
static void co_nmt_enter(co_nmt_t *nmt, co_nmt_state_t *next)
Enters the specified state of an NMT master/slave service and invokes the exit and entry functions.
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_boot_con(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
The CANopen NMT 'boot slave' confirmation function, invoked when the 'boot slave' process completes.
int co_nmt_lss_con(co_nmt_t *nmt)
Confirms the completion of the process when booting an NMT master.
static void co_nmt_ec_init(co_nmt_t *nmt)
Initializes the error control services.
void co_nmt_hb_ind(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, co_unsigned8_t st)
The CANopen NMT heartbeat indication function, invoked when a heartbeat event occurs.
static co_unsigned32_t co_100c_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for CANopen object 100C (Guard time).
static co_unsigned32_t co_1016_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for CANopen object 1016 (Consumer heartbeat time).
static co_unsigned32_t co_1f82_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for (all sub-objects of) CANopen object 1F80 (Request NMT).
static void co_nmt_slaves_fini(co_nmt_t *nmt)
Finalizes NMT slave management.
static co_nmt_state_t * co_nmt_stop_on_enter(co_nmt_t *nmt)
The entry function of the 'stopped' state.
co_time_t * co_nmt_get_time(const co_nmt_t *nmt)
Returns a pointer to the TIME producer/consumer service.
static co_nmt_state_t *const co_nmt_reset_comm_state
The NMT 'reset communication' state.
static void default_hb_ind(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The default heartbeat event handler.
This header file is part of the CANopen library; it contains the network management (NMT) declaration...
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...
#define CO_NMT_ST_BOOTUP
The NMT state 'boot-up'.
#define CO_NMT_CS_START
The NMT command specifier 'start'.
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...
#define CO_NMT_ST_PREOP
The NMT state 'pre-operational'.
#define CO_NMT_EC_CANID(id)
The CAN identifier used for both node guarding and heartbeat monitoring.
#define CO_NMT_CS_ENTER_PREOP
The NMT command specifier 'enter pre-operational'.
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...
#define CO_NMT_CS_RESET_NODE
The NMT command specifier 'reset node'.
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...
#define LELY_CO_NMT_TIMEOUT
The default SDO timeout (in milliseconds) for the NMT 'boot slave' and 'check configuration' processe...
#define CO_NMT_CS_STOP
The NMT command specifier 'stop'.
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...
@ CO_NMT_EC_STATE
An NMT error control state change event.
@ CO_NMT_EC_TIMEOUT
An NMT error control timeout event.
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...
#define CO_NMT_ST_START
The NMT state 'operational'.
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...
#define CO_NMT_ST_RESET_NODE
The NMT sub-state 'reset application'.
#define CO_NMT_ST_TOGGLE
The mask to get/set the toggle bit from an NMT state.
#define CO_NMT_CS_CANID
The CAN identifier used for NMT commands.
#define CO_NMT_ST_RESET_COMM
The NMT sub-state 'reset communication'.
@ CO_NMT_EC_OCCURRED
An NMT error control event occurred.
@ CO_NMT_EC_RESOLVED
An NMT error control event was resolved.
#define CO_NMT_ST_STOP
The NMT state 'stopped'.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
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...
void co_nmt_boot_destroy(co_nmt_boot_t *boot)
Destroys a CANopen NMT 'boot slave' service.
co_nmt_boot_t * co_nmt_boot_create(can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
Creates a new CANopen NMT 'boot slave' service.
int co_nmt_boot_boot_req(co_nmt_boot_t *boot, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
Starts a CANopen NMT 'boot slave' service.
This is the internal header file of the NMT 'boot slave' declarations.
void co_nmt_cfg_destroy(co_nmt_cfg_t *cfg)
Destroys a CANopen NMT 'configuration request'.
int co_nmt_cfg_cfg_req(co_nmt_cfg_t *cfg, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
Starts a CANopen NMT 'configuration request'.
co_nmt_cfg_t * co_nmt_cfg_create(can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
Creates a new CANopen NMT 'configuration request'.
int co_nmt_cfg_cfg_res(co_nmt_cfg_t *cfg, co_unsigned32_t ac)
Indicates the result of the 'update configuration' step of an NMT 'configuration request'.
This is the internal header file of the NMT 'configuration request' declarations.
void co_nmt_hb_destroy(co_nmt_hb_t *hb)
Destroys a CANopen NMT heartbeat consumer service.
void co_nmt_hb_set_1016(co_nmt_hb_t *hb, co_unsigned8_t id, co_unsigned16_t ms)
Processes the value of CANopen object 1016 (Consumer heartbeat time) for the specified heartbeat cons...
co_nmt_hb_t * co_nmt_hb_create(can_net_t *net, co_nmt_t *nmt)
Creates a new CANopen NMT heartbeat consumer service.
void co_nmt_hb_set_st(co_nmt_hb_t *hb, co_unsigned8_t st)
Sets the expected state of a remote NMT node.
This is the internal header file of the NMT heartbeat consumer declarations.
void co_nmt_srv_set(struct co_nmt_srv *srv, co_nmt_t *nmt, int set)
Enables/disables the specified CANopen services.
void co_nmt_srv_fini(struct co_nmt_srv *srv)
Finalizes a CANopen NMT service manager.
void co_nmt_srv_init(struct co_nmt_srv *srv, co_nmt_t *nmt)
Initializes a CANopen NMT service manager.
This is the internal header file of the NMT service manager declarations.
#define CO_NMT_SRV_LSS
The LSS master/slave service.
This header file is part of the CANopen library; it contains the Receive-PDO declarations.
int co_rpdo_sync(co_rpdo_t *pdo, co_unsigned8_t cnt)
Triggers the actuation of a received synchronous PDO.
This is the internal header file of the CANopen library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
A CANopen EMCY producer/consumer service.
A CANopen LSS master/slave service.
A CANopen NMT 'boot slave' service.
A CANopen NMT 'configuration request' service.
A CANopen NMT heartbeat consumer.
co_nmt_state_t *(* on_boot)(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
A pointer to the transition function invoked when an 'boot slave' process completes.
void(* on_leave)(co_nmt_t *nmt)
A pointer to the function invoked when the current state is left.
co_nmt_state_t *(* on_enter)(co_nmt_t *nmt)
A pointer to the function invoked when a new state is entered.
co_nmt_state_t *(* on_cs)(co_nmt_t *nmt, co_unsigned8_t cs)
A pointer to the transition function invoked when an NMT command is received.
A CANopen NMT master/slave service.
co_nmt_st_ind_t * st_ind
A pointer to the state change event indication function.
struct timespec inhibit
The time at which the next NMT message may be sent.
co_nmt_hb_t ** hbs
An array of pointers to the heartbeat consumers.
can_timer_t * cs_timer
A pointer to the CAN timer for sending buffered NMT messages.
co_unsigned32_t startup
The NMT startup value (object 1F80).
void * up_data
A pointer to user-specified data for up_ind.
int halt
A flag indicating if the startup procedure was halted because of a mandatory slave boot failure.
co_nmt_sdo_ind_t * dn_ind
A pointer to the SDO download progress indication function.
co_nmt_hb_ind_t * hb_ind
A pointer to the heartbeat event indication function.
int timeout
The default SDO timeout (in milliseconds) used during the NMT 'boot slave' and 'check configuration' ...
void * dcf_comm
The concise DCF of the communication parameters.
co_nmt_boot_ind_t * boot_ind
A pointer to the NMT 'boot slave' indication function.
void * st_data
A pointer to user-specified data for st_ind.
void * cs_data
A pointer to user-specified data for cs_ind.
void * dcf_node
The concise DCF of the application parameters.
co_dev_t * dev
A pointer to a CANopen device.
co_nmt_sdo_ind_t * up_ind
A pointer to the SDO upload progress indication function.
co_unsigned8_t id
The pending node-ID.
void * hb_data
A pointer to user-specified data for hb_ind.
void * sync_data
A pointer to user-specified data for sync_ind.
void * cfg_data
A pointer to user-specified data for cfg_ind.
co_unsigned16_t gt
The guard time (in milliseconds).
co_nmt_lg_ind_t * lg_ind
A pointer to the life guarding event indication function.
struct can_buf buf
A pointer to the CAN frame buffer for NMT messages.
can_net_t * net
A pointer to a CAN network interface.
void * boot_data
A pointer to user-specified data for boot_ind.
co_nmt_ng_ind_t * ng_ind
A pointer to the node guarding event indication function.
can_recv_t * recv_700
A pointer to the CAN frame receiver for NMT error control messages.
void * lg_data
A pointer to user-specified data for lg_ind.
co_unsigned8_t ltf
The lifetime factor.
co_nmt_state_t * state
The current state.
co_unsigned8_t st
The state of the NMT service (including the toggle bit).
void * lss_data
A pointer to user-specified data for lss_req.
co_nmt_sync_ind_t * sync_ind
A pointer to the SYNC indication function.
int master
A flag specifying whether the NMT service is a master or a slave.
co_unsigned16_t ms
The producer heartbeat time (in milliseconds).
can_recv_t * recv_000
A pointer to the CAN frame receiver for NMT messages.
co_nmt_lss_req_t * lss_req
A pointer to the LSS request function.
unsigned long tpdo_event_mask[512/LONG_BIT]
A bit mask tracking all Transmit-PDO events indicated by co_nmt_on_tpdo_event() that have been postpo...
int lg_state
Indicates whether a life guarding error occurred (CO_NMT_EC_OCCURRED or CO_NMT_EC_RESOLVED).
co_nmt_cfg_ind_t * cfg_ind
A pointer to the NMT 'configuration request' indication function.
struct co_nmt_srv srv
The NMT service manager.
size_t tpdo_event_wait
The number of calls to co_nmt_on_tpdo_event_lock() minus the number of calls to co_nmt_on_tpdo_event_...
void * ng_data
A pointer to user-specified data for ng_ind.
can_timer_t * ec_timer
A pointer to the CAN timer for life guarding or heartbeat production.
co_unsigned8_t nhb
The number of heartbeat consumers.
struct co_nmt_slave slaves[CO_NUM_NODES]
An array containing the state of each NMT slave.
co_nmt_cs_ind_t * cs_ind
A pointer to the NMT command indication function.
void * dn_data
A pointer to user-specified data for dn_ind.
A CANopen SYNC producer/consumer service.
A CANopen TIME producer/consumer service.
A CAN or CAN FD format frame.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).
uint_least8_t flags
The flags (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR, CAN_FLAG_FDF, CAN_FLAG_BRS and CAN_FLAG_ESI...
uint_least8_t len
The number of bytes in data (or the requested number of bytes in case of a remote frame).
A struct containing the state of an NMT slave.
co_nmt_boot_t * boot
A pointer to the NMT 'boot slave' service.
void * cfg_data
A pointer to user-specified data for cfg_con.
can_timer_t * timer
A pointer to the CAN timer for node guarding.
co_unsigned8_t ltf
The lifetime factor.
co_unsigned8_t rst
The received state of the slave (including the toggle bit).
can_recv_t * recv
A pointer to the CAN frame receiver for the boot-up event and node guarding messages.
co_unsigned16_t gt
The guard time (in milliseconds).
int ng_state
Indicates whether a node guarding error occurred (CO_NMT_EC_OCCURRED or CO_NMT_EC_RESOLVED).
co_nmt_t * nmt
A pointer to the NMT master service.
co_nmt_cfg_t * cfg
A pointer to the NMT 'update configuration' service.
char es
The error status of the 'boot slave' process.
co_nmt_cfg_con_t * cfg_con
A pointer to the NMT 'configuration request' confirmation function.
co_unsigned32_t assignment
The NMT slave assignment (object 1F81).
co_unsigned8_t rtr
The number of unanswered node guarding RTRs.
int booted
A flag specifying whether the 'boot slave' process has ended.
co_unsigned8_t est
The expected state of the slave (excluding the toggle bit).
A CANopen NMT service manager.
co_tpdo_t ** tpdos
An array of pointers to the Transmit-PDO services.
co_unsigned16_t ntpdo
The number of Transmit-PDO services.
co_lss_t * lss
A pointer to the LSS master/slave service.
co_ssdo_t ** ssdos
An array of pointers to the Server-SDO services.
co_rpdo_t ** rpdos
An array of pointers to the Receive-PDO services.
co_unsigned8_t ncsdo
The number of Client-SDO services.
co_unsigned8_t nssdo
The number of Server-SDO services.
co_time_t * time
A pointer to the TIME producer/consumer service.
co_csdo_t ** csdos
An array of pointers to the Client-SDO services.
co_emcy_t * emcy
A pointer to the EMCY producer/consumer service.
co_unsigned16_t nrpdo
The number of Receive-PDO services.
co_sync_t * sync
A pointer to the SYNC producer/consumer service.
A CANopen SDO upload/download request.
This header file is part of the CANopen library; it contains the Transmit-PDO declarations.
int co_tpdo_event(co_tpdo_t *pdo)
Triggers the transmission of an acyclic or event-driven PDO.
int co_tpdo_sync(co_tpdo_t *pdo, co_unsigned8_t cnt)
Triggers the transmission of a synchronous PDO.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
#define CO_DEFTYPE_DOMAIN
The data type (and object index) of an arbitrary large block of data.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
A union of the CANopen static data types.
This header file is part of the utilities library; it contains the time function declarations.
int timespec_cmp(const void *p1, const void *p2)
Compares two times.
void timespec_add_usec(struct timespec *tp, uint_least64_t usec)
Adds usec microseconds to the time at tp.
This header file is part of the CANopen library; it contains the CANopen value declarations.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.