[Tinyos-commits] CVS: tinyos-1.x/apps/TOSBase Makefile, 1.3,
1.4 README, 1.3, 1.4 TOSBaseM.nc, 1.8, 1.9
Gilman Tolle
gtolle at users.sourceforge.net
Thu Jul 14 10:48:58 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/apps/TOSBase
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30740
Modified Files:
Makefile README TOSBaseM.nc
Log Message:
Several improvements to the TOSBase bridge application:
* Replaced buffer-swapping queues with buffer-copying queues. This
works around a buffer-swapping bug in the CC2420 radio stack that we
have been unable to pin down and fix. This change does fix the bug
that causes the TOSBase to return 0-length packets under heavy
load. Using memcpy instead of buffer swapping does not appear to
impose a noticeable performance penalty.
* Fixed the bug discovered by Michael Newman, in which
PROTO_PACKET_NOACK packets are not bridged from UART to Radio.
* Increased the size of the task queue to lower the chance of a post
failure.
Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/apps/TOSBase/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile 7 Oct 2003 21:45:12 -0000 1.3
--- Makefile 14 Jul 2005 17:48:56 -0000 1.4
***************
*** 1,3 ****
--- 1,4 ----
COMPONENT=TOSBase
+ CFLAGS += -DTOSH_MAX_TASKS_LOG2=8
include ../Makerules
Index: README
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/apps/TOSBase/README,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** README 9 Nov 2004 19:19:22 -0000 1.3
--- README 14 Jul 2005 17:48:56 -0000 1.4
***************
*** 35,42 ****
As always, a task post failure somewhere in the serial or radio stacks
! may cause the TOSBase to hang.
!
! Under heavy load, 0-length packets, or packets with the wrong length
! may be sent on the serial link. This is known, and most likely resides
! in the radio stack, but has not yet been debugged.
!
--- 35,39 ----
As always, a task post failure somewhere in the serial or radio stacks
! may cause the TOSBase to hang. The chance of this is lessened by
! including the CFLAGS += -DTOSH_MAX_TASKS_LOG2=8 line in the TOSBase
! Makefile, incleasing the size of the task queue to 256.
Index: TOSBaseM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/apps/TOSBase/TOSBaseM.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** TOSBaseM.nc 23 May 2005 22:24:39 -0000 1.8
--- TOSBaseM.nc 14 Jul 2005 17:48:56 -0000 1.9
***************
*** 71,82 ****
TOS_Msg uartQueueBufs[UART_QUEUE_LEN];
- TOS_MsgPtr uartQueue[UART_QUEUE_LEN];
uint8_t uartIn, uartOut;
! bool uartBusy, uartFull;
TOS_Msg radioQueueBufs[RADIO_QUEUE_LEN];
- TOS_MsgPtr radioQueue[RADIO_QUEUE_LEN];
uint8_t radioIn, radioOut;
! bool radioBusy, radioFull;
task void UARTSendTask();
--- 71,80 ----
TOS_Msg uartQueueBufs[UART_QUEUE_LEN];
uint8_t uartIn, uartOut;
! bool uartBusy, uartCount;
TOS_Msg radioQueueBufs[RADIO_QUEUE_LEN];
uint8_t radioIn, radioOut;
! bool radioBusy, radioCount;
task void UARTSendTask();
***************
*** 85,106 ****
void failBlink();
void dropBlink();
command result_t StdControl.init() {
result_t ok1, ok2, ok3;
- uint8_t i;
! for (i = 0; i < UART_QUEUE_LEN; i++) {
! uartQueue[i] = &uartQueueBufs[i];
! }
! uartIn = uartOut = 0;
uartBusy = FALSE;
- uartFull = FALSE;
! for (i = 0; i < RADIO_QUEUE_LEN; i++) {
! radioQueue[i] = &radioQueueBufs[i];
! }
! radioIn = radioOut = 0;
radioBusy = FALSE;
- radioFull = FALSE;
ok1 = call UARTControl.init();
--- 83,96 ----
void failBlink();
void dropBlink();
+ void processUartPacket(TOS_MsgPtr Msg, bool wantsAck, uint8_t Token);
command result_t StdControl.init() {
result_t ok1, ok2, ok3;
! uartIn = uartOut = uartCount = 0;
uartBusy = FALSE;
! radioIn = radioOut = radioCount = 0;
radioBusy = FALSE;
ok1 = call UARTControl.init();
***************
*** 132,136 ****
event TOS_MsgPtr RadioReceive.receive(TOS_MsgPtr Msg) {
- TOS_MsgPtr pBuf = Msg;
dbg(DBG_USR1, "TOSBase received radio packet.\n");
--- 122,125 ----
***************
*** 139,186 ****
return Msg;
! atomic {
! if (!uartFull) {
! pBuf = uartQueue[uartIn];
! uartQueue[uartIn] = Msg;
!
! if( ++uartIn >= UART_QUEUE_LEN ) uartIn = 0;
!
! if (uartIn == uartOut) {
! uartFull = TRUE;
! }
! if (!uartBusy) {
! if (post UARTSendTask()) {
! uartBusy = TRUE;
! }
}
- } else {
- dropBlink();
}
}
! return pBuf;
}
task void UARTSendTask() {
- bool noWork = FALSE;
-
dbg (DBG_USR1, "TOSBase forwarding Radio packet to UART\n");
! atomic {
! if (uartIn == uartOut && uartFull == FALSE) {
! uartBusy = FALSE;
! noWork = TRUE;
! }
! }
! if (noWork) {
! return;
! }
- if (call UARTSend.send(uartQueue[uartOut]) == SUCCESS) {
- call Leds.greenToggle();
} else {
! failBlink();
! post UARTSendTask();
}
}
--- 128,165 ----
return Msg;
! if (uartCount < UART_QUEUE_LEN) {
! memcpy(&uartQueueBufs[uartIn], Msg, sizeof(TOS_Msg));
! uartCount++;
!
! if( ++uartIn >= UART_QUEUE_LEN ) uartIn = 0;
!
! if (!uartBusy) {
! if (post UARTSendTask()) {
! uartBusy = TRUE;
}
}
+ } else {
+ dropBlink();
}
! return Msg;
}
task void UARTSendTask() {
dbg (DBG_USR1, "TOSBase forwarding Radio packet to UART\n");
! if (uartCount == 0) {
!
! uartBusy = FALSE;
} else {
!
! if (call UARTSend.send(&uartQueueBufs[uartOut]) == SUCCESS) {
! call Leds.greenToggle();
! } else {
! failBlink();
! post UARTSendTask();
! }
}
}
***************
*** 191,205 ****
failBlink();
} else {
!
! atomic {
! if (msg == uartQueue[uartOut]) {
! if( ++uartOut >= UART_QUEUE_LEN ) uartOut = 0;
! if (uartFull) {
! uartFull = FALSE;
! }
! }
! }
}
!
post UARTSendTask();
--- 170,177 ----
failBlink();
} else {
! uartCount--;
! if( ++uartOut >= UART_QUEUE_LEN ) uartOut = 0;
}
!
post UARTSendTask();
***************
*** 208,268 ****
event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr Msg) {
return Msg;
}
event TOS_MsgPtr UARTTokenReceive.receive(TOS_MsgPtr Msg, uint8_t Token) {
! TOS_MsgPtr pBuf = Msg;
bool reflectToken = FALSE;
dbg(DBG_USR1, "TOSBase received UART token packet.\n");
! atomic {
! if (!radioFull) {
! reflectToken = TRUE;
! pBuf = radioQueue[radioIn];
! radioQueue[radioIn] = Msg;
! if( ++radioIn >= RADIO_QUEUE_LEN ) radioIn = 0;
! if (radioIn == radioOut)
! radioFull = TRUE;
! if (!radioBusy) {
! if (post RadioSendTask()) {
! radioBusy = TRUE;
! }
}
- } else {
- dropBlink();
}
}
! if (reflectToken) {
call UARTTokenReceive.ReflectToken(Token);
}
-
- return pBuf;
}
task void RadioSendTask() {
! bool noWork = FALSE;
! dbg (DBG_USR1, "TOSBase forwarding UART packet to Radio\n");
! atomic {
! if (radioIn == radioOut && radioFull == FALSE) {
! radioBusy = FALSE;
! noWork = TRUE;
! }
! }
! if (noWork)
! return;
- radioQueue[radioOut]->group = TOS_AM_GROUP;
-
- if (call RadioSend.send(radioQueue[radioOut]) == SUCCESS) {
- call Leds.redToggle();
} else {
! failBlink();
! post RadioSendTask();
}
}
--- 180,238 ----
event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr Msg) {
+ processUartPacket(Msg, FALSE, 0);
return Msg;
}
event TOS_MsgPtr UARTTokenReceive.receive(TOS_MsgPtr Msg, uint8_t Token) {
! processUartPacket(Msg, TRUE, Token);
! return Msg;
! }
!
! void processUartPacket(TOS_MsgPtr Msg, bool wantsAck, uint8_t Token) {
bool reflectToken = FALSE;
dbg(DBG_USR1, "TOSBase received UART token packet.\n");
! if (radioCount < RADIO_QUEUE_LEN) {
! reflectToken = TRUE;
! memcpy(&radioQueueBufs[radioIn], Msg, sizeof(TOS_Msg));
!
! radioCount++;
!
! if( ++radioIn >= RADIO_QUEUE_LEN ) radioIn = 0;
!
! if (!radioBusy) {
! if (post RadioSendTask()) {
! radioBusy = TRUE;
}
}
+ } else {
+ dropBlink();
}
! if (wantsAck && reflectToken) {
call UARTTokenReceive.ReflectToken(Token);
}
}
task void RadioSendTask() {
! dbg(DBG_USR1, "TOSBase forwarding UART packet to Radio\n");
! if (radioCount == 0) {
! radioBusy = FALSE;
} else {
!
! radioQueueBufs[radioOut].group = TOS_AM_GROUP;
!
! if (call RadioSend.send(&radioQueueBufs[radioOut]) == SUCCESS) {
! call Leds.redToggle();
! } else {
! failBlink();
! post RadioSendTask();
! }
}
}
***************
*** 273,283 ****
failBlink();
} else {
! atomic {
! if (msg == radioQueue[radioOut]) {
! if( ++radioOut >= RADIO_QUEUE_LEN ) radioOut = 0;
! if (radioFull)
! radioFull = FALSE;
! }
! }
}
--- 243,248 ----
failBlink();
} else {
! radioCount--;
! if( ++radioOut >= RADIO_QUEUE_LEN ) radioOut = 0;
}
More information about the Tinyos-commits
mailing list