2011年10月20日星期四

Telosb serial port test-tinyos2.1.1

Telosb has two serial port: UART 0 and UART 1. The default setting is UART1.
When doing the write or read operation, data will go through FT232BM chip, which is a USB-serial converter chip, and then upload to PC.

First, I will introduce the 'make' command

1)make [platform]: this command will compile nesc code that could run on certain platform such as telosb or mica. You need to cd to the code directory.

eg: make telosb; make mica

2)make [platform] reinstall: this command will download the code into the platform

3)make [platform] install: this command is equal to first run 'make [platform]' then 'make [platform] reinstall'. Of course, if there is any error when doing the 'make [platform]', it will not go to 'make [platform] reinstall'.

4)make clean: clean the file or directory the above compile command generate.

Then you can run 'java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb'
ttyUSBx could change, you can check the port with 'motelist'

If the java env and PATH is right, you will get
serial@/dev/ttyUSB0:115200: resynchronising

this means java is ok, and it is waiting the data. But it could receive anything.
We need to go to /apps/tests/TestSerial
'make telosb install'
Then try the serial listen again, it will say
:-) java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb
serial@/dev/ttyUSB0:115200: resynchronising
00 FF FF 00 00 02 00 89 00 64
00 FF FF 00 00 02 00 89 00 65
00 FF FF 00 00 02 00 89 00 66
00 FF FF 00 00 02 00 89 00 67
00 FF FF 00 00 02 00 89 00 68
00 FF FF 00 00 02 00 89 00 69
00 FF FF 00 00 02 00 89 00 6A
00 FF FF 00 00 02 00 89 00 6B
00 FF FF 00 00 02 00 89 00 6C
00 FF FF 00 00 02 00 89 00 6D
00 FF FF 00 00 02 00 89 00 6E
00 FF FF 00 00 02 00 89 00 6F
00 FF FF 00 00 02 00 89 00 70
00 FF FF 00 00 02 00 89 00 71
00 FF FF 00 00 02 00 89 00 72
00 FF FF 00 00 02 00 89 00 73
00 FF FF 00 00 02 00 89 00 74

:-) java TestSerial -comm serial@/dev/ttyUSB1:telosb
Sending packet 0
serial@/dev/ttyUSB1:115200: resynchronising
Received packet sequence number 287
Received packet sequence number 288
Received packet sequence number 289
Received packet sequence number 290
serial@/dev/ttyUSB1:115200: bad packet
Received packet sequence number 292
Received packet sequence number 293
Received packet sequence number 294
serial@/dev/ttyUSB1:115200: bad packet
Received packet sequence number 296
Received packet sequence number 297
Received packet sequence number 298
serial@/dev/ttyUSB1:115200: bad packet
serial@/dev/ttyUSB1:115200: bad packet
Received packet sequence number 301
Received packet sequence number 302
Received packet sequence number 303


Congrats!


Telosb communicate with PC through support/sdk/java and support/sdk/c, we could use java or c to do the communication. Also, we could use python.

java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb

This command use java to implement the listen of serial port. The baud rate of telosb is 115200.

Tomorrow I will study the serial port of telosb both in hardware and software.

The cable that connect microUSB port to USB male port is still on delivery...
I will debug telosb serial port and android port separately before I get the cable.

没有评论: