From ea002ecd1bf3ec3937310352ede53480cea89485 Mon Sep 17 00:00:00 2001 From: klueska Date: Wed, 18 Jun 2008 14:48:56 +0000 Subject: [PATCH] Update to TestCollection apps for tosthreads to send correct payload for displaying sensor values --- apps/tosthreads/apps/TestBasicsbSensors/Makefile | 10 +++++++++- .../apps/TestCollection/TestCollectionC.nc | 12 +++++++----- .../tosthreads/capps/TestCollection/TestCollection.c | 5 ++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/tosthreads/apps/TestBasicsbSensors/Makefile b/apps/tosthreads/apps/TestBasicsbSensors/Makefile index 7580f0d4..eca2a88d 100644 --- a/apps/tosthreads/apps/TestBasicsbSensors/Makefile +++ b/apps/tosthreads/apps/TestBasicsbSensors/Makefile @@ -2,4 +2,12 @@ COMPONENT=TestBasicsbSensorsAppC CFLAGS += -I$(TOSDIR)/sensorboards/basicsb CFLAGS += -I$(TOSDIR)/lib/tosthreads/sensorboards/basicsb -include $(MAKERULES) +ifneq ($(filter mica2 micaz clean,$(MAKECMDGOALS)),) + include $(MAKERULES) +else +%: + @echo " Sorry, this application is only written to work with mica based motes and the basicsb sensorboards.." +threads: + @: +endif + diff --git a/apps/tosthreads/apps/TestCollection/TestCollectionC.nc b/apps/tosthreads/apps/TestCollection/TestCollectionC.nc index e401fc05..e49640ba 100644 --- a/apps/tosthreads/apps/TestCollection/TestCollectionC.nc +++ b/apps/tosthreads/apps/TestCollection/TestCollectionC.nc @@ -73,7 +73,10 @@ implementation { call RootControl.setRoot(); for (;;) { if (call BlockingReceive.receive(&recvbuf, 0) == SUCCESS) { - call SerialBlockingSend.send(AM_BROADCAST_ADDR, &recvbuf, sizeof(local)); + oscilloscope_t *recv_o = (oscilloscope_t *) call BlockingReceive.getPayload(&recvbuf, sizeof(oscilloscope_t)); + oscilloscope_t *send_o = (oscilloscope_t *) call SerialBlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); + memcpy(send_o, recv_o, sizeof(oscilloscope_t)); + call SerialBlockingSend.send(AM_BROADCAST_ADDR, &sendbuf, sizeof(oscilloscope_t)); report_received(); } } @@ -82,14 +85,13 @@ implementation { for (;;) { if (reading == NREADINGS) { - oscilloscope_t *o = o; - o = (oscilloscope_t *)call BlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); + oscilloscope_t *o = (oscilloscope_t *) call BlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); if (o == NULL) { fatal_problem(); return; } - memcpy(o, &local, sizeof(local)); - if (call BlockingSend.send(&sendbuf, sizeof(local)) == SUCCESS) { + memcpy(o, &local, sizeof(oscilloscope_t)); + if (call BlockingSend.send(&sendbuf, sizeof(oscilloscope_t)) == SUCCESS) { report_sent(); } else { report_problem(); diff --git a/apps/tosthreads/capps/TestCollection/TestCollection.c b/apps/tosthreads/capps/TestCollection/TestCollection.c index f0b417fb..75da7287 100644 --- a/apps/tosthreads/capps/TestCollection/TestCollection.c +++ b/apps/tosthreads/capps/TestCollection/TestCollection.c @@ -64,7 +64,10 @@ void tosthread_main(void* arg) { collectionSetRoot(); for (;;) { if ( collectionReceive(&recvbuf, 0, AM_OSCILLOSCOPE) == SUCCESS) { - amSerialSend(AM_BROADCAST_ADDR, &recvbuf, sizeof(local), AM_OSCILLOSCOPE); + oscilloscope_t *recv_o = (oscilloscope_t *) collectionGetPayload(&recvbuf, sizeof(oscilloscope_t)); + oscilloscope_t *send_o = (oscilloscope_t *) serialGetPayload(&sendbuf, sizeof(oscilloscope_t)); + memcpy(send_o, recv_o, sizeof(oscilloscope_t)); + amSerialSend(AM_BROADCAST_ADDR, &sendbuf, sizeof(local), AM_OSCILLOSCOPE); report_received(); } } -- 2.39.2