[Tinyos-devel] serial communication in TinyOS2

Philip Levis pal at cs.stanford.edu
Mon Jun 5 21:28:07 PDT 2006


On Jun 5, 2006, at 5:38 PM, Razvan Musaloiu-E. wrote:

> Hi!
>
> I'm trying to use the serial communication from TinyOS2 and I  
> encounter
> some difficulties.
>
> First: even the description of sfsend in README says:
>
> 	- sfsend: send a packet (specified on the command line) to a  
> serial forwarder
>
> the code doesn't really do this. It tries to send some packets but  
> they
> are composed manually. The way it is done is like this:
>
>     26        unsigned char packet[100];
>     27
>     28        packet[i++] = 0xff; // addr low byte
>     29        packet[i++] = 0xff; // addr high byte
>     30        packet[i++] = 0x04; // AM id
>     31        packet[i++] = 0xbc; // group id
>     32        lenp = i++;         // length
>     33        packet[i++] = j;    // payload
>     34        packet[i++] = 0xbe; // payload
>     35        packet[i++] = 0xef; // payload
>     36
>     37        packet[lenp] = i-5; // length, don't include header
>
> This doesn't seem to follow the format described in
> tinyos-2.x/tos/lib/serial/Serial.h which is:
>
>    112  typedef nx_struct serial_header {
>    113    nx_am_addr_t addr;
>    114    nx_uint8_t length;
>    115    nx_am_group_t group;
>    116    nx_am_id_t type;
>    117  } serial_header_t;
>
> Could someone provide some guidance here? :-)

I think that sfsend.c is not quite ready. It was part of David Gay's  
efforts to produce a C SDK, but right now it's on the back burner as  
he releases nesC 1.2.5 and implements the storage system for the at45db.

> Second: I find very tempting to use Python to talk to a serial  
> forwarder
> but the code from tinyos-2.x/support/sdk/python doesn't have any
> utilization instructions. :-) I manage find how I can connect to a  
> serial
> forwarder (sending "U ") and what is the format of the received data
> (one byte size follow by the packet) but I still don't know how to
> use the Message class in a useful way. Could someone make a little  
> light
> here? :-)

There is not a complete Python SDK for TinyOS yet. Geoff Mainland at  
Harvard implemented one for 1.x, but some changes would be needed for  
it to work with 2.x. The code currently in sdk/python is just enough  
to generate messages when using TOSSIM.

Phil


More information about the Tinyos-devel mailing list