In a nutshell I want to create a wireless replacement for a J1939 (CAN-Bus) cable. I already have two Yuns and two SeeedStudio CAN-Bus shields. I am using the ARD1939 library and protocol stack (Example and Source).I have no problem receiving and transmitting CAN messages at this point but the procedure for transferring the data is where I need some guidance.
Essentially I want to allow bidirectional communication between the Arduinos while mitigating the possibility of loosing a CAN message. I am trying to figure out the best approach.
- Yun <-> WiFi <-> Yun
I believe I would use the YunClient class in this situation. My loop would have only a couple function calls.
a. Check for a received CAN and if received:
- Package CAN message for transmission
- Connect to client (other Yun)
- Send data to client
- Confirm message recieved
b. Check for a received Wifi (TCP) message and if received:
- Confirm message recieved
- Unpack CAN Message to comply with ARD1939
- Transmit CAN message over CAN bus
So there are a couple things I'm worried about here:
- How can I be sure one Yun is recieving all the messages from the other?
- I've read there that message transmissions can be cut short due to buffer issues. The max size of the transmission will exceed 250 bytes.
I'd appreciate any input anyone has. This is my first Arduino project so I'm still learning.