TinyOS UART – Sending Raw Data


In Serial.h serial packets datatype is defined as:

typedef nx_struct serial_packet {
     serial_header_t header; //Headers!
     nx_uint8_t data[];
} serial_packet_t;

but, what if we don’t want to send any headers, i.e. raw data ???



A TinyOS interface that allows an application to tell the Serial Dispatcher, which is in charge of packet formatting, whether to use headers or not in the serial packets.

interface SerialConfigure {
  command void useHeaders( bool use_headers );


This is where the Serial Dispatcher is in TinyOS’s serial stack:



TinyOS Serial stack. Taken from TinyOS Documentation

The actual implementation is in SerialDispatcherP.nc, thus the original file must be replaced with the one provided at the bottom of this page. Then apps only need to implement the SerialConfigure interface.




Example of Use
( Not relevant code is omitted. See complete code on download area )

configuration TestAppC{
    components TestC as App;
    App.UartConfigure -> SerialDispatcherC.SerialConfigure; //we must wire it to the Serial Dispatcher,

module TestC{
    uses interface SerialConfigure as UartConfigure; 
    event void Boot.booted(){
        call UartConfigure.useHeaders(FALSE); //Then we set to false or true 



When calling UartConfigure.useHeaders( TRUE )

When calling UARTConfigure.useHeaders( FALSE )




By |2015-07-06T06:23:14+00:00July 2nd, 2012|Middleware, TinyOS|0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.