I would like to share this communication protocol, called MaCaco, that allow multiple P2Pcommunication within Freakduino devices. Suggestion, comment and tester are apprecciated.
The protocol is designed for low rate transmission, is mainly a state-less protocol and can work in subscription mode or polling mode.
The protocol is inspired to Modbus in some features, data are exchanged via a shared map (an array that has the same structure in all devices), for each type of action there is a functional code, data sent should not allow gaps.
Out of these, the protocol doesn't share other common points with Modbus. Mainly differencies are:
- Doesn't work as Master-Slave, is a P2P,
- Shared Map could contain different data between devices,
- Data could be polled, but also exchange only when data are changing their value.
The shared memory map is just an array that has the same structure for all devices (is not a real constrain, but is suggested). Virtually is splitted in INPUT and OUTPUT areas, where OUTPUT are tipically shared with other devices. The INPUT are used to collect data from devices in the network.
An area of the memory map (tipically the output) is also assigned for subscription.
The protocol allow to subscribe an area (tipically the output) of the memory map of another device. Every time that data change, the source of data will communicate the new values to the device that was asking for the subscription.
The subscription save bandwith and CPU load, periodically the device asking for subscription renew it based on two parameters: channel healty and communication counts.
Some data could be required on event-base and not at every cicly, in this case polling is the right option. In case of polling, for each request is sent an answer with the current values also if they aren't changed.
Using polling mode at every cycle will use bandwith and CPU also if not really required.
This protocol is quasi state-less, this because in the header of the frame is contained the address where data will be placed once it came back. So is not required to record the connection. This feature make impossible use this protocol within devices that use a different number of bits for addressing their internal registers, but lets less code.
Is not fully state-less because in subscription mode are stored healty and count for each communication channel.
When, Why, Who...
This protocol could be used to exchange data between multiple Freakduinos, and can work over standard chibiduino or chibiduino with routing. It allow easy data transfer for people intendend to build a distribuited system (like home automation system).
Please share suggestion and comments and also it will be apprecciated any tester.