I'm using cantools in python for decoding some CAN messages read from socketcan. In python, I can read a message from the socket and decode it simply with:
message = can_bus.recv()
decoded_msg = db.decode_message(msg.arbitration_id, msg.data)
where can_bus is the socket and db is the dbc loaded file.
Now i've generated the C files .h and .c starting from my .dbc file. How can I decode a CAN message received in C using the auto-generated files? I can read the message from socket in this way (in C):
nbytes = read(s, &frame, sizeof(struct can_frame));
where s is the socket and frame is where the recived frame is stored.
How can I decode the received frame using the .h and .c autogenerated files?