Start of Frame Delimiter. It's a part of MAC header.

Correct me if I'm wrong.

Ittipong


2009/5/6 Michael Schippling <[email protected]>

> ummm....what's an SFD?
> MS
>
>
> Philip Levis wrote:
>
>> If there's an SFD before the timer fires, your code will reset the timer
>> to fire. E.g., imagine your mote has an SFD interrupt every 500ms. It will
>> set the timer to fire in 1024ms, the SFD goes again, it will reset the timer
>> to fire in 1024ms, the SFD goes again...
>>
>> I don't know if that's the root of your problem, but it's definitely an
>> issue.
>>
>> Phil
>>
>> On Apr 23, 2009, at 2:42 AM, Ittipong Khemapech wrote:
>>
>>  I start the timer within the receive() event and *nothing* happens. No
>>> packet is transmitted by the source. I'm pretty sure that the radio is on at
>>> that time.
>>>
>>> I posted this problem several weeks ago and still got no reply. That's
>>> why I have to use the InitW2RTimer and it's started in the receivedSFD()
>>> event.
>>>
>>> Anybody got the same experience?
>>>
>>> Thanks,
>>> Ittipong
>>>
>>>
>>> 2009/4/21 Ittipong Khemapech <[email protected]>
>>> It wasn't me asking about the previous Timer questions. Many thanks for
>>> your hints. Will try and get back soon.
>>>
>>> Ittipong
>>>
>>> 2009/4/21 Michael Schippling <[email protected]>
>>>
>>> I guess this is what you were trying to get at in previous
>>> Timer questions, right?
>>>
>>> It looks like it should work the way you want. The only thing
>>> I can see that is questionable is the long atomic {block} for
>>> your message sending in DataSendTimer.fired(). This might
>>> block interrupts for too long.
>>>
>>> I would try to simplify the Timer scheme on it's own, flashing
>>> LEDs or something to see if it works the way you expect, and then
>>> start adding the radio message drivers back in.
>>>
>>> I think you should also be able to use the receive() method instead
>>> of starting your first timer, because it is called after the message
>>> is fully received.
>>>
>>> MS
>>>
>>> Ittipong Khemapech wrote:
>>> Hi,
>>>
>>> I have been trying to figure the problems out for days. No idea what
>>> causes it.
>>>
>>> I have a source receiving a packet from the base station. After the SFD
>>> is received, a timer is called to run to make sure that the reception is
>>> completed. The source waits for a wait_interval duration to send its data
>>> packet. So, another timer is used for timing the transmission.
>>>
>>> I am using AlarmToTimer component. The command startOneShot is called.
>>> What I expect is that the source should send *only after* it receives the
>>> packet from base station. It seems to me that the source keeps sending.
>>>
>>> Look forward to hear from you soon.
>>>
>>> Thanks,
>>> Ittipong
>>>
>>> The codes are as follows:
>>>
>>> MyDef.h
>>> ---------------------------------------------------------------------------------------------------
>>>
>>>
>>> #ifndef MYDEF_H_
>>> #define MYDEF_H_
>>>
>>> enum {
>>>  WAIT_TO_RECEIVE = 1024
>>> };
>>>
>>> #endif
>>> ==================================================
>>>
>>> SourceAppC.nc
>>> ----------------------------------------------------------------------------------------------------
>>>
>>>
>>> #include "MyDef.h"                   #include "DataMsg.h"
>>> #include "ControlMsg.h"
>>>
>>> configuration SourceAppC {
>>> }
>>> implementation {
>>>  components MainC;
>>>  components ActiveMessageC;
>>>
>>>  components new AMSenderC(AM_DATAMSG) as AMSenderDataC;
>>>  components new AMReceiverC(AM_CONTROLMSG) as AMReceiverCtrlC;
>>>
>>>  components new Alarm32khz32C() as Alarm2Timer;
>>>  components new AlarmToTimerC(T32khz) as W2RTimer;             components
>>> new AlarmToTimerC(T32khz) as SendTimer;
>>>
>>>  components CC2420TransmitC;
>>>  components CC2420ActiveMessageC;
>>>
>>>  components SourceC as App;
>>>
>>>  // Wiring
>>>  App.Boot -> MainC;
>>>
>>>  App.Packet -> AMSenderDataC;
>>>  App.AMPacket -> AMSenderDataC;
>>>  App.AMSend -> AMSenderDataC;
>>>  App.Receive -> AMReceiverCtrlC;
>>>
>>>  App.AMControl -> ActiveMessageC;;
>>>
>>>  App.InitW2RTimer -> W2RTimer;     App.DataSendTimer -> SendTimer;
>>>   W2RTimer.Alarm -> Alarm2Timer;
>>>  SendTimer.Alarm -> Alarm2Timer;
>>>               App.CC2420Packet -> CC2420ActiveMessageC;
>>>  App.RadioTimeStamping -> CC2420TransmitC;
>>>  App.CC2420Transmit -> CC2420TransmitC;
>>>     }
>>> =====================================================
>>>
>>> SourceC.nc
>>> ----------------------------------------------------------------------------------------------------------
>>>
>>>
>>> #include <Timer.h>
>>> #include "MyDef.h"                   #include "DataMsg.h"
>>> #include "ControlMsg.h"
>>>
>>> module SourceC {
>>>  uses {
>>>     interface Boot;
>>>     interface AMSend;
>>>     interface Receive;                         interface AMPacket;
>>>     interface Packet;
>>>     interface Timer<T32khz> as InitW2RTimer;
>>>     interface Timer<T32khz> as DataSendTimer;
>>>     interface RadioTimeStamping;             interface SplitControl as
>>> AMControl;
>>>     interface CC2420Packet;                         interface
>>> CC2420Transmit;
>>>  }
>>> }
>>> implementation {
>>>  message_t dpkt, cpkt;
>>>  bool sending = FALSE;
>>>  uint16_t pktseq, sentpkts;                 uint8_t current_tx;
>>>                                                        uint8_t base_addr,
>>> me;
>>>  uint32_t no_slot, slot_length, slot_start;         uint32_t
>>> wait_interval;
>>>
>>>  uint16_t rcv_no;
>>>
>>>  task void callInitW2RTimer() {
>>>     call InitW2RTimer.startOneShot(WAIT_TO_RECEIVE);
>>>  }
>>>
>>>  task void callDataSendTimer() {
>>>     call DataSendTimer.startOneShot(wait_interval);
>>>  }
>>>
>>>  event void Boot.booted() {
>>>     call AMControl.start();
>>>  }
>>>
>>>  event void AMControl.startDone(error_t err) {
>>>     if (err != SUCCESS) {
>>>         call AMControl.start();
>>>     }
>>>  }
>>>
>>>  event void AMControl.stopDone(error_t err) {
>>>  }
>>>
>>>  event void InitW2RTimer.fired() {
>>>     post callDataSendTimer();
>>>  }
>>>  event void DataSendTimer.fired() {
>>>
>>>     if (!sending) {
>>>         atomic {
>>>
>>>             DataMsg* dataMsg = (DataMsg*)(call Packet.getPayload(&dpkt,
>>> NULL));
>>>
>>>             sentpkts++;
>>>             pktseq++;
>>>
>>>             call CC2420Packet.setPower(&dpkt, MAX_TX);
>>> current_tx = call CC2420Packet.getPower(&dpkt);
>>>             dataMsg->pkt_type = 1;
>>>             dataMsg->source_id = me;
>>>             dataMsg->rcv_no = rcv_no;
>>>
>>>             dataMsg->tx_power = current_tx;
>>>             dataMsg->snt_no = sentpkts;
>>>             dataMsg->seq_no = pktseq;
>>>             dataMsg->slot = no_slot;
>>>             dataMsg->length = slot_length;
>>>             dataMsg->start = slot_start;
>>>             dataMsg->wait = wait_interval;
>>>
>>>             if (call AMSend.send(base_addr, &dpkt, sizeof(DataMsg)) ==
>>> SUCCESS) {
>>>                 sending = TRUE;                     }
>>>         }
>>>     }
>>>
>>>  }
>>>  event void AMSend.sendDone(message_t *msg, error_t error) {
>>>     if (&dpkt == msg) {
>>>         atomic {
>>>             sending = FALSE;
>>>         }             }
>>>  }
>>>  event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
>>> len) {
>>>
>>>     if (len == sizeof(ControlMsg)) {
>>>         atomic {
>>>               ControlMsg* controlMsg = (ControlMsg*) payload;
>>>
>>>             base_addr = controlMsg->base_id;
>>>             me = TOS_NODE_ID;
>>>
>>>             rcv_no = controlMsg->snt_no;
>>>
>>>             no_slot = controlMsg->no_alloc_slot;
>>>             slot_length = controlMsg->slot_length;
>>>             slot_start = controlMsg->slot_start;
>>>
>>>             wait_interval = (uint32_t) (((me - 1) * slot_length) +
>>> slot_start);
>>>
>>>         }
>>>     }
>>>     return msg;
>>>  }
>>>
>>>
>>>  async event void RadioTimeStamping.transmittedSFD(uint16_t time,
>>> message_t* p_msg) {
>>>  }
>>>
>>>  async event void RadioTimeStamping.receivedSFD(uint16_t time) {
>>>     post callInitW2RTimer();           }
>>>
>>>  async event void CC2420Transmit.sendDone(message_t* p_msg, error_t
>>> error) {
>>>  }
>>>
>>> }
>>> ====================================================================
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Tinyos-help mailing list
>>> [email protected]
>>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>>
>>>
>>> _______________________________________________
>>> Tinyos-help mailing list
>>> [email protected]
>>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>>
>>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to