hi, does everybody know a way to make timestamping with tinyOS 1.x?
thanks! 2009/4/24 Anton <ag...@disi.unitn.it> > Hi, > > > for timestamps in TinyOS 2.1 it is better to use the interfaces > TimeSyncAMSend and TimeSyncPacket. On a sender: you should read the > timer (e.g. “sendertime = call Alarm.getNow()”), put its value to some > field of the radio packet you are going to send, send the packet by the > command “call TimeSyncAMSend.Send()”. On a receiver: in the “Receive” > event you can extract the sender timestamp by reading the corresponding > field of the received message; also you can call the command > TimeSyncPacket.eventTime(msg)” to read the time of the receiver > corresponding to the sender timestamp (i.e. this value is the receiver > time at the moment when the sender makes its time reading, which is then > put in the packet). Don’t forget to use proper precision and width tags, > i.e. if you use 32-bit timer clocked by 32768 Hz oscillator your > interfaces declarations in “…C.nc file” should look like these: > > interface TimeSyncAMSend<T32khz,uint32_t>; > > interface TimeSyncPacket<T32khz,uint32_t>; > > in “…AppC.nc file” it should be like this: > > App.Send -> ActiveMessageC.TimeSyncAMSend32khz[AM_MYMSG]; > > Anyway, look attentively through the TEP 133 and TEP 102 – everything is > explained there: > > http://www.tinyos.net/tinyos-2.1.0/doc/html/tep133.html > > http://www.tinyos.net/tinyos-2.1.0/doc/html/tep102.html > > If you are interested why the code with “RadioTimeStamping” does not > work in TinyOS 2.1: because this interface is not provided by the > CC2420TransmitP.nc module there. As for the CC2420Transmit interface: it > is still present in TinyOS 2.1 (provided by CC2420TransmitP.nc), but, in > order to use it, of course, in your “…App.nc” file it is necessary to > “wire” the interface in a way like this: > > components CC2420TransmitC; > > App.CC2420Transmit->CC2420TransmitC.CC2420Transmit; > > Also, you used millisecond-timer in your application (uses interface > Timer<TMilli> as Timer0;), while the event > “RadioTimeStamping.transmittedSFD” returns 16-bit value of the timer > clocked by 32768 Hz oscillator – of course it is incompatible in such a > way. Besides, the code like this > > > mytimebuf=(((((timertime&0x0000FFFFUL)>((uint32_t)time&0x0000FFFFUL))?timertime:(timertime-0x00010000UL))&0xFFFF0000UL)|((uint32_t)time&0x0000FFFFUL)); > > is absolutely unreadable, it is wrong to code like this. Sorry, it is my > fault, I did this, I don’t know why. Of course, it’s a crime to code > like this. It is better to use “if-else” statements. > > > > > 2009/4/23 sara so <sara.k...@gmail.com <mailto:sara.k...@gmail.com>> > > > > Hi, > > Thanks for your help but I have tried to follow your small code ... > it > > is always complaining about no such interface CC2420TransmitC?? > > uses interface RadioTimeStamping; also this interface is not > > avialable?? > > This is my code in case you want to take a look? > > > > #include <Timer.h> > > #include "CC2420.h" > > #include "BlinkToRadio.h" > > > > module BlinkToRadioC{ > > uses interface Boot; > > uses interface Leds; > > uses interface Timer<TMilli> as Timer0; > > > > uses interface Packet; > > uses interface AMPacket; > > uses interface AMSend; > > uses interface Receive; > > uses interface SplitControl as AMControl; > > uses interface RadioTimeStamping; > > implementation { > > message_t pkt; > > bool busy = FALSE; > > uint32_t timertime; > > uint32_t mytimebuf; > > uint32_t transmittime; > > uint8_t mytime[4]; > > event void Boot.booted() { > > call AMControl.start(); > > } > > > > event void AMControl.startDone(error_t err) { > > if (err == SUCCESS) { > > call Timer0.startPeriodic(TIMER_PERIOD_MILLI); > > } > > else { > > call AMControl.start(); > > } > > } > > > > event void AMControl.stopDone(error_t err) { > > } > > > > event void Timer0.fired() { > > > > if (!busy) { > > BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call > > Packet.getPayload(&pkt, NULL)); > > > > if (call AMSend.send(2, &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) { > > busy = TRUE; > > } > > } > > } > > > > event void AMSend.sendDone(message_t* msg, error_t err) { > > if (&pkt == msg) { > > busy = FALSE; > > } > > } > > > > async event void RadioTimeStamping.transmittedSFD(uint16_t time, > > message_t* p_msg){ > > > > //get the current time and replace the lower half-word with > > SFD-captured timer content: > > timertime= call Timer0.getNow(); //timeget(); is that ok ? > > > mytimebuf=(((((timertime&0x0000FFFFUL)>((uint32_t)time&0x0000FFFFUL))?timertime:(timertime-0x00010000UL))&0xFFFF0000UL)|((uint32_t)time&0x0000FFFFUL)); > > transmittime=mytimebuf; > > //load the 32-bit timestamp to a uint8_t 4-elements' array: > > for(v=0;v<4;v++){ > > mytime[v]=(uint8_t)((mytimebuf>>((3-v)*8))&0x000000FFUL); > > } > > //write the timestamp to the CC2420 RAM: > > call CC2420Transmit.modify( > > offsetof(pkt,timeStamp)+sizeof(message_header_t), mytime, 4); > > } > > > > async event void RadioTimeStamping.receivedSFD(uint16_t time, > > message_t* p_msg){ > > > > } > > } > > > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >
_______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help