2020-06-02 06:33 AM
Hello everyone, i am working on a project to connect two stm32 boards via CAN bus which i managed to do successfully, now i am looking for a way to acces to variables of one board from the other board. i really hope one of you can reply. thank you.
2020-06-02 08:08 AM
It depends on the network protocol used with the CAN bus. Most CAN protocols use a data object concept, where a global identifier is used to query or modify an object on a remote node.
CANopen is a good example of how this works. There is a common object dictionary which defines the variables (i.e. objects) exposed for remote access. A Process Data Object (PDO) is periodically broadcast by the source node and received by all other nodes on the bus. The receivers can chose to ignore the broadcast or process the remote data as needed by the overall application. This is roughly equivalent to a UDP broadcast in TCP/IP.
A second method in CANopen uses Service Data Objects (SDO) to handle on-demand queries or modifications. The remote node sends a request to the local node using the SDO identifier. The local node sends the SDO data on the bus, which can be processed by other nodes if they listen for the identifier. Ths is similar to TCP transactions in TCP/IP.
CANopen has mechanisms to transmit simple or complex data objects, although in keeping with the CAN philosophy the ideal format is short messages and minimal point to point transactions. It is designed to work with the 16-bit filtering masks to separate the different services and nodes.
You might also look at the J1939 CAN protocol, which is used for vehicles. It is slightly easier to implement but has some issues with assigning object identifiers and message filtering.
Jack Peacock