Finally, clear explanation of TinyOS 2.x serial packet structure

TinyOS 2.x

A message sent through serial ports from motes to PC will typically look like this:

00 FF FF 00 00 08 00 09 19 77 02 07 00 13 00 00


  • The first byte 00 is the leading zero.
  • After that, the whole packet is of the type "serial_packet_t", defined in tinyos-2.x/tos/lib/serial/Serial.h.
    • Inside the serial_packet_t structure, the first 7 bytes are of the type "serial_header_t", which is also defined in tinyos-2.x/tos/lib/serial/Serial.h.

      In the case above, it would be FF FF 00 00 08 00 09.

      Within the "serial_header_t", the following structure takes place:
      • nx_am_addr_t dest // Destination (2 bytes)
      • nx_am_addr_t src // Source (2 bytes)
      • nx_uint8_t length // Payload Length (1 byte)
      • nx_am_group_t group // Group ID (1 byte)
      • nx_am_id_t type // Active Message Handler Type (1 byte), some enum value that you can define yourself.
    • After the 7 byte header, here comes the payload, which can be up to TOS_DATA_LENGTH (28 bytes) long. The content could be anything.

      In the above example, the payload is: 19 77 02 07 00 13 00 00, which is of the length (8 bytes) denoted in the "Payload Length" field.


To note, besides the payload part, we need to fill out the destination address and payload length field by calling SerialActiveMessageC.AMSend(am_addr_t dest, message_t* msg, uint8_t len). It would be a good programming manner to fill the len with sizeof(). And we also need to specify the Active Message Handler Type by wiring the AMSend to SerialActiveMessage.AMSend[am_id_t id];

ref:
http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/lesson4.html. The doc here doesn't seem to be up-to-date since it left out the source address from the header.
GREAT THANKS TO http://tristan-tech.blogspot.com/ and his blog!!!!
(I copied whole blog from him in order to have in mine blog everything I might use in future)

Comments

Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.

Popular posts from this blog

Timeline on Latex

Exporting Skype Chat/Skype Contacts to csv file using the shell script and sqlite3 (usually already installed on mac)

trim() not supported by IE7 and IE8