== Mote-PC Serial Communication == The receivers receive packets from senders and pass them on to the serial port. Tinyos provides two java tools (Listen and MsgReader) to print the messages on the PC console. {{{ node1-2:~# java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb }}} The Listen tool receives the packets and prints the raw packets to the PC console. 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 }}} MsgReader is a better alternative to Listen. The MsgReader class takes a java message class (provided by the user) as an argument. It prints receives the packets from the serial port and prints the packet structure defined by the java message class. {{{ 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] }}}