dbg_clear("App", "\n");
}
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 (out == NULL || call Packet.payloadLength(&uartbuf) != sizeof(oscilloscope_t)) {
return msg;
}
else {
}
//Prepare message to be sent over the uart
- out = (oscilloscope_t*)call SerialSend.getPayload(newmsg);
+ out = (oscilloscope_t*)call SerialSend.getPayload(newmsg, sizeof(oscilloscope_t));
+ if (out == NULL) {
+ return;
+ }
memcpy(out, in, sizeof(oscilloscope_t));
if (call UARTQueue.enqueue(newmsg) != SUCCESS) {
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) {
+ return;
+ }
memcpy(o, &local, sizeof(local));
if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS) {
dbg("App", "Sending a packet.\n");