/* * For CS321: to be used with iMote2 for the Desync project. * * @author Brano Kusy * @date 10/15/07 */ for the Desync project, you are going to need a way to record system time and to precisely schedule radio message transmission. SingleTimer which you've seen in the warmup project is not built for this purpose: it does not provide method to read the current time, and it also may not be able to schedule your fired() event very precisely. precise timing can be achieved using SysTimeC component which can be found in \opt\tinyos-1.x\beta\platform\pxa27x. We had to implement an extra command for Desync testing, so please use the implementation provided in tos directory in our MainProject.zip file (by specifying 'PFLAGS+=-Itos' in your Makefile). SysTimeC provides SysTime64 interface which has the following interesting commands: async command uint32_t getTime32(); async command result_t setAlarm(uint32_t val); async event result_t alarmFired(uint32_t val); getTime32() will be used to record current time: Resolution of the clock is ~3.25Mhz, so 1 unit is about one third of a microsecond. That means that time is consistent for about 20 mins after which it overflows. For the purposes of this project, we don't have to worry about this. If you are interested, you can look at getTime64() method provided by SysTimeC. alarm command/event will be used to precisely schedule your Desync message transmission. if you want the alarmFired() event to be fired in xxx miliseconds, you need the setAlarm(val) command with the current time plus xxx milliseconds converted to 3.25MHz timebase: 'getTime32()+(xxx*3250)' you may want to think about two types of applications - the ones which require high precision (TDMA) and short (a few ms) intervals and the ones which sample over larger (a few sec) time intervals (monitoring applications). Become familiar with the motes' system time: "clock.samples" file contains a number of clock readings taken with 10Hz period over almost half hour. first column is the real time, second column is the mote SysTime. try to find where in the data the clock overflew. try to calculate resolution of the mote clock using this data.