diff options
Diffstat (limited to 'cethcan/can.c')
-rw-r--r-- | cethcan/can.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cethcan/can.c b/cethcan/can.c index be8c635..4a61756 100644 --- a/cethcan/can.c +++ b/cethcan/can.c @@ -32,8 +32,18 @@ struct can_user *can_register_alloc(void *arg, can_handler handler, void can_broadcast(struct can_user *origin, struct can_message *msg) { struct can_user *u; + char buf[3*8+1]; msg->origin = origin; + + if (msg->dlc > 8) { + lprintf("invalid CAN message (DLC = %zu)", msg->dlc); + return; + } + for (size_t i = 0; i < msg->dlc; i++) + sprintf(buf + 3 * i, " %02x", msg->bytes[i]); + lprintf("%08x (%zu)%s", (unsigned)msg->daddr, msg->dlc, buf); + for (u = users; u; u = u->next) if (u != origin) u->handler(u->arg, msg); |