-
Notifications
You must be signed in to change notification settings - Fork 0
SerialForwarder protocol
This page describes the TinyOS serial-forwarder protocol. This is probably described in a TEP somewhere as well. http://tinyos.stanford.edu/tinyos-wiki/index.php/Mote-PC_serial_communication_and_SerialForwarder_%28TOS_2.1.1_and_later%29
Communication with serial-forwarder is done over a TCP socket, basically packets over a stream. The server and client identify themselves with a handshake and then start sending messages. Messages are basically sent as Pascal strings - first the length and then the number of bytes specified by the length. The length field is 1 byte, so the maximum number of bytes in a packet is 255. Theoretically it should be possible to send 0 bytes for keep-alive and detecting broken streams, but this might not work in all implementations(TODO check).
In the beginning of the TCP connection the server sends and also expects to receive a protocol version handshake. Most implementations have this hard-coded and an exact match is required. The handshake is 2 bytes in both directions and is a fixed value of "U ". Supposedly the space is the actual protocol version and could differ.
Handshake
| ASCII | Dec | Hex | Description |
|---|---|---|---|
| "U " | 85 32 | 0x55 0x20 | Uppercase U and a space |
The following is a 16 byte packet.
| Length | Data |
|---|---|
| 0x10 | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |