rtel wrote on Tuesday, October 19, 2010:
Quoting from several posts:
When the gps device is turned on, I would like to start a 1 minute timer
The timing constraints are very course then, which makes it easier.
in what thread should the timeout function get called? A running thread can not suddenly be yanked to do this operation, so fundamentally you need a new thread to handle this timeout
I think it depends on the structure of the other tasks I suppose, also, what the task that is using the GPS is doing while no signal is available. If it has no work to do until there is no signal then the problem would not exist, so I assume it has other functionality it must maintain while waiting for the signal.
Presumably it will be checking the signal status before trying to use the GPS data anyway? In which case some status variables could be set from an interrupt to say when the signal was locked (assuming the GPS generates interrupts) if it would take to long to query the GPS device directly. The interrupt could also clear the timer. The task that used the GPS data would then just have to check the status variables. In this case the tick hook could be used for the timer functionality. When the GPS receiver was switched on the timer count down value would be set. The tick hook would decrement the count down value, and set one of the status variables accordingly (timeout condition), or call a function, if the decrement caused the count down value to change from 1 to 0. In all other cases no further action would be taken. Obviously the decrement would only occur if the count down values was greater than 0.
I do have a timer module that allows timers to be created and deleted on the fly, but it is very, very, very (get the idea) old. I might not even be able to find it now. My problem with it is finding an efficient way to process timers. FreeRTOS never walks through a linked list from within an interrupt or while interrupts are disabled, so a linked list of timers that are processed in the tick is against the design philosophy (responsiveness and determinism being the issues). Statically declared/coded timer functionality as described in the paragraph above is less of a problem as simple switch statements, etc. can be used.