]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Low Power Sensing Application initial checkin
authorklueska <klueska>
Mon, 3 Sep 2007 22:46:35 +0000 (22:46 +0000)
committerklueska <klueska>
Mon, 3 Sep 2007 22:46:35 +0000 (22:46 +0000)
35 files changed:
apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseAppC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Base/Makefile [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Base/volumes-at45db.xml [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Base/volumes-stm25p.xml [new file with mode: 0644]
apps/tutorials/LowPowerSensing/LowPowerSensingConstants.h [new file with mode: 0644]
apps/tutorials/LowPowerSensing/LowPowerSensingMsgs.h [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerAppC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Sampler/Makefile [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Sampler/volumes-at45db.xml [new file with mode: 0644]
apps/tutorials/LowPowerSensing/Sampler/volumes-stm25p.xml [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/Constants.class [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/Constants.java [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.class [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.jar [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.java [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/Makefile [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.class [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.java [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/SerialSampleMsg.class [new file with mode: 0644]
apps/tutorials/LowPowerSensing/java/SerialSampleMsg.java [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/GenericSensorSample.h [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLogger16C.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLoggerP.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/SampleLogRead.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderP.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/sampleLog/SampleNxConverter.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SampleNxConverterC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SamplePeriodicLogC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SensorSample.h [new file with mode: 0644]
apps/tutorials/LowPowerSensing/universal_sensors/SampleNxConverterC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/universal_sensors/SamplePeriodicLogC.nc [new file with mode: 0644]
apps/tutorials/LowPowerSensing/universal_sensors/SensorSample.h [new file with mode: 0644]

diff --git a/apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseAppC.nc b/apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseAppC.nc
new file mode 100644 (file)
index 0000000..4dfd958
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "LowPowerSensingConstants.h"
+configuration LowPowerSensingBaseAppC{}
+implementation {
+  components MainC, LowPowerSensingBaseC as App;
+  components new QueueC(message_t, MSG_QUEUE_SIZE) as Queue;
+  components LedsC;
+  MainC.Boot <- App;
+  App.MsgQueue -> Queue;
+  App.Leds -> LedsC;
+
+  components SerialActiveMessageC as Serial;
+  App.SerialAMControl -> Serial;
+  App.SerialAMPacket -> Serial;
+  App.SerialPacket -> Serial;
+
+  components ActiveMessageC as Radio;
+  App.RadioAMControl -> Radio;
+  App.RadioAMPacket -> Radio;
+  App.RadioPacket -> Radio;
+
+  components new SerialAMReceiverC(AM_SERIAL_REQUEST_SAMPLES_MSG) as SerialRequestSampleMsgsReceiver;
+  components new AMSenderC(AM_REQUEST_SAMPLES_MSG) as RadioRequestSampleMsgsSender;
+  App.SerialRequestSampleMsgsReceive -> SerialRequestSampleMsgsReceiver;
+  App.RadioRequestSampleMsgsSend -> RadioRequestSampleMsgsSender;
+
+  components new AMReceiverC(AM_SAMPLE_MSG) as RadioSampleMsgReceiver;
+  components new SerialAMSenderC(AM_SERIAL_SAMPLE_MSG) as SerialSampleMsgSender;
+  App.RadioSampleMsgReceive -> RadioSampleMsgReceiver;
+  App.SerialSampleMsgSend -> SerialSampleMsgSender;
+
+//Nasty hack since no uniform way of prividing LPL support as of yet
+#if defined(PLATFORM_TELOSB) || defined(PLATFORM_TMOTE) || defined(PLATFORM_MICAZ)
+  components CC2420ActiveMessageC as LPLProvider;
+  App.LPL -> LPLProvider;
+#endif
+
+#if defined(PLATFORM_MICA2)
+  components CC1000CsmaRadioC as LPLProvider;
+  App.LPL -> LPLProvider;
+#endif
+}
+
diff --git a/apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseC.nc b/apps/tutorials/LowPowerSensing/Base/LowPowerSensingBaseC.nc
new file mode 100644 (file)
index 0000000..919b7a6
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+#include "LowPowerSensingConstants.h"
+module LowPowerSensingBaseC {
+  uses {
+    interface Boot;
+    interface Queue<message_t> as MsgQueue;
+    interface Leds;
+    interface LowPowerListening as LPL;
+
+    interface SplitControl as SerialAMControl;
+    interface AMPacket as SerialAMPacket;
+    interface Packet as SerialPacket;
+
+    interface SplitControl as RadioAMControl;
+    interface AMPacket as RadioAMPacket;
+    interface Packet as RadioPacket;
+
+    interface Receive as SerialRequestSampleMsgsReceive;
+    interface AMSend as RadioRequestSampleMsgsSend;
+    interface Receive as RadioSampleMsgReceive;
+    interface AMSend as SerialSampleMsgSend;
+  }
+}
+implementation {
+  bool serialSending;
+  am_addr_t dest_addr;
+  message_t request_samples_msg;
+  message_t sample_msg;
+  serial_sample_msg_t* sample_msg_payload;
+
+  event void Boot.booted() {
+    serialSending = FALSE;
+    sample_msg_payload = (serial_sample_msg_t*)call SerialPacket.getPayload(&sample_msg, NULL);
+    call RadioAMControl.start();
+  }
+  
+  event void RadioAMControl.startDone(error_t error) {
+    call SerialAMControl.start();
+  }
+
+  event void SerialAMControl.startDone(error_t error) {
+  }
+
+  event void RadioAMControl.stopDone(error_t error) {
+  }
+
+  event void SerialAMControl.stopDone(error_t error) {
+  }
+
+  event message_t* SerialRequestSampleMsgsReceive.receive(message_t* msg, void* payload, uint8_t len) {
+    serial_request_samples_msg_t* request_msg = payload;
+    call Leds.led0On();
+    call LPL.setRxSleepInterval(&request_samples_msg, LPL_INTERVAL+100);
+    call RadioRequestSampleMsgsSend.send(request_msg->addr, &request_samples_msg, sizeof(request_samples_msg_t));
+    return msg;
+  }
+
+  event void RadioRequestSampleMsgsSend.sendDone(message_t* msg, error_t error) {
+    if(error == SUCCESS)
+      call Leds.led0Off();
+  }
+
+  event message_t* RadioSampleMsgReceive.receive(message_t* msg, void* payload, uint8_t len) {
+    call Leds.led2Toggle();
+    if(call MsgQueue.empty() == FALSE || serialSending == TRUE)
+      call MsgQueue.enqueue(*msg);
+    else {
+      sample_msg_payload->src_addr = call RadioAMPacket.source(msg);
+      sample_msg_payload->sample = *((nx_sensor_sample_t*)payload);
+      dest_addr = call SerialAMPacket.destination(msg); 
+      serialSending = TRUE;
+      call SerialSampleMsgSend.send(dest_addr, &sample_msg, sizeof(*sample_msg_payload));
+    }
+    return msg;
+  }
+
+  event void SerialSampleMsgSend.sendDone(message_t* msg, error_t error) {
+    if(call MsgQueue.empty() == FALSE) {
+      sample_msg = call MsgQueue.dequeue();
+      dest_addr = call SerialAMPacket.destination(msg);
+      call SerialSampleMsgSend.send(dest_addr, &sample_msg, sizeof(serial_sample_msg_t));
+    }
+    else serialSending = FALSE;
+  }
+}
+
diff --git a/apps/tutorials/LowPowerSensing/Base/Makefile b/apps/tutorials/LowPowerSensing/Base/Makefile
new file mode 100644 (file)
index 0000000..4e1481a
--- /dev/null
@@ -0,0 +1,5 @@
+COMPONENT=LowPowerSensingBaseAppC
+CFLAGS += -I.. -I../universal_sensors
+CFLAGS += -DCC1K_DEFAULT_FREQ=CC1K_914_077_MHZ
+
+include $(MAKERULES)
diff --git a/apps/tutorials/LowPowerSensing/Base/volumes-at45db.xml b/apps/tutorials/LowPowerSensing/Base/volumes-at45db.xml
new file mode 100644 (file)
index 0000000..105e58a
--- /dev/null
@@ -0,0 +1,3 @@
+<volume_table>
+  <volume name="SENSOR_SAMPLES" size="262144"/>
+</volume_table>
diff --git a/apps/tutorials/LowPowerSensing/Base/volumes-stm25p.xml b/apps/tutorials/LowPowerSensing/Base/volumes-stm25p.xml
new file mode 100644 (file)
index 0000000..64dfc4c
--- /dev/null
@@ -0,0 +1,3 @@
+<volume_table>
+  <volume name="DATALOG" size="786432"/>
+</volume_table>
diff --git a/apps/tutorials/LowPowerSensing/LowPowerSensingConstants.h b/apps/tutorials/LowPowerSensing/LowPowerSensingConstants.h
new file mode 100644 (file)
index 0000000..a0687f4
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#ifndef LOWPOWERSENSINGCONSTANTS_H
+#define LOWPOWERSENSINGCONSTANTS_H
+
+#ifndef LOWPOWERSENSING_JAVA_MAKEFILE
+#include "StorageVolumes.h"
+#endif
+#include "LowPowerSensingMsgs.h"
+
+#define LOW_POWER_LISTENING
+enum {
+  LPL_INTERVAL       = 2000,
+  SAMPLING_INTERVAL     = 3000,
+  MSG_QUEUE_SIZE     = 50,
+  BASE_STATION_ADDR     = 0,
+};
+#endif //LOWPOWERSENSINGCONSTANTS_H
+
diff --git a/apps/tutorials/LowPowerSensing/LowPowerSensingMsgs.h b/apps/tutorials/LowPowerSensing/LowPowerSensingMsgs.h
new file mode 100644 (file)
index 0000000..0fcc191
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#ifndef LOWPOWERSENSINGMSGS_H
+#define LOWPOWERSENSINGMSGS_H
+
+#include "message.h"
+#include "SensorSample.h"
+
+enum {
+  AM_SERIAL_REQUEST_SAMPLES_MSG         = 0x92,
+  AM_REQUEST_SAMPLES_MSG                = 0x93,
+
+  AM_SAMPLE_MSG                         = 0x98,
+  AM_SERIAL_SAMPLE_MSG                  = 0x99,
+};
+
+typedef nx_struct serial_request_samples_msg {
+  nx_am_addr_t addr;
+  nx_uint32_t sample_num;
+} serial_request_samples_msg_t;
+
+typedef nx_struct request_samples_msg {
+} request_samples_msg_t;
+
+typedef  nx_struct sample_msg {
+  nx_sensor_sample_t sample;
+} sample_msg_t;
+
+typedef  nx_struct serial_sample_msg {
+  nx_am_addr_t  src_addr;
+  nx_sensor_sample_t sample;
+} serial_sample_msg_t;
+
+#endif //LOWPOWERSENSINGMSGS_H
+
diff --git a/apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerAppC.nc b/apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerAppC.nc
new file mode 100644 (file)
index 0000000..4a48684
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "LowPowerSensingConstants.h"
+#include "SensorSample.h"
+configuration LowPowerSensingPeriodicSamplerAppC {}
+implementation {
+  components new SamplePeriodicLogC(SAMPLING_INTERVAL, VOLUME_SENSOR_SAMPLES);
+  components MainC, LowPowerSensingPeriodicSamplerC as App;
+  components SampleNxConverterC;
+  MainC.Boot <- App;
+  App.SampleLogRead -> SamplePeriodicLogC;
+  App.SampleNxConverter -> SampleNxConverterC;
+
+  components ActiveMessageC;
+  App.AMControl -> ActiveMessageC;
+  App.AMPacket -> ActiveMessageC;
+  App.Packet -> ActiveMessageC;
+
+  components new AMSenderC(AM_SAMPLE_MSG) as SampleSender;
+  App.SampleSend -> SampleSender;
+
+  components new AMReceiverC(AM_REQUEST_SAMPLES_MSG) as RequestSamplesReceiver;
+  App.RequestSamplesReceive -> RequestSamplesReceiver;
+
+  components LedsC as LedsC;
+  App.Leds -> LedsC;
+
+//Nasty hack since no uniform way of prividing LPL support as of yet
+#if defined(PLATFORM_TELOSB) || defined(PLATFORM_TMOTE) || defined(PLATFORM_MICAZ)
+  components CC2420ActiveMessageC as LPLProvider;
+  App.LPL -> LPLProvider;
+#endif
+
+#if defined(PLATFORM_MICA2)
+  components CC1000CsmaRadioC as LPLProvider;
+  App.LPL -> LPLProvider;
+#endif
+}
+
diff --git a/apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerC.nc b/apps/tutorials/LowPowerSensing/Sampler/LowPowerSensingPeriodicSamplerC.nc
new file mode 100644 (file)
index 0000000..17a1b1e
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "LowPowerSensingConstants.h"
+#include "SensorSample.h"
+module LowPowerSensingPeriodicSamplerC {
+  uses {
+    interface Boot;
+    interface SampleLogRead<sensor_sample_t>;
+    interface SampleNxConverter;
+    interface Leds;
+    interface SplitControl as AMControl;
+    interface AMPacket;
+    interface Packet;
+    interface AMSend as SampleSend;
+    interface Receive as RequestSamplesReceive;
+    interface LowPowerListening as LPL;
+  }
+}
+implementation {
+  message_t sample_msg;
+  bool sendBusy = FALSE;
+
+  task void readNextTask();
+  task void sendSampleMsgTask();
+
+  void readNext() {
+    error_t error = call SampleLogRead.readNext();
+    if(error == FAIL)
+      post readNextTask();
+    else if(error == ECANCEL) {
+      sendBusy = FALSE;
+      call Leds.led1Toggle();
+    }
+  }
+  
+  void sendSampleMsg() {
+    call LPL.setRxSleepInterval(&sample_msg, 0);
+    if(call SampleSend.send(BASE_STATION_ADDR, &sample_msg, sizeof(nx_sensor_sample_t)) != SUCCESS)
+      post sendSampleMsgTask();
+    else call Leds.led2On();
+  }
+  
+  task void readNextTask() { readNext(); }
+  task void sendSampleMsgTask() { sendSampleMsg(); }
+       
+  event void Boot.booted() {
+    call LPL.setLocalSleepInterval(LPL_INTERVAL);
+    call AMControl.start();
+  }
+  
+  event void AMControl.startDone(error_t e) {
+       if(e != SUCCESS)
+               call AMControl.start();
+  }
+  
+  event void AMControl.stopDone(error_t e) {
+  }
+  
+  event void SampleLogRead.readDone(sensor_sample_t* sample, error_t error) {
+    if(error == SUCCESS) {
+      nx_sensor_sample_t* nx_sample = call SampleSend.getPayload(&sample_msg);
+      call SampleNxConverter.copyToNx(nx_sample, sample);
+      sendSampleMsg();
+    }
+    else post readNextTask();
+  }
+
+  event message_t* RequestSamplesReceive.receive(message_t* msg, void* payload, uint8_t len) {
+    call Leds.led0Toggle();
+    if(sendBusy == FALSE) {
+      sendBusy = TRUE;
+      readNext();
+    }
+    return msg;
+  }
+
+  event void SampleSend.sendDone(message_t* msg, error_t error) {
+    if(error != SUCCESS)
+      post sendSampleMsgTask();
+    else {
+      call Leds.led2Off();
+      readNext();
+    }
+  }
+}
diff --git a/apps/tutorials/LowPowerSensing/Sampler/Makefile b/apps/tutorials/LowPowerSensing/Sampler/Makefile
new file mode 100644 (file)
index 0000000..b77d82a
--- /dev/null
@@ -0,0 +1,5 @@
+COMPONENT=LowPowerSensingPeriodicSamplerAppC
+CFLAGS += -I.. -I../sampleLog -I../universal_sensors
+CFLAGS += -DCC1K_DEFAULT_FREQ=CC1K_914_077_MHZ
+
+include $(MAKERULES)
diff --git a/apps/tutorials/LowPowerSensing/Sampler/volumes-at45db.xml b/apps/tutorials/LowPowerSensing/Sampler/volumes-at45db.xml
new file mode 100644 (file)
index 0000000..105e58a
--- /dev/null
@@ -0,0 +1,3 @@
+<volume_table>
+  <volume name="SENSOR_SAMPLES" size="262144"/>
+</volume_table>
diff --git a/apps/tutorials/LowPowerSensing/Sampler/volumes-stm25p.xml b/apps/tutorials/LowPowerSensing/Sampler/volumes-stm25p.xml
new file mode 100644 (file)
index 0000000..73ed485
--- /dev/null
@@ -0,0 +1,3 @@
+<volume_table>
+  <volume name="SENSOR_SAMPLES" size="786432"/>
+</volume_table>
diff --git a/apps/tutorials/LowPowerSensing/java/Constants.class b/apps/tutorials/LowPowerSensing/java/Constants.class
new file mode 100644 (file)
index 0000000..d67b953
Binary files /dev/null and b/apps/tutorials/LowPowerSensing/java/Constants.class differ
diff --git a/apps/tutorials/LowPowerSensing/java/Constants.java b/apps/tutorials/LowPowerSensing/java/Constants.java
new file mode 100644 (file)
index 0000000..5798537
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * This class is automatically generated by ncg. DO NOT EDIT THIS FILE.
+ * This class includes values of some nesC constants from
+ * ../LowPowerSensingConstants.h.
+ */
+
+public class Constants  {
+    public static final byte MSG_QUEUE_SIZE = 50;
+    public static final short SAMPLING_INTERVAL = 3000;
+    public static final byte BASE_STATION_ADDR = 0;
+    public static final short LPL_INTERVAL = 2000;
+}
diff --git a/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.class b/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.class
new file mode 100644 (file)
index 0000000..9c1b6c0
Binary files /dev/null and b/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.class differ
diff --git a/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.jar b/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.jar
new file mode 100644 (file)
index 0000000..fce3ff0
Binary files /dev/null and b/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.jar differ
diff --git a/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.java b/apps/tutorials/LowPowerSensing/java/LowPowerSensingApp.java
new file mode 100644 (file)
index 0000000..e1d30a6
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+import net.tinyos.message.*;
+import net.tinyos.util.*;
+import java.io.*;
+/**
+*/
+
+public class LowPowerSensingApp implements MessageListener
+{
+  MoteIF mote;
+
+  /* Main entry point */
+  void run() {
+    mote = new MoteIF(PrintStreamMessenger.err);
+    mote.registerListener(new SerialSampleMsg(), this);
+  }
+
+  synchronized public void messageReceived(int dest_addr, Message msg) {
+    if (msg instanceof SerialSampleMsg) {
+      System.out.print(msg.toString());
+    }
+  }
+
+  synchronized public void requestSamples(int addr) {
+    SerialRequestSamplesMsg msg = new SerialRequestSamplesMsg();
+    msg.set_addr(addr);
+    try {
+      mote.send(MoteIF.TOS_BCAST_ADDR, msg);
+    }
+    catch (IOException e) {
+      System.err.println("Cannot send message to mote");
+    }
+  }
+
+  public static void main(String[] args) {
+    LowPowerSensingApp me = new LowPowerSensingApp();
+    me.run();
+
+    InputStreamReader cin = new InputStreamReader(System.in);
+    BufferedReader in = new BufferedReader(cin);
+    String input = "";
+
+    System.out.print("Enter 's' to request samples\n");
+    System.out.print(">> ");
+    for(;;) {
+      try {
+        input = in.readLine();
+        if(input.equals("s")) {
+          System.out.print("Enter Address: ");
+          input = in.readLine();
+          me.requestSamples(Integer.parseInt(input));
+        }
+        else System.out.println("Invalid Input!!!!: ");
+        System.out.print(">> ");
+      }
+      catch (IOException e) {
+        System.out.print("Error On Input!!");
+      }
+    }
+  }
+}
diff --git a/apps/tutorials/LowPowerSensing/java/Makefile b/apps/tutorials/LowPowerSensing/java/Makefile
new file mode 100644 (file)
index 0000000..5bf4573
--- /dev/null
@@ -0,0 +1,31 @@
+GEN=SerialRequestSamplesMsg.java SerialSampleMsg.java Constants.java
+
+SENSOR_DIR = universal_sensors
+SENSOR_DEPS = ../$(SENSOR_DIR)/SensorSample.h
+
+all: LowPowerSensingApp.jar
+
+LowPowerSensingApp.jar: LowPowerSensingApp.class
+       jar cf $@ *.class
+
+SerialRequestSamplesMsg.java: ../LowPowerSensingMsgs.h $(SENSOR_DEPS)
+       mig -I../$(SENSOR_DIR) -target=null \
+-java-classname=SerialRequestSamplesMsg java ../LowPowerSensingMsgs.h serial_request_samples_msg -o $@
+
+SerialSampleMsg.java: ../LowPowerSensingMsgs.h $(SENSOR_DEPS)
+       mig -I../$(SENSOR_DIR) -target=null \
+-java-classname=SerialSampleMsg java ../LowPowerSensingMsgs.h serial_sample_msg -o $@
+
+Constants.java: ../LowPowerSensingConstants.h
+       ncg -I../$(SENSOR_DIR) -DLOWPOWERSENSING_JAVA_MAKEFILE -target=null \
+-java-classname=Constants java ../LowPowerSensingConstants.h BASE_STATION_ADDR SAMPLING_INTERVAL \
+MSG_QUEUE_SIZE LPL_INTERVAL  -o $@
+
+LowPowerSensingApp.class: $(wildcard *.java) $(GEN)
+       javac *.java
+
+clean:
+       rm -f *.class $(GEN)
+
+veryclean: clean
+       rm LowPowerSensingApp.jar
diff --git a/apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.class b/apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.class
new file mode 100644 (file)
index 0000000..02d38e9
Binary files /dev/null and b/apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.class differ
diff --git a/apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.java b/apps/tutorials/LowPowerSensing/java/SerialRequestSamplesMsg.java
new file mode 100644 (file)
index 0000000..486d2e7
--- /dev/null
@@ -0,0 +1,224 @@
+/**
+ * This class is automatically generated by mig. DO NOT EDIT THIS FILE.
+ * This class implements a Java interface to the 'SerialRequestSamplesMsg'
+ * message type.
+ */
+
+public class SerialRequestSamplesMsg extends net.tinyos.message.Message {
+
+    /** The default size of this message type in bytes. */
+    public static final int DEFAULT_MESSAGE_SIZE = 6;
+
+    /** The Active Message type associated with this message. */
+    public static final int AM_TYPE = 146;
+
+    /** Create a new SerialRequestSamplesMsg of size 6. */
+    public SerialRequestSamplesMsg() {
+        super(DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /** Create a new SerialRequestSamplesMsg of the given data_length. */
+    public SerialRequestSamplesMsg(int data_length) {
+        super(data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg with the given data_length
+     * and base offset.
+     */
+    public SerialRequestSamplesMsg(int data_length, int base_offset) {
+        super(data_length, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg using the given byte array
+     * as backing store.
+     */
+    public SerialRequestSamplesMsg(byte[] data) {
+        super(data);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg using the given byte array
+     * as backing store, with the given base offset.
+     */
+    public SerialRequestSamplesMsg(byte[] data, int base_offset) {
+        super(data, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg using the given byte array
+     * as backing store, with the given base offset and data length.
+     */
+    public SerialRequestSamplesMsg(byte[] data, int base_offset, int data_length) {
+        super(data, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg embedded in the given message
+     * at the given base offset.
+     */
+    public SerialRequestSamplesMsg(net.tinyos.message.Message msg, int base_offset) {
+        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialRequestSamplesMsg embedded in the given message
+     * at the given base offset and length.
+     */
+    public SerialRequestSamplesMsg(net.tinyos.message.Message msg, int base_offset, int data_length) {
+        super(msg, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+    /* Return a String representation of this message. Includes the
+     * message type name and the non-indexed field values.
+     */
+    public String toString() {
+      String s = "Message <SerialRequestSamplesMsg> \n";
+      try {
+        s += "  [addr=0x"+Long.toHexString(get_addr())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      try {
+        s += "  [sample_num=0x"+Long.toHexString(get_sample_num())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      return s;
+    }
+
+    // Message-type-specific access methods appear below.
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: addr
+    //   Field type: int, unsigned
+    //   Offset (bits): 0
+    //   Size (bits): 16
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'addr' is signed (false).
+     */
+    public static boolean isSigned_addr() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'addr' is an array (false).
+     */
+    public static boolean isArray_addr() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'addr'
+     */
+    public static int offset_addr() {
+        return (0 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'addr'
+     */
+    public static int offsetBits_addr() {
+        return 0;
+    }
+
+    /**
+     * Return the value (as a int) of the field 'addr'
+     */
+    public int get_addr() {
+        return (int)getUIntBEElement(offsetBits_addr(), 16);
+    }
+
+    /**
+     * Set the value of the field 'addr'
+     */
+    public void set_addr(int value) {
+        setUIntBEElement(offsetBits_addr(), 16, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'addr'
+     */
+    public static int size_addr() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'addr'
+     */
+    public static int sizeBits_addr() {
+        return 16;
+    }
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: sample_num
+    //   Field type: long, unsigned
+    //   Offset (bits): 16
+    //   Size (bits): 32
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'sample_num' is signed (false).
+     */
+    public static boolean isSigned_sample_num() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'sample_num' is an array (false).
+     */
+    public static boolean isArray_sample_num() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'sample_num'
+     */
+    public static int offset_sample_num() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'sample_num'
+     */
+    public static int offsetBits_sample_num() {
+        return 16;
+    }
+
+    /**
+     * Return the value (as a long) of the field 'sample_num'
+     */
+    public long get_sample_num() {
+        return (long)getUIntBEElement(offsetBits_sample_num(), 32);
+    }
+
+    /**
+     * Set the value of the field 'sample_num'
+     */
+    public void set_sample_num(long value) {
+        setUIntBEElement(offsetBits_sample_num(), 32, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'sample_num'
+     */
+    public static int size_sample_num() {
+        return (32 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'sample_num'
+     */
+    public static int sizeBits_sample_num() {
+        return 32;
+    }
+
+}
diff --git a/apps/tutorials/LowPowerSensing/java/SerialSampleMsg.class b/apps/tutorials/LowPowerSensing/java/SerialSampleMsg.class
new file mode 100644 (file)
index 0000000..da8340d
Binary files /dev/null and b/apps/tutorials/LowPowerSensing/java/SerialSampleMsg.class differ
diff --git a/apps/tutorials/LowPowerSensing/java/SerialSampleMsg.java b/apps/tutorials/LowPowerSensing/java/SerialSampleMsg.java
new file mode 100644 (file)
index 0000000..c290b3d
--- /dev/null
@@ -0,0 +1,290 @@
+/**
+ * This class is automatically generated by mig. DO NOT EDIT THIS FILE.
+ * This class implements a Java interface to the 'SerialSampleMsg'
+ * message type.
+ */
+
+public class SerialSampleMsg extends net.tinyos.message.Message {
+
+    /** The default size of this message type in bytes. */
+    public static final int DEFAULT_MESSAGE_SIZE = 8;
+
+    /** The Active Message type associated with this message. */
+    public static final int AM_TYPE = 153;
+
+    /** Create a new SerialSampleMsg of size 8. */
+    public SerialSampleMsg() {
+        super(DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /** Create a new SerialSampleMsg of the given data_length. */
+    public SerialSampleMsg(int data_length) {
+        super(data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg with the given data_length
+     * and base offset.
+     */
+    public SerialSampleMsg(int data_length, int base_offset) {
+        super(data_length, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg using the given byte array
+     * as backing store.
+     */
+    public SerialSampleMsg(byte[] data) {
+        super(data);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg using the given byte array
+     * as backing store, with the given base offset.
+     */
+    public SerialSampleMsg(byte[] data, int base_offset) {
+        super(data, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg using the given byte array
+     * as backing store, with the given base offset and data length.
+     */
+    public SerialSampleMsg(byte[] data, int base_offset, int data_length) {
+        super(data, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg embedded in the given message
+     * at the given base offset.
+     */
+    public SerialSampleMsg(net.tinyos.message.Message msg, int base_offset) {
+        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new SerialSampleMsg embedded in the given message
+     * at the given base offset and length.
+     */
+    public SerialSampleMsg(net.tinyos.message.Message msg, int base_offset, int data_length) {
+        super(msg, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+    /* Return a String representation of this message. Includes the
+     * message type name and the non-indexed field values.
+     */
+    public String toString() {
+      String s = "Message <SerialSampleMsg> \n";
+      try {
+        s += "  [src_addr=0x"+Long.toHexString(get_src_addr())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      try {
+        s += "  [sample.sample_num=0x"+Long.toHexString(get_sample_sample_num())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      try {
+        s += "  [sample.sin_value=0x"+Long.toHexString(get_sample_sin_value())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      return s;
+    }
+
+    // Message-type-specific access methods appear below.
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: src_addr
+    //   Field type: int
+    //   Offset (bits): 0
+    //   Size (bits): 16
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'src_addr' is signed (false).
+     */
+    public static boolean isSigned_src_addr() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'src_addr' is an array (false).
+     */
+    public static boolean isArray_src_addr() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'src_addr'
+     */
+    public static int offset_src_addr() {
+        return (0 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'src_addr'
+     */
+    public static int offsetBits_src_addr() {
+        return 0;
+    }
+
+    /**
+     * Return the value (as a int) of the field 'src_addr'
+     */
+    public int get_src_addr() {
+        return (int)getUIntBEElement(offsetBits_src_addr(), 16);
+    }
+
+    /**
+     * Set the value of the field 'src_addr'
+     */
+    public void set_src_addr(int value) {
+        setUIntBEElement(offsetBits_src_addr(), 16, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'src_addr'
+     */
+    public static int size_src_addr() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'src_addr'
+     */
+    public static int sizeBits_src_addr() {
+        return 16;
+    }
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: sample.sample_num
+    //   Field type: long
+    //   Offset (bits): 16
+    //   Size (bits): 32
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'sample.sample_num' is signed (false).
+     */
+    public static boolean isSigned_sample_sample_num() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'sample.sample_num' is an array (false).
+     */
+    public static boolean isArray_sample_sample_num() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'sample.sample_num'
+     */
+    public static int offset_sample_sample_num() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'sample.sample_num'
+     */
+    public static int offsetBits_sample_sample_num() {
+        return 16;
+    }
+
+    /**
+     * Return the value (as a long) of the field 'sample.sample_num'
+     */
+    public long get_sample_sample_num() {
+        return (long)getUIntBEElement(offsetBits_sample_sample_num(), 32);
+    }
+
+    /**
+     * Set the value of the field 'sample.sample_num'
+     */
+    public void set_sample_sample_num(long value) {
+        setUIntBEElement(offsetBits_sample_sample_num(), 32, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'sample.sample_num'
+     */
+    public static int size_sample_sample_num() {
+        return (32 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'sample.sample_num'
+     */
+    public static int sizeBits_sample_sample_num() {
+        return 32;
+    }
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: sample.sin_value
+    //   Field type: int
+    //   Offset (bits): 48
+    //   Size (bits): 16
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'sample.sin_value' is signed (false).
+     */
+    public static boolean isSigned_sample_sin_value() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'sample.sin_value' is an array (false).
+     */
+    public static boolean isArray_sample_sin_value() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'sample.sin_value'
+     */
+    public static int offset_sample_sin_value() {
+        return (48 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'sample.sin_value'
+     */
+    public static int offsetBits_sample_sin_value() {
+        return 48;
+    }
+
+    /**
+     * Return the value (as a int) of the field 'sample.sin_value'
+     */
+    public int get_sample_sin_value() {
+        return (int)getUIntBEElement(offsetBits_sample_sin_value(), 16);
+    }
+
+    /**
+     * Set the value of the field 'sample.sin_value'
+     */
+    public void set_sample_sin_value(int value) {
+        setUIntBEElement(offsetBits_sample_sin_value(), 16, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'sample.sin_value'
+     */
+    public static int size_sample_sin_value() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'sample.sin_value'
+     */
+    public static int sizeBits_sample_sin_value() {
+        return 16;
+    }
+
+}
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/GenericSensorSample.h b/apps/tutorials/LowPowerSensing/sampleLog/GenericSensorSample.h
new file mode 100644 (file)
index 0000000..d79a154
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#ifndef GENERICSENSORSAMPLE_H
+#define GENERICSENSORSAMPLE_H
+
+typedef struct generic_sensor_sample {
+  uint32_t sample_num;
+  sensor_type_t values[num_sensors];
+} generic_sensor_sample_t;
+
+typedef union generic_sensor_sample_type_union {
+  uint8_t u8;
+  uint16_t u16;
+  uint32_t u32; 
+  sensor_type_t st;
+} generic_sensor_sample_type_union_t;
+
+#endif //GENERICSENSORSAMPLE_H
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLogger16C.nc b/apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLogger16C.nc
new file mode 100644 (file)
index 0000000..6221725
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+generic configuration PeriodicSampleLogger16C(uint32_t period, uint8_t num_sensors){
+  uses {
+    interface Boot;
+    interface LogWrite;
+    interface Read<uint16_t> as Sensor[uint8_t];
+  }
+}
+implementation {
+  Boot = Logger.Boot;
+  Sensor = Logger;
+
+  components new PeriodicSampleLoggerP(period, num_sensors, uint16_t) as Logger;
+  components new TimerMilliC();
+  Logger.LogWrite = LogWrite;
+  Logger.Timer -> TimerMilliC;
+
+  components NoLedsC as LedsC;
+  Logger.Leds -> LedsC;
+}
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLoggerP.nc b/apps/tutorials/LowPowerSensing/sampleLog/PeriodicSampleLoggerP.nc
new file mode 100644 (file)
index 0000000..23fa83c
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+generic module PeriodicSampleLoggerP(uint32_t period_ms, 
+                                     uint8_t num_sensors, 
+                                     typedef sensor_type_t) {
+  uses {
+    interface Boot;
+    interface Read<sensor_type_t> as Sensor[uint8_t];
+    interface Timer<TMilli> as Timer;
+    interface LogWrite;
+    interface Leds;
+  }
+}
+implementation {
+  #include "GenericSensorSample.h"
+
+  generic_sensor_sample_t sample[2];
+  generic_sensor_sample_t* current_sample;
+  uint8_t current_sample_id;
+
+  task void eraseTask();
+  task void appendTask();
+
+  void readSensors() {
+    int i;
+    for(i=0; i<num_sensors; i++)
+      call Sensor.read[i]();
+  }
+
+  void appendSample(generic_sensor_sample_t* s) {
+    //printf("WRITE LOC: %d\n", call LogWrite.currentOffset());
+    if(call LogWrite.append(s, sizeof(generic_sensor_sample_t)) != SUCCESS)
+      post appendTask();
+  }
+
+  task void eraseTask() {
+    if(call LogWrite.erase() != SUCCESS)
+      post eraseTask();
+  }
+
+  task void appendTask() {
+    appendSample(&(sample[!current_sample_id]));
+  }
+
+  event void Boot.booted() {
+    if(call LogWrite.erase() != SUCCESS)
+      post eraseTask();
+  }
+
+  event void LogWrite.eraseDone(error_t error) {
+    sample[0].sample_num = 0;
+    sample[1].sample_num = 1;
+    current_sample_id = 0;
+    current_sample = &(sample[current_sample_id]);
+    readSensors();
+    call Timer.startPeriodic(period_ms);
+  }
+
+  event void Timer.fired() {
+    call Leds.led0Toggle();
+    appendSample(current_sample);
+    current_sample_id = !current_sample_id;
+    current_sample = &(sample[current_sample_id]);
+    readSensors();
+  }
+
+  event void Sensor.readDone[uint8_t i](error_t result, sensor_type_t val) {
+    if(result == SUCCESS) {
+      current_sample->values[i] = val;
+      call Leds.led1Toggle();
+    }
+    else {
+      current_sample->values[i] = ((generic_sensor_sample_type_union_t)(0xFFFFFFFF)).st;
+      call Leds.led2Toggle();
+    }
+  }
+
+  event void LogWrite.appendDone(void* buf, storage_len_t len, bool recordsLost, error_t error){
+    if(error != SUCCESS)
+      post appendTask();
+    else ((generic_sensor_sample_t*)buf)->sample_num+=2;
+  }
+  event void LogWrite.syncDone(error_t error) {}
+  default command error_t Sensor.read[uint8_t i]() {return SUCCESS;}
+}
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/SampleLogRead.nc b/apps/tutorials/LowPowerSensing/sampleLog/SampleLogRead.nc
new file mode 100644 (file)
index 0000000..1dd5452
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+interface SampleLogRead<sample_type_t> {
+  command error_t readFirst();
+  command error_t readNext();
+  event void readDone(sample_type_t* entry, error_t error);
+}
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderC.nc b/apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderC.nc
new file mode 100644 (file)
index 0000000..25d544e
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+generic configuration SampleLogReaderC(typedef sample_type_t) {
+  provides {
+   interface SampleLogRead<sample_type_t>;
+  }
+  uses {
+    interface LogRead;
+    interface LogWrite;
+  }
+}
+implementation {
+  components new SampleLogReaderP(sample_type_t) as LogReader;
+
+  SampleLogRead = LogReader;
+  LogReader.LogRead = LogRead;
+  LogReader.LogWrite = LogWrite;
+}
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderP.nc b/apps/tutorials/LowPowerSensing/sampleLog/SampleLogReaderP.nc
new file mode 100644 (file)
index 0000000..3f6886d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+generic module SampleLogReaderP(typedef sample_type_t) {
+  provides {
+    interface SampleLogRead<sample_type_t>;
+  }
+  uses {
+    interface LogRead;
+    interface LogWrite;
+  }
+}
+implementation {
+  sample_type_t sample;
+  storage_cookie_t writeLocation;
+
+  command error_t SampleLogRead.readFirst() {
+    return call LogRead.seek(SEEK_BEGINNING);
+  }
+
+  command error_t SampleLogRead.readNext() {
+    atomic writeLocation = call LogWrite.currentOffset();
+    if(call LogRead.currentOffset() == writeLocation)
+      return ECANCEL;
+    else return call LogRead.read(&sample, sizeof(sample));
+  }
+
+  event void LogRead.readDone(void* buf, storage_len_t len, error_t error) {
+    signal SampleLogRead.readDone((sample_type_t*)buf, error);
+  }
+
+  event void LogRead.seekDone(error_t error) {
+    if(error == SUCCESS) {
+      error = call SampleLogRead.readNext();
+      if(error != SUCCESS)
+        signal SampleLogRead.readDone(&sample, error);
+    }
+    else signal SampleLogRead.readDone(&sample, error);
+  }
+  event void LogWrite.appendDone(void* buf, storage_len_t len, bool recordsLost, error_t error) {}
+  event void LogWrite.eraseDone(error_t error) {}
+  event void LogWrite.syncDone(error_t error) {}
+  default event void SampleLogRead.readDone(sample_type_t* s, error_t error) {}
+}
+
diff --git a/apps/tutorials/LowPowerSensing/sampleLog/SampleNxConverter.nc b/apps/tutorials/LowPowerSensing/sampleLog/SampleNxConverter.nc
new file mode 100644 (file)
index 0000000..3715431
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "SensorSample.h"
+interface SampleNxConverter {
+  command void copyToNx(nx_sensor_sample_t* dest, sensor_sample_t* src);
+  command void copyFromNx(sensor_sample_t* dest, nx_sensor_sample_t* src);
+}
+
diff --git a/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SampleNxConverterC.nc b/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SampleNxConverterC.nc
new file mode 100644 (file)
index 0000000..d6c8339
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "SensorSample.h"
+module SampleNxConverterC {
+  provides interface SampleNxConverter;
+}
+implementation {
+  command void SampleNxConverter.copyToNx(nx_sensor_sample_t* dest, sensor_sample_t* src) {
+    dest->sample_num = src->sample_num;
+    dest->humidity = src->humidity;
+    dest->temperature = src->temperature;
+    dest->photo_active = src->photo_active;
+    dest->total_solar = src->total_solar;
+  }
+  command void SampleNxConverter.copyFromNx(sensor_sample_t* dest, nx_sensor_sample_t* src) {
+    dest->sample_num = src->sample_num;
+    dest->humidity = src->humidity;
+    dest->temperature = src->temperature;
+    dest->photo_active = src->photo_active;
+    dest->total_solar = src->total_solar;
+  }
+}
+
diff --git a/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SamplePeriodicLogC.nc b/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SamplePeriodicLogC.nc
new file mode 100644 (file)
index 0000000..5580b5e
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "SensorSample.h"
+#include "Storage.h"
+generic configuration SamplePeriodicLogC(uint32_t sampling_period, 
+                                                        volume_id_t volume) {
+  provides{
+    interface SampleLogRead<sensor_sample_t>;
+  }
+}
+implementation {
+
+  //Change sensors based on sensorboard........
+  components new PeriodicSampleLogger16C(sampling_period, 4) as PeriodicLogger;
+  components new SensirionSht11C() as HumidityTempC;
+  components new HamamatsuS10871TsrC() as PhotoActiveC;
+  components new HamamatsuS1087ParC() as TotalSolarC;
+  PeriodicLogger.Sensor[0] -> HumidityTempC.Humidity;
+  PeriodicLogger.Sensor[1] -> HumidityTempC.Temperature;
+  PeriodicLogger.Sensor[2] -> PhotoActiveC;
+  PeriodicLogger.Sensor[3] -> TotalSolarC;
+  
+  //Don't change........ just copy
+  components MainC;
+  components new LogStorageC(volume, TRUE);
+  components new SampleLogReaderC(sensor_sample_t) as LogReader;
+  SampleLogRead = LogReader;
+  MainC.Boot <- PeriodicLogger;
+  PeriodicLogger.LogWrite -> LogStorageC;
+  LogReader.LogRead -> LogStorageC;
+  LogReader.LogWrite -> LogStorageC;
+
+}
+
diff --git a/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SensorSample.h b/apps/tutorials/LowPowerSensing/tmote_onboard_sensors/SensorSample.h
new file mode 100644 (file)
index 0000000..45c0e89
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#ifndef SENSORSAMPLE_H
+#define SENSORSAMPLE_H
+
+typedef struct sensor_sample {
+  uint32_t sample_num;
+  uint16_t humidity;
+  uint16_t temperature;
+  uint16_t photo_active;
+  uint16_t total_solar;
+} sensor_sample_t;
+
+typedef nx_struct nx_sensor_sample {
+  nx_uint32_t sample_num;
+  nx_uint16_t humidity;
+  nx_uint16_t temperature;
+  nx_uint16_t photo_active;
+  nx_uint16_t total_solar;
+} nx_sensor_sample_t;
+
+#endif //SENSORSAMPLE_H
+
diff --git a/apps/tutorials/LowPowerSensing/universal_sensors/SampleNxConverterC.nc b/apps/tutorials/LowPowerSensing/universal_sensors/SampleNxConverterC.nc
new file mode 100644 (file)
index 0000000..f935534
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "SensorSample.h"
+module SampleNxConverterC {
+  provides interface SampleNxConverter;
+}
+implementation {
+  command void SampleNxConverter.copyToNx(nx_sensor_sample_t* dest, sensor_sample_t* src) {
+    dest->sample_num = src->sample_num;
+    dest->sin_value = src->sin_value;
+  }
+  command void SampleNxConverter.copyFromNx(sensor_sample_t* dest, nx_sensor_sample_t* src) {
+    dest->sample_num = src->sample_num;
+    dest->sin_value = src->sin_value;
+  }
+}
+
diff --git a/apps/tutorials/LowPowerSensing/universal_sensors/SamplePeriodicLogC.nc b/apps/tutorials/LowPowerSensing/universal_sensors/SamplePeriodicLogC.nc
new file mode 100644 (file)
index 0000000..f131cec
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#include "SensorSample.h"
+#include "Storage.h"
+generic configuration SamplePeriodicLogC(uint32_t sampling_period, volume_id_t volume) {
+  provides{
+    interface SampleLogRead<sensor_sample_t>;
+  }
+}
+implementation {
+
+  //Change sensors based on sensorboard........
+  components new PeriodicSampleLogger16C(sampling_period, 1) as PeriodicLogger;
+  components new SineSensorC();
+  PeriodicLogger.Sensor[0] -> SineSensorC;
+  
+  //Don't change..... just copy for different sensorboard implementations
+  components MainC;
+  components new LogStorageC(volume, TRUE);
+  components new SampleLogReaderC(sensor_sample_t) as LogReader;
+  MainC.Boot <- PeriodicLogger;
+  PeriodicLogger.LogWrite -> LogStorageC;
+  SampleLogRead = LogReader;
+  LogReader.LogRead -> LogStorageC;
+  LogReader.LogWrite -> LogStorageC;
+}
+
diff --git a/apps/tutorials/LowPowerSensing/universal_sensors/SensorSample.h b/apps/tutorials/LowPowerSensing/universal_sensors/SensorSample.h
new file mode 100644 (file)
index 0000000..8727eab
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date July 24, 2007
+ */
+
+#ifndef SENSORSAMPLE_H
+#define SENSORSAMPLE_H
+
+typedef struct sensor_sample {
+  uint32_t sample_num;
+  uint16_t sin_value;
+} sensor_sample_t;
+
+typedef nx_struct nx_sensor_sample {
+  nx_uint32_t sample_num;
+  nx_uint16_t sin_value;
+} nx_sensor_sample_t;
+
+#endif //SENSORSAMPLE_H
+