TinyOS UART – Sending Raw Data

Posted By on Jul 2, 2012 | 0 comments


 

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 ???

 

Solution

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{
}
implementation{
    components TestC as App;
    App.UartConfigure -> SerialDispatcherC.SerialConfigure; //we must wire it to the Serial Dispatcher,
}

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

 

Results

When calling UartConfigure.useHeaders( TRUE )

When calling UARTConfigure.useHeaders( FALSE )

 

Downloads

 

Download

Submit a Comment

Your email address will not be published. Required fields are marked *