Protocol - SPI over UDP (port 2118)
SPI - Send SPI data
00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'e' | 'F' | 'i' | 'r' | ||||||||||||||||||||||||||||
'm' | 'a' | 't' | 'a' | ||||||||||||||||||||||||||||
'S' | 'P' | 'I' | Version = 0 | ||||||||||||||||||||||||||||
Reserved = 0 | wait | CPOL | CPHA | ||||||||||||||||||||||||||||
SPI character data ... ... 255 octets max ... |
The SPI data transfer format is set by CPOL and CPHA.
If the wait bit is set, the firmware should wait for the CS pin to become inactive before sending this data. (This is to help deal with the buggy dSpin stepper-motor controller.)
NOTE: the "wait", "CPOL" and "CPHA" bits are not implemented yet. :-(
There is no wait. CPOL and CPHA are both hard-coded to 1. (coming soon!...)
The number of bytes is inferred from the UDP packet length.
The data should be kept fairly small. The PC should wait for return data before sending more data. The internal buffer is only 256 frames, and the network can run much faster than the SPI. It is possible to completely overflow the input buffer. (Perhaps this would work better as TCP?...)
Response
SPI - Return SPI data
00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SPI character data ... ... |
The return data has no additional structure; it is simply the data contained in the UDP packet.
The eFirmata MAY return multiple packets. (In fact, it is LIKELY that the return data will be broken up across multiple packets.)
The eFirmata MUST return the same number of data bytes as were sent to it. (This is the very nature of SPI -- one byte is received and transmitted at the same time.)