Protocol Atmel 9331
Internally in the Rio700 products, there is a communication protocol between the Linux part and the Arduino environment. This occurs on the i2C multi-master bus, which means that both CPUs can act as a master. The I2C bus also connects to shield(s) plugged into the Arduino expansion port, and considerations must be made to accommodate for that communication as well.
Binary vs Text protocols
The Internet has been largely successful due to the easy-to-understand and easy-to-test text protocols that are heavily used. However, for tiny microcontrollers string manipulation is overly expensive, and should be avoid if possible. Therefor, the protocol between the two system is binary.
Proprietary vs Standard protocols
This is trickier. It is often "obvious" that a simple proprietary protocol should be used, especially since this is totally hidden from the outside world, doesn't need to handle the many outside world and integration problems that normal protocols need to deal with. On the other hand, standard protocols are available and (somewhat) tested in actual use. So, even though they handle more than is needed, it might still save time in getting any own stuff working properly.
ModBus would possibly be the best candidate, since it is widely used and endless number of open source implementations exist. Exoline is a possible choice, since I personally know it extremely well and have code laying around implementing it.
ModBus data model consists of making a distinction between
- Discrete Inputs - boolean read-only and is typically the physical digital input on the device.
- Coils - boolean, read/write and can either be logical values in a program or the physical digital outputs on the device.
- Input Registers - 16 bit read-only registers, which are used for ADC inputs and counter functions.
- Holding Registers - 16 bit read/write registers.
Each of the above have a 16 bit address and the ModBus codes for reading and writing can do this in blocks of 2048 items, which may either be along the address space or independent of it. The data model makes no such limitations.
After further study of the ModBus protocol, there is one thing that is definitely speaking against it, the lack of floating point numbers. There are a convention that two 16-bit registers next to each other are used for this.
I2C vs RxTx
The Rio700 has both the RxTx as well as the I2C bus connected between the Linux and Arduino environments.
Choosing RxTx makes software integration with any existing ModBus protocol a lot easier. The downside is that the resource is highly limited, on I2C there is a mechanism defined for multi-master and multi-slave communications, making it less "scarce".
I2C on the other hand requires bit-banging master and slave implementations, which probably exist in the open source landscape. The i2C bit-banging both master and slave, especially on the Atmel, should not be under-estimated, both in terms of performance, as well as the need for a fully non-blocking implementation.
Another consideration is the use of RxTx to Rionita52 (Power Measurement Shield), where it shares the RxTx with the Atmel, i.e. Linux can talk to both, but they can't talk to each other.
It is not an easy choice, but I think I am going to recommend a RxTx implementation in the first round, since there are so many other moving parts. This (and everything else) can be changed at a later date if found necessary.