70 __co_nmt_hb_alloc(
void)
79 __co_nmt_hb_free(
void *ptr)
99 goto error_create_recv;
106 goto error_create_timer;
145 if (!__co_nmt_hb_init(hb, net, nmt)) {
153 __co_nmt_hb_free(hb);
163 __co_nmt_hb_fini(hb);
164 __co_nmt_hb_free(hb);
215 co_unsigned8_t
st = msg->
data[0];
226 co_unsigned8_t old_st = hb->
st;
227 int old_state = hb->
state;
232 "NMT: heartbeat time out resolved for node %d",
242 "NMT: heartbeat state change occurred for node %d",
260 diag(
DIAG_INFO, 0,
"NMT: heartbeat time out occurred for node %d",
An NMT error control timeout event.
A CAN or CAN FD format frame.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
can_timer_t * timer
A pointer to the CAN timer.
static int co_nmt_hb_recv(const struct can_msg *msg, void *data)
The CAN receive callback function for a heartbeat consumer.
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)...
static int co_nmt_hb_timer(const struct timespec *tp, void *data)
The CAN timer callback function for a heartbeat consumer.
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.
#define CO_NMT_ST_TOGGLE
The mask to get/set the toggle bit from an NMT state.
can_recv_t * recv
A pointer to the CAN frame receiver.
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
An NMT error control event occurred.
An NMT error control event was resolved.
void co_nmt_hb_set_st(co_nmt_hb_t *hb, co_unsigned8_t st)
Sets the expected state of a remote NMT node.
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 set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
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.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
co_unsigned16_t ms
The consumer heartbeat time (in milliseconds).
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
void can_recv_destroy(can_recv_t *recv)
Destroys a CAN frame receiver.
co_unsigned8_t id
The node-ID.
This is the internal header file of the CANopen library.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
#define CO_NMT_EC_CANID(id)
The CAN identifier used for both node guarding and heartbeat monitoring.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
A CANopen NMT master/slave service.
An NMT error control state change event.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
This header file is part of the utilities library; it contains the diagnostic declarations.
int state
Indicates whether a heartbeat error occurred (CO_NMT_EC_OCCURRED or CO_NMT_EC_RESOLVED).
A CANopen NMT heartbeat consumer.
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.
can_net_t * net
A pointer to a CAN network interface.
co_nmt_t * nmt
A pointer to an NMT master/slave service.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface...
co_unsigned8_t st
The state of the node (excluding the toggle bit).
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.
This header file is part of the CANopen library; it contains the device description declarations...
void co_nmt_hb_destroy(co_nmt_hb_t *hb)
Destroys a CANopen NMT heartbeat consumer service.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib.h> and defines any missing functionality.
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...
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.
This is the internal header file of the NMT heartbeat consumer declarations.
An informational message.