Lecture 5 Sensing 石致豪
Introduction
Sense application SenseAppC.nc configuration SenseAppC { } implementation { components SenseC, MainC, LedsC, new TimerMilliC(), new DemoSensorC() as Sensor; SenseC.Boot -> MainC; SenseC.Leds -> LedsC; SenseC.Timer -> TimerMilliC; SenseC.Read -> Sensor; }
module SenseC { uses { interface Boot; interface Leds; interface Timer ; interface Read ; }
Read interface interface Read { /** * Initiates a read of the value. * SUCCESS if a readDone() event will eventually come back. */ command error_t read(); /** * Signals the completion of the read(). * result SUCCESS if the read() was successful val the value that has been read */ event void readDone( error_t result, val_t val ); }
DemoSenserC component generic configuration DemoSensorC() { provides interface Read ; } implementation { components new VoltageC() as DemoSensor; can be modified!! Read = DemoSensor; }
Available Sensor component tinyos-2.x/tos/platforms tinyos-2.x/tos/sensorboards tinyos-2.x/tos/chips tinyos-2.x/tos/system
Running the Sense application apps/Sense make telosb install
Oscilloscope application Let you visualize sensor readings on the PC Broadcasts a message within 10 accumulated readings over the radio Must be used with the BaseStation application
OscilloscopeAppC.nc configuration OscilloscopeAppC { } implementation { components OscilloscopeC, MainC, ActiveMessageC,LedsC, new TimerMilliC(), new DemoSensorC() as Sensor, new AMSenderC(AM_OSCILLOSCOPE), new AMReceiverC(AM_OSCILLOSCOPE); OscilloscopeC.Boot -> MainC; OscilloscopeC.RadioControl -> ActiveMessageC; OscilloscopeC.AMSend -> AMSenderC; OscilloscopeC.Receive -> AMReceiverC; OscilloscopeC.Timer -> TimerMilliC; OscilloscopeC.Read -> Sensor; OscilloscopeC.Leds -> LedsC; }
OscilloscopeC.nc module OscilloscopeC { uses { interface Boot; interface SplitControl as RadioControl; interface AMSend; interface Receive; interface Timer; interface Read; interface Leds; }
Running te Oscilloscope application tinyos-2.x/apps/Oscilloscope $ make telosb install,1 ^ L assign number to node
Running the Java GUI Create a BaseStation node tiny-2.x/apps/Oscilloscope/java/% make Create a SerialFowarder./run