Version 2 (modified by 16 years ago) ( diff ) | ,
---|
Mote-PC Serial Communication
The basic abstraction for mote-PC communication is a packet source . A packet source is a communication medium over which an application can receive packets from and send packets to a mote. Examples of packet sources include serial ports, TCP sockets, and the SerialForwarder tool. Most TinyOS communication tools take an optional -comm parameter, which allows you to specify the packet source as a string. For example:
node1-2:~# java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb
tells Listen tool to use the serial port /dev/ttyUSB0 at the correct speed for a telosb mote.
Listen creates a packet source and just prints out every packet it sees. Output should look something like this:
node1-2:/opt/tinyos-2.1.0/apps/BaseStation# java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb serial@/dev/ttyUSB0:115200: resynchronising 00 FF FF 00 01 04 00 06 00 01 00 4E 00 FF FF 00 01 04 00 06 00 01 00 4F 00 FF FF 00 01 04 00 06 00 01 00 50 00 FF FF 00 01 04 00 06 00 01 00 51 00 FF FF 00 01 04 00 06 00 01 00 52 00 FF FF 00 01 04 00 06 00 01 00 53 00 FF FF 00 01 04 00 06 00 01 00 54 00 FF FF 00 01 04 00 06 00 01 00 55 00 FF FF 00 01 04 00 06 00 01 00 56 00 FF FF 00 01 04 00 06 00 01 00 57 00 FF FF 00 01 04 00 06 00 01 00 58 00 FF FF 00 01 04 00 06 00 01 00 59 00 FF FF 00 01 04 00 06 00 01 00 5A 00 FF FF 00 01 04 00 06 00 01 00 5B
We use MsgReader to print out the messages.
node1-2:~# java net.tinyos.tools.MsgReader -comm serial@/dev/ttyUSB0:telosb BlinkToRadioMsg
MsgReader reads the packet send to the serial port, looks at its AM type, and if it matches the AM type of one of the Java message classes passed at the command line, it prints out the packet. We see the output like this:
1152232617609: Message [nodeid=0x2] [counter=0x1049] 1152232617609: Message [nodeid=0x2] [counter=0x104a] 1152232617609: Message [nodeid=0x2] [counter=0x104b] 1152232617621: Message [nodeid=0x2] [counter=0x104c]