Hi guys.
I've been diving into the CAN protocol for my professional projects and I start to wonder if all the implementations I've seen could follow some form of Remote Procedure Call paradigm. CAN has two distinct forms of messages (frames):
- messages that correspond to node data broadcast,
- messages that request specific data from any node able to provide them.
The former is a one-way communication. The latter is two-way and even includes the number of bytes the requesting node expects as the DLC field, which is exactly some form of RPC (
Request-Response); the message ID could be mapped to a function name and the DLC field as the number of
expected byte arguments. That's low level RPC of course but from what I've understood so far CAN implementations could as well be generalized into a low level RPC library, what do you think?
I see one big difference, at least: RPC usually involves 2 specific peers in a client-server communication by using IP sockets, for instance, while CAN frames are broadcast, which means RPC calls would be
asynchronous. But the microcontroller has all it takes to buffer messages, which is one problem solved at the hardware level. In my opinion this kind of programming would be best implemented as a
state machine as the latter can also work around delayed loops easily (an example
here which I based my state machine code on).
Anyway do you know or are there CAN libraries implemented as [low-level] RPC around?