Download presentation
Presentation is loading. Please wait.
Published byJakob Henriksson Modified over 5 years ago
1
SenseToRfm SenseToInt.Timer -> TimerC; configuration SenseToRfm {
// this module does not provide any interface } implementation { components Main, SenseToInt, IntToRfm, TimerC, Photo as Sensor; Main.StdControl -> SenseToInt; Main.StdControl -> IntToRfm; SenseToInt.Timer -> TimerC.Timer[unique("Timer")]; SenseToInt.Timer -> TimerC; SenseToInt.ADC -> Sensor; SenseToInt.ADCControl -> Sensor; SenseToInt.IntOutput -> IntToRfm; Main StdControl SenseToInt TimerControl ADCControl Timer ADC IntOutput TimerC Photo IntToRfm
2
Nested Configuration includes IntMsg; configuration IntToRfm {
provides { interface IntOutput; interface StdControl; } implementation components IntToRfmM, GenericComm as Comm; IntOutput = IntToRfmM; StdControl = IntToRfmM; IntToRfmM.Send -> Comm.SendMsg[AM_INTMSG]; IntToRfmM.SubControl -> Comm; StdControl IntOutput IntToRfmM SubControl SendMsg[AM_INTMSG]; GenericComm
3
IntToRfm Module command result_t StdControl.start() includes IntMsg;
{ return call SubControl.start(); } command result_t StdControl.stop() { return call SubControl.stop(); } command result_t IntOutput.output(uint16_t value) { ... if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data) return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr msg, result_t success) includes IntMsg; module IntToRfmM { uses { interface StdControl as SubControl; interface SendMsg as Send; } provides { interface IntOutput; interface StdControl; implementation bool pending; struct TOS_Msg data; command result_t StdControl.init() { pending = FALSE; return call SubControl.init();
4
The Complete Application
SenseToRfm generic comm IntToRfm AMStandard RadioCRCPacket UARTnoCRCPacket packet CRCfilter noCRCPacket Timer photo MicaHighSpeedRadioM ChannelMon phototemp RadioTiming SecDedEncode byte SW SPIByteFIFO RandomLFSR ADC HW UART ClockC bit SlavePin
5
Sending a Message User component provide structured msg storage
bool pending; struct TOS_Msg data; command result_t IntOutput.output(uint16_t value) { IntMsg *message = (IntMsg *)data.data; if (!pending) { pending = TRUE; message->val = value; message->src = TOS_LOCAL_ADDRESS; if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data)) return SUCCESS; pending = FALSE; } return FAIL; destination length Refuses to accept command if buffer is still full or network refuses to accept send command User component provide structured msg storage
6
Send done Event Send done event fans out to all potential senders
event result_t IntOutput.sendDone(TOS_MsgPtr msg, result_t success) { if (pending && msg == &data) { pending = FALSE; signal IntOutput.outputComplete(success); } return SUCCESS; Send done event fans out to all potential senders Use the event to schedule pending communication
7
RfmToLeds configuration RfmToLeds { } implementation {
components Main, RfmToInt, IntToLeds; Main.StdControl -> IntToLeds.StdControl; Main.StdControl -> RfmToInt.StdControl; RfmToInt.IntOutput -> IntToLeds.IntOutput; Main StdControl IntToLeds StdControl IntOutput RfmToInt
8
RfmtoInt configuration RfmToInt { provides interface StdControl;
uses interface IntOutput; } implementation { components RfmToIntM, GenericComm; IntOutput = RfmToIntM; StdControl = RfmToIntM; RfmToIntM.ReceiveIntMsg -> GenericComm.ReceiveMsg[AM_INTMSG]; RfmToIntM.CommControl -> GenericComm; IntOutput StdControl RfmToIntM CommControl ReceiveMsg GenericComm
9
RfmToIntM command result_t StdControl.stop() {
return call CommControl.stop(); } event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) { IntMsg *message = (IntMsg *)m->data; call IntOutput.output(message->val); return m; event result_t IntOutput.outputComplete(result_t success) { return SUCCESS; module RfmToIntM { provides interface StdControl; uses { interface ReceiveMsg as ReceiveIntMsg; interface IntOutput; interface StdControl as CommControl; } implementation { command result_t StdControl.init() { return call CommControl.init(); command result_t StdControl.start() { return call CommControl.start();
10
IntToLeds configuration IntToLeds { provides interface IntOutput;
provides interface StdControl; } implementation components IntToLedsM, LedsC; IntOutput = IntToLedsM.IntOutput; StdControl = IntToLedsM.StdControl; IntToLedsM.Leds -> LedsC.Leds;
11
Receive Event event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) { IntMsg *message = (IntMsg *)m->data; call IntOutput.output(message->val); return m; } Active message automatically dispatched to associated handler knows format, no run-time parsing performs action on message event Must return free buffer to the system typically the incoming buffer if processing complete
12
Exercise Distributed version of Blink Timer and BlinkM on one mote
LedsC on another mote When timeout occurs, the first mote should send a command to the other mote to make the LED blink.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.