I have some third party software (that I can't change) that can discover devices on the CAN bus by sending out messages sequentially to nodes (starting from 0x01 thru to 0xFF).
These messages use the remote frame type (RTR bit set to 1) and the nodes typically respond with a CAN message stating their type and serial number. This allows the third party tool to then further interrogate the node to get configuration data to be sent back to the tool for configuration of the system (it is the Velbus home automation system).
Now, I'm trying to write a custom node using an Arduino R4 Minima to interact with other nodes on the bus. So far I can connected to the bus and send unprompted CAN messages.
However, if I call CAN.avaliable() in my loop function, it does not return true to these RTR messages, which means I cannot respond to them, so the third party software is unaware of my node.
I think the problem is the setup of the mailboxes in the 7FA4M1_CAN constructor
R7FA4M1_CAN::R7FA4M1_CAN(int const can_tx_pin, int const can_rx_pin)
// snip
, _can_mailbox
{
//snip
/* Mailbox Group #4 */
{ .mailbox_id = 0, .id_mode = CAN_ID_MODE_EXTENDED, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
// snip
/* Mailbox Group #6 */
{ .mailbox_id = 8, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
//snip
Has anybody been able to receive remote frame type messages ? If so what needs to be changed ?
If I changed the frame type for receive mailbox 11
/* Mailbox Group #6 */
{ .mailbox_id = 8, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
{ .mailbox_id = 9, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
{ .mailbox_id = 10, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
// { .mailbox_id = 11, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_DATA, .mailbox_type = CAN_MAILBOX_RECEIVE },
{ .mailbox_id = 11, .id_mode = CAN_ID_MODE_STANDARD, .frame_type = CAN_FRAME_TYPE_REMOTE, .mailbox_type = CAN_MAILBOX_RECEIVE },
then the message is received.
But this makes me nervous because I'm not sure what all of the mailboxes are for, and in this application most messages (apart from the occasional one from the config software) will be normal data messages.
I don't want to muck things up too much, so I'm really looking for some advice on how to configure the mailboxes.
Another interesting discovery.
The CanMsg class declared in CanMsg.h does not have a way to discover if the RTR (remote transmission request) flag has been set.
It can detect if an extended (29 bit) id has been used by bitmasking the id with 0x8000000 as the most significant bit (31) is set to indicate this. The comments in the code say bit 30 is reserved for a future remote transmission request flag, but it has not been implemented yet.
Is there any other to detect this as I cannot change the underlying third party software and how it detects unconfigured nodes. I have read CiA Application Note 802 so understand the issues.
Do I need to go spelunking into the underlying Renases CAN code ?
I've found the underlying structure "R_CAN0_Type" in the R7FA4M1AB.h header file * but my C++ skills are a bit rusty so it will take me some time to understand how this flows through.
* in directory ~/.arduino15/packages/arduino/hardware/renesas_uno/1.1.0/variants/MINIMA/includes/ra/fsp/src/bsp/cmsis/Device/RENESAS/Include