Hello!
I am trying to send some messages to the serial port in order to process
them with a java application. But something goes wrong, the java app does
not "see" the packets arriving to the serial port. So either I do not send
them to the serial port correctly or the java app is not correct. Or both.
I am using a telosb mote connected to usb port which receives a message
every second. The mote sends another message over the radio and forwards
the received message (after some changes) to the serial port. In order to
send to the serial port I have written:
module MineC{
...
uses interface AMSend as UartAMSend;
uses interface Packet as UartPacket;
...
}
implementation{
...
message_t packet_uart;
...
event message_t* RadioReceive.receive(message_t* msg, void* payload,
uint8_t len){
...
MineMsg* pkt3=(MineMsg*)(call
UartPacket.getPayload(&packet_uart,sizeof(MineMsg)));
pkt3->id=u;
pkt3->d=x;
pkt3->c=y;
pkt3->c2=z;
pkt3->t=w;
call UartAMSend.send(TOS_UART_ADDR,&packet_uart,sizeof(MineMsg));
...
}
event void UartAMSend.sendDone(message_t* msg, error_t err){
if(err==SUCCESS){
printf("\n!!!MESSAGE SENT TO SERIAL PORT!!!\n");
}else call
UartAMSend.send(TOS_UART_ADDR,&packet_uart,sizeof(CondMsg));
}
} //end of implementation
and at Mine.h I define TOS_UART_ADDR=0x007E. Also at MineAppC.nc I wire the
interfaces with the components. I compile and install the program and I
don't get any errors. If I run MsgReader tool I get:
serial@/dev/ttyUSB4:115200: resynchronising
serial@/dev/ttyUSB4:115200: bad packet
and then nothing. It does not exit either. If I run Listen tool I a packet
per sec as expected. But the first second I get:
serial@/dev/ttyUSB4:115200: resynchronising
00 FF FF 00 00 1C 00 64 0A 49 20 61 6D 20 69 6E 74 6F 20 52 65 63 65 69 76
65 21 21 21 0A 0A 7A 6F 6E 65 3D
00 FF FF 00 00 1C 00 64 31 2C 20 74 65 6D 70 3D 30 2C 20 64 75 73 74 3D 35
35 2C 63 6F 3D 31 39 30 30 2C 63
00 FF FF 00 00 1C 00 64 6F 32 3D 35 39 32 0A 0A 0A 53 45 4E 44 3A 6C 65 64
30 3D 30 0A 6C 65 64 31 3D 31 0A
00 FF FF 00 00 1C 00 64 0A 0A 46 4F 52 20 53 45 52 49 41 4C 3A 7A 6F 6E 65
3D 31 2C 20 74 65 6D 70 3D 30 2C
00 FF FF 00 00 1C 00 64 20 64 75 73 74 3D 35 35 2C 63 6F 3D 31 39 30 30 2C
63 6F 32 3D 35 39 32 0A 0A 21 21
00 FF FF 00 00 1C 00 64 21 4D 45 53 53 41 47 45 20 53 45 4E 54 21 21 21 0A
0A 21 21 21 4D 45 53 53 41 47 45
00 FF FF 00 00 1C 00 64 20 53 45 4E 54 20 54 4F 20 53 45 52 49 41 4C 20 50
4F 52 54 21 21 21 0A 00 00 00 00
and then every second I get these 7 lines:
00 FF FF 00 00 1C 00 64 0A 49 20 61 6D 20 69 6E 74 6F 20 52 65 63 65 69 76
65 21 21 21 0A 0A 7A 6F 6E 65 3D
00 FF FF 00 00 1C 00 64 31 2C 20 74 65 6D 70 3D 30 2C 20 64 75 73 74 3D 35
33 2C 63 6F 3D 31 39 30 30 2C 63
00 FF FF 00 00 1C 00 64 6F 32 3D 35 39 32 0A 0A 0A 53 45 4E 44 3A 6C 65 64
30 3D 30 0A 6C 65 64 31 3D 31 0A
00 FF FF 00 00 1C 00 64 0A 0A 46 4F 52 20 53 45 52 49 41 4C 3A 7A 6F 6E 65
3D 31 2C 20 74 65 6D 70 3D 30 2C
00 FF FF 00 00 1C 00 64 20 64 75 73 74 3D 35 33 2C 63 6F 3D 31 39 30 30 2C
63 6F 32 3D 35 39 32 0A 0A 21 21
00 FF FF 00 00 1C 00 64 21 4D 45 53 53 41 47 45 20 53 45 4E 54 21 21 21 0A
0A 21 21 21 4D 45 53 53 41 47 45
00 FF FF 00 00 1C 00 64 20 53 45 4E 54 20 54 4F 20 53 45 52 49 41 4C 20 50
4F 52 54 21 21 21 0A 00 00 00 00
That does not seem correct, since the MineMsg is small:
typedef nx_struct mine_msg{
nx_int16_t id;
nx_int16_t d;
nx_int16_t c;
nx_int16_t c2;
nx_int16_t t;
} MineMsg;
and also it's payload should be different every second. Any ideas what do I
do wrong? I am on tinyos -2.1.0.
Thank you all in advance!
Georgia
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help