Hi Mark,
I'd like your advice on how to handle the following scenario in uTasker.
I have a task TASK_COMMS_TX which formats a message packet which is then sent out of a serial port using fnWrite(SerialPortID...... as well as sending a packet out on the serial port it also Starts a time-out timer using
uTaskerMonoTimer(TASK_COMMS_TX, (DELAY_LIMIT)(0.25*SEC), E_COMMS_TIMEOUT); // Set Timeout timer for 250ms
I have another task TASK_COMMS_RX which handles the serial reception from the remote device, this task parses the received message. If it receives a valid reply then I want TASK_COMMS_TX to process the next message that may be waiting in its Queue. The reception of a valid message should also stop the above time-out timer using
uTaskerStopTimer(TASK_COMMS_TX); // stop timeout timer
TASK_COMMS_TX is configured to be in the state UTASKER_STOP, so it should only be woken by events.
What I want to do is use the input queue of TASK_COMMS_TX to cache incoming messages, that will be processed either after a valid reply to a previous message is received or a time-out from a previously transmitted message occurs. Am I correct in saying that if TASK_COMMS_TX is in the state UTASKER_SUSPENDED nothing can wake it, where as if its in the state UTASKER_STOP. Any event will wake it including the reception of another packet to be transmitted.
One way around this would be to have another task, to handle the Time out event and switch TASK_COMMS_TX into the UTASKER_STOP state when a timeout occurs, but this seems a bit untidy, 3 Tasks to handle a comms protocol.
Is the above the way to do this or is there a simpler way?
I hope the above makes sense
Cheers
Martin Honeywill