UNO + Ethershield + CAN bus: how do we know who is talking?

Thank you for your interest... :slight_smile:

I am using this adaptor: MCP2515

DATA:    [======    ]  60.3% (used 1234 bytes from 2048 bytes)
PROGRAM: [=======   ]  72.1% (used 23268 bytes from 32256 bytes)

I have progressed with the fault finding, by going back to basics:
two UNOS, two MCP2515 boards, connect them, one transmits the other receives; sweet, all working.
Then change code on one to read data from the source device, a battery management system. Also working.

Changed publishTopicAndMessage() to serial out, rather than sendMqtt... and this produced some gibberish, indicating the program seems to work, but the coding must be wrong.

The source sends data at 4Hz, and quite a bit of data.
I reckon the sendMqtt msg bit takes to long; and another suspicion is my c-string handling, which I have to read up on. It may well be the reason for the UNO to produce gibberish, and eventually reset after a few seconds, due to buffer overflows.

I think I need to rewrite this to wait for a certain message Id, process this, send the MQTT msg, and then wait for the next msg Id. Say, every few seconds I capture another msg of interest. There are 7, one every 2 seconds, and I have the data in 15 seconds, do this every 5 minutes, this will do.

Most importantly what I forgot: the key question: Who talks on SPI? Or, what manages the different slave select pins? How does one know the other is talking? In this case the Ethernet shield uses pin 10, while the MCP2515 uses pin 9. Who orchestrates the 'traffic' so to speak? I have mot coded anything to that effect. This could be also the problem for the gibberish (as in weird characters) I get?!