Hello,
I would like to know if it's possible to send complex nested struct over Serial (I2C, SPI) from Arduino to Raspberry PI.
Example:
struct SamplePayload {
int8_t A;
uint8_t B;
cmValve valve1;
cmValve valve2;
cmSensor sensor1;
cmSensor sensor2;
} payload;
It is, but the other end will have NO IDEA what you just send. Remember, in the line (no matter if it's I2C, SPI or serial) it is ALL just packages of one byte in a row.
Aka, if you want to send it over you have to come up with a protocol so both ends will understand how to send it and how to receive it.
I would use SerialProtocol library. The same type and struct definitions would be used on both ends.
rdvojmoc:
I would use SerialProtocol library. The same type and struct definitions would be used on both ends.
You'd have to make sure that the processor on each end of the link use the same data alignment, Endianness, etc. Otherwise, it could require some byte manipulation on the RX end.