Hi all!
In my program, I modified the application in the Tutorial Lesson 7. I have to program 3 motes, one mote as a source node that transmits packet at fixed interval of time, one node as a relay node (it just forward whatever packet it receives) and one node as base station that read packet from both the source node and relay node (TosBase). I use Listen.java to read packet from the base station. However, I have a problem that I myself can not explain.
When I start running my program, by using Listen.java I can see packet from the source node, but not from the relay node. However, when I turn off and after that turn on the switch of the relay node by manual I can see both packets from the source node and the relay node but the green led does not toggle (In my program, I want the green led at the relay node toggle whenever it receive new packet).
Here is my program for Relay
node:
includes MyMsg;
module RelayM {
provides interface StdControl;
uses {
interface Leds;
interface ReceiveMsg as ReceiveCmdMsg;
interface SendMsg as SendCmdMsg;
interface StdControl as CommControl;
}
}
provides interface StdControl;
uses {
interface Leds;
interface ReceiveMsg as ReceiveCmdMsg;
interface SendMsg as SendCmdMsg;
interface StdControl as CommControl;
}
}
implementation
{
{
enum {
QUEUE_LENGTH = 5
};
QUEUE_LENGTH = 5
};
TOS_MsgPtr msg;
int8_t bcast_pending;
TOS_Msg buf;
uint8_t i, currentqueue;
uint16_t queue[QUEUE_LENGTH];
int8_t bcast_pending;
TOS_Msg buf;
uint8_t i, currentqueue;
uint16_t queue[QUEUE_LENGTH];
task void forwarder() {
call SendCmdMsg.send(TOS_BCAST_ADDR, sizeof(MyMsg), msg);
}
event result_t SendCmdMsg.sendDone(TOS_MsgPtr pmsg, result_t status) {
if (status == SUCCESS) bcast_pending = 0;
return status;
}
call SendCmdMsg.send(TOS_BCAST_ADDR, sizeof(MyMsg), msg);
}
event result_t SendCmdMsg.sendDone(TOS_MsgPtr pmsg, result_t status) {
if (status == SUCCESS) bcast_pending = 0;
return status;
}
command result_t StdControl.init() {
msg = &buf;
bcast_pending = 0;
currentqueue=0;
for(i=0; i<QUEUE_LENGTH; i++) queue[i] = 10000;
return (call CommControl.init());
}
msg = &buf;
bcast_pending = 0;
currentqueue=0;
for(i=0; i<QUEUE_LENGTH; i++) queue[i] = 10000;
return (call CommControl.init());
}
command result_t StdControl.start(){
return (call CommControl.start());
}
command result_t StdControl.stop(){
return (call CommControl.stop());
}
inline char is_new_msg(struct MyMsg *bmsg) {
if (bcast_pending) return 0;
for (i=0; i<QUEUE_LENGTH; i++) {
if ((bmsg->seqno) == queue[i]) return 0;
else {
queue[currentqueue++]= bmsg->seqno;
if ( currentqueue == QUEUE_LENGTH) currentqueue=0;
return 1;
}
}
}
if (bcast_pending) return 0;
for (i=0; i<QUEUE_LENGTH; i++) {
if ((bmsg->seqno) == queue[i]) return 0;
else {
queue[currentqueue++]= bmsg->seqno;
if ( currentqueue == QUEUE_LENGTH) currentqueue=0;
return 1;
}
}
}
inline void remember_msg(struct MyMsg *bmsg) {
bcast_pending = 1;
}
}
event TOS_MsgPtr ReceiveCmdMsg.receive(TOS_MsgPtr pmsg){
TOS_MsgPtr ret = msg;
struct MyMsg *data= "" MyMsg *)pmsg->data;
call Leds.greenToggle();
if (is_new_msg(data)) {
remember_msg(data);
data->hop_count++;
data->source = TOS_LOCAL_ADDRESS;
ret = msg;
msg = pmsg;
post forwarder();
}
return ret;
}
} // end of implementation
TOS_MsgPtr ret = msg;
struct MyMsg *data= "" MyMsg *)pmsg->data;
call Leds.greenToggle();
if (is_new_msg(data)) {
remember_msg(data);
data->hop_count++;
data->source = TOS_LOCAL_ADDRESS;
ret = msg;
msg = pmsg;
post forwarder();
}
return ret;
}
} // end of implementation
Could any body help me with this trouble?
Many thanks!
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.
_______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
