This patch adds a simple function that makes it possible
to extract the time left to the next fire-event of the
timer.
diff -Naur old/interfaces/Timer.nc tos/interfaces/Timer.nc
--- old/interfaces/Timer.nc 2003-10-27 12:30:02.
764424000 +0100
+++ tos/interfaces/Timer.nc 2003-10-27 12:29:16.
297608000 +0100
@@ -67,6 +67,13 @@
*/
command result_t stop();
+ /**
+ * Gets the number of clock ticks left for the timer to
fire.
+ * @return Returns SUCCESS if the timer exists, and
is
+ * started, FAIL otherwize.
+ */
+ command result_t Timer.TicksLeft(uint32_t *ticks);
+
/**
* The signal generated by the timer when it fires.
*/
diff -Naur old/system/TimerM.nc tos/system/TimerM.nc
--- old/system/TimerM.nc 2003-10-27 12:30:12.
768809600 +0100
+++ tos/system/TimerM.nc 2003-10-27 14:04:25.
206001600 +0100
@@ -150,6 +150,15 @@
return FAIL; //timer not running
}
+ command result_t Timer.TicksLeft[uint8_t id]
(uint32_t *ticks) {
+ if (id>=NUM_TIMERS) return FAIL;
+ if (mState&(0x1<<id)) {
+ *ticks = mTimerList[id].ticksLeft - call Clock.
readCounter();
+ return SUCCESS;
+ } else {
+ return FAIL;
+ }
+ }
default event result_t Timer.fired[uint8_t id]() {
return SUCCESS;