[Tinyos-2-commits] CVS: tinyos-2.x/apps/MultihopOscilloscope
MultihopOscilloscopeAppC.nc, 1.1.2.3,
1.1.2.4 MultihopOscilloscopeC.nc, 1.1.2.4, 1.1.2.5
Kyle Jamieson
kasj78 at users.sourceforge.net
Wed Nov 1 18:29:33 PST 2006
Update of /cvsroot/tinyos/tinyos-2.x/apps/MultihopOscilloscope
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23391
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
MultihopOscilloscopeAppC.nc MultihopOscilloscopeC.nc
Log Message:
Added application-level queue for sending to the UART at the root.
Index: MultihopOscilloscopeAppC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/MultihopOscilloscope/MultihopOscilloscopeAppC.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** MultihopOscilloscopeAppC.nc 11 Sep 2006 12:11:59 -0000 1.1.2.3
--- MultihopOscilloscopeAppC.nc 2 Nov 2006 02:29:31 -0000 1.1.2.4
***************
*** 49,52 ****
--- 49,58 ----
MultihopOscilloscopeC.RootControl -> Collector;
+ components new PoolC(message_t, 10) as UARTMessagePoolP,
+ new QueueC(message_t*, 10) as UARTQueueP;
+
+ MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
+ MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
+
//
// Components for debugging collection.
Index: MultihopOscilloscopeC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** MultihopOscilloscopeC.nc 31 Oct 2006 23:00:53 -0000 1.1.2.4
--- MultihopOscilloscopeC.nc 2 Nov 2006 02:29:31 -0000 1.1.2.5
***************
*** 36,39 ****
--- 36,42 ----
interface RootControl;
+ interface Queue<message_t *> as UARTQueue;
+ interface Pool<message_t> as UARTMessagePool;
+
// Miscalleny:
interface Timer<TMilli>;
***************
*** 131,137 ****
memcpy(out, in, sizeof(oscilloscope_t));
}
- uartbusy = TRUE;
uartlen = sizeof(oscilloscope_t);
post uartSendTask();
}
--- 134,159 ----
memcpy(out, in, sizeof(oscilloscope_t));
}
uartlen = sizeof(oscilloscope_t);
post uartSendTask();
+ } else {
+ // The UART is busy; queue up messages and service them when the
+ // UART becomes free.
+ message_t *newmsg = call UARTMessagePool.get();
+ if (newmsg == NULL) {
+ // drop the message on the floor if we run out of queue space.
+ report_problem();
+ return msg;
+ }
+
+ memcpy(newmsg, msg, sizeof(message_t));
+
+ if (call UARTQueue.enqueue(newmsg) != SUCCESS) {
+ // drop the message on the floor and hang if we run out of
+ // queue space without running out of queue space first (this
+ // should not occur).
+ call UARTMessagePool.put(newmsg);
+ fatal_problem();
+ return msg;
+ }
}
***************
*** 141,147 ****
task void uartSendTask() {
if (call SerialSend.send(0xffff, &uartbuf, uartlen) != SUCCESS) {
! uartbusy = FALSE;
}
}
//
// Overhearing other traffic in the network.
--- 163,191 ----
task void uartSendTask() {
if (call SerialSend.send(0xffff, &uartbuf, uartlen) != SUCCESS) {
! report_problem();
! } else {
! uartbusy = TRUE;
! }
! }
!
! event void SerialSend.sendDone(message_t *msg, error_t error) {
! uartbusy = FALSE;
! if (call UARTQueue.empty() == FALSE) {
! // We just finished a UART send, and the uart queue is
! // non-empty. Let's start a new one.
! message_t *queuemsg = call UARTQueue.dequeue();
! if (queuemsg == NULL) {
! fatal_problem();
! return;
! }
! memcpy(&uartbuf, queuemsg, sizeof(message_t));
! if (call UARTMessagePool.put(queuemsg) != SUCCESS) {
! fatal_problem();
! return;
! }
! post uartSendTask();
}
}
+
//
// Overhearing other traffic in the network.
***************
*** 215,222 ****
}
- event void SerialSend.sendDone(message_t *msg, error_t error) {
- uartbusy = FALSE;
- }
-
// Use LEDs to report various status issues.
static void fatal_problem() {
--- 259,262 ----
More information about the Tinyos-2-commits
mailing list