11 if ((listener.
can_id & listener.
mask) > canbus::CAN_STANDARD_ID_MAX) {
12 ESP_LOGW(TAG,
"frame listener 0x%x/0x%x matches no 11-bit CAN ID, not added", listener.
can_id, listener.
mask);
21 listener.
can_id &= canbus::CAN_STANDARD_ID_MAX;
22 listener.
mask &= canbus::CAN_STANDARD_ID_MAX;
25 if (this->
co_ !=
nullptr)
31 CO_CANmodule_t *mod = this->
co_->CANmodule;
32 for (uint16_t i = 0; i < mod->rxSize; i++) {
33 const CO_CANrx_t *rx = &mod->rxArray[i];
34 if (rx->CANrx_callback ==
nullptr || (rx->ident & 0x800))
36 if (((can_id ^ rx->ident) & mask & rx->mask) == 0) {
37 ESP_LOGW(TAG,
"frame listener 0x%03x/0x%03x overlaps CAN ID 0x%03x used by CANopenNode", can_id, mask,
44 if (can_id > canbus::CAN_STANDARD_ID_MAX ||
len > canbus::CAN_MAX_DATA_LENGTH)
46 return this->
transmit(can_id, data,
static_cast<uint8_t
>(
len));
50 if (msg.ident & 0x800)
53 if (((msg.ident ^
l->can_id) &
l->mask) == 0)
54 l->callback(
l->context, msg.ident, msg.data, msg.DLC);
57#ifdef USE_CANOPEN_HEARTBEAT
65 if (!
decode_emcy(msg.ident, msg.data, msg.DLC, node, emcy))
69 ESP_LOGI(TAG,
"node 0x%02x EMCY: error reset, register 0x%02x", node, emcy.
error_register);
73#ifdef USE_CANOPEN_EMCY
CallbackManager< void(uint8_t, const Emergency &)> emcy_callback_
bool transmit(uint16_t ident, const uint8_t *data, uint8_t len)
void add_frame_listener(FrameListener &listener)
FrameListener * frame_listeners_
bool send_frame(uint32_t can_id, const uint8_t *data, size_t len)
void check_frame_listener_(uint16_t can_id, uint16_t mask)
void dispatch_frame_(const CO_CANrxMsg_t &msg)
CallbackManager< void(uint8_t, NMTState)> heartbeat_callback_
bool decode_heartbeat(uint32_t can_id, const uint8_t *data, size_t len, uint8_t &node, NMTState &state)
ESPHOME_LOG_TAG(TAG, "canopen")
bool decode_emcy(uint32_t can_id, const uint8_t *data, size_t len, uint8_t &node, Emergency &emcy)