[Tinyos-2-commits]
CVS: tinyos-2.x/apps/tutorials/LowPowerSensing/sampleLog
GenericSensorSample.h, NONE, 1.1 PeriodicSampleLogger16C.nc,
NONE, 1.1 PeriodicSampleLoggerP.nc, NONE, 1.1 SampleLogRead.nc,
NONE, 1.1 SampleLogReaderC.nc, NONE, 1.1 SampleLogReaderP.nc,
NONE, 1.1 SampleNxConverter.nc, NONE, 1.1
Kevin Klues
klueska at users.sourceforge.net
Mon Sep 3 15:46:38 PDT 2007
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tutorials/LowPowerSensing/java
Constants.class, NONE, 1.1 Constants.java, NONE,
1.1 LowPowerSensingApp.class, NONE, 1.1 LowPowerSensingApp.jar,
NONE, 1.1 LowPowerSensingApp.java, NONE, 1.1 Makefile, NONE,
1.1 SerialRequestSamplesMsg.class, NONE,
1.1 SerialRequestSamplesMsg.java, NONE,
1.1 SerialSampleMsg.class, NONE, 1.1 SerialSampleMsg.java, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tutorials/LowPowerSensing/tmote_onboard_sensors
SampleNxConverterC.nc, NONE, 1.1 SamplePeriodicLogC.nc, NONE,
1.1 SensorSample.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tutorials/LowPowerSensing/sampleLog
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8308/sampleLog
Added Files:
GenericSensorSample.h PeriodicSampleLogger16C.nc
PeriodicSampleLoggerP.nc SampleLogRead.nc SampleLogReaderC.nc
SampleLogReaderP.nc SampleNxConverter.nc
Log Message:
Low Power Sensing Application initial checkin
--- NEW FILE: GenericSensorSample.h ---
/*
* 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 at 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
--- NEW FILE: PeriodicSampleLogger16C.nc ---
/*
* 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 at 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;
}
--- NEW FILE: PeriodicSampleLoggerP.nc ---
/*
* 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 at 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;}
}
--- NEW FILE: SampleLogRead.nc ---
/*
* 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 at 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);
}
--- NEW FILE: SampleLogReaderC.nc ---
/*
* 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 at 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;
}
--- NEW FILE: SampleLogReaderP.nc ---
/*
* 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 at 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) {}
}
--- NEW FILE: SampleNxConverter.nc ---
/*
* 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 at 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);
}
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tutorials/LowPowerSensing/java
Constants.class, NONE, 1.1 Constants.java, NONE,
1.1 LowPowerSensingApp.class, NONE, 1.1 LowPowerSensingApp.jar,
NONE, 1.1 LowPowerSensingApp.java, NONE, 1.1 Makefile, NONE,
1.1 SerialRequestSamplesMsg.class, NONE,
1.1 SerialRequestSamplesMsg.java, NONE,
1.1 SerialSampleMsg.class, NONE, 1.1 SerialSampleMsg.java, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tutorials/LowPowerSensing/tmote_onboard_sensors
SampleNxConverterC.nc, NONE, 1.1 SamplePeriodicLogC.nc, NONE,
1.1 SensorSample.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list