70__co_nmt_hb_alloc(
void)
81__co_nmt_hb_free(
void *ptr)
101 goto error_create_recv;
108 goto error_create_timer;
147 if (!__co_nmt_hb_init(hb,
net,
nmt)) {
155 __co_nmt_hb_free(hb);
165 __co_nmt_hb_fini(hb);
166 __co_nmt_hb_free(hb);
217 co_unsigned8_t
st = msg->
data[0];
228 co_unsigned8_t old_st = hb->
st;
229 int old_state = hb->
state;
234 "NMT: heartbeat time out resolved for node %d",
244 "NMT: heartbeat state change occurred for node %d",
262 diag(
DIAG_INFO, 0,
"NMT: heartbeat time out occurred for node %d",
This header file is part of the CANopen library; it contains the device description declarations.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
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.
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 can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
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.
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.
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.
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
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.
#define CO_NMT_EC_CANID(id)
The CAN identifier used for both node guarding and heartbeat monitoring.
@ CO_NMT_EC_STATE
An NMT error control state change event.
@ CO_NMT_EC_TIMEOUT
An NMT error control timeout event.
#define CO_NMT_ST_TOGGLE
The mask to get/set the toggle bit from an NMT state.
@ CO_NMT_EC_OCCURRED
An NMT error control event occurred.
@ CO_NMT_EC_RESOLVED
An NMT error control event was resolved.
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...
static int co_nmt_hb_timer(const struct timespec *tp, void *data)
The CAN timer callback function for a heartbeat consumer.
static int co_nmt_hb_recv(const struct can_msg *msg, void *data)
The CAN receive callback function for a heartbeat consumer.
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.
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 NMT heartbeat consumer.
can_timer_t * timer
A pointer to the CAN timer.
co_unsigned8_t st
The state of the node (excluding the toggle bit).
can_net_t * net
A pointer to a CAN network interface.
co_unsigned16_t ms
The consumer heartbeat time (in milliseconds).
co_unsigned8_t id
The node-ID.
co_nmt_t * nmt
A pointer to an NMT master/slave service.
can_recv_t * recv
A pointer to the CAN frame receiver.
int state
Indicates whether a heartbeat error occurred (CO_NMT_EC_OCCURRED or CO_NMT_EC_RESOLVED).
A CANopen NMT master/slave 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 len
The number of bytes in data (or the requested number of bytes in case of a remote frame).
A time type with nanosecond resolution.