X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2FMultihopOscilloscope%2FMultihopOscilloscopeC.nc;h=5179b3500d46aa8a37c9c3ba2a40a0e1a22d8687;hb=2209f8d2cb9ae1b6c268532e99a374533eb8fa78;hp=fff54d7ca7bc5f9988dd17022332573ed6845f9d;hpb=1a329382c4f4556fd52d85f4e3f4a67e54911682;p=tinyos-2.x.git diff --git a/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc b/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc index fff54d7c..5179b350 100644 --- a/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc +++ b/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc @@ -19,7 +19,7 @@ #include "Timer.h" #include "MultihopOscilloscope.h" -module MultihopOscilloscopeC { +module MultihopOscilloscopeC @safe(){ uses { // Interfaces for initialization: interface Boot; @@ -128,8 +128,8 @@ implementation { oscilloscope_t* in = (oscilloscope_t*)payload; oscilloscope_t* out; if (uartbusy == FALSE) { - out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf); - if (len != sizeof(oscilloscope_t)) { + out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf, sizeof(oscilloscope_t)); + if (len != sizeof(oscilloscope_t) || out == NULL) { return msg; } else { @@ -147,8 +147,11 @@ implementation { return msg; } - //Prepare message to be sent over the uart - out = (oscilloscope_t*)call SerialSend.getPayload(newmsg); + //Serial port busy, so enqueue. + out = (oscilloscope_t*)call SerialSend.getPayload(newmsg, sizeof(oscilloscope_t)); + if (out == NULL) { + return msg; + } memcpy(out, in, sizeof(oscilloscope_t)); if (call UARTQueue.enqueue(newmsg) != SUCCESS) { @@ -224,7 +227,11 @@ implementation { event void Timer.fired() { if (reading == NREADINGS) { if (!sendbusy) { - oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf); + oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf, sizeof(oscilloscope_t)); + if (o == NULL) { + fatal_problem(); + return; + } memcpy(o, &local, sizeof(local)); if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS) sendbusy = TRUE;