rtel wrote on Friday, November 18, 2005:
It is possible to access the queue directly with a bit of fiddling, but I’m wondering if you are really wanting a queue at all or whether a simple buffer might be more appropriate for your application?
The primary reason for using a queue would be to guarantee the priority at which each received character was processed. See this thread for more detail: http://sourceforge.net/forum/message.php?msg_id=3381733
If you are wanting to buffer characters until a CR LF sequence then you could have a very simple ISR that just
1) reads the character from the peripheral,
2) places it in a buffer (just an array),
3) checks whether it is the end of the message, 4) clears the interrupt
5) if it is the end of the message then optionally signal to a task that a complete message is ready for processing. This could be done by using xSemaphoreGiveFromISR(). Depending on the relative priorities of your tasks the semaphore could make the data processing task the highest priority task ready to run meaning the ISR returns immediately to the data processing task.
The data processing task would then be something like:
____while( !xSemaphoreTake( Semaphore, MAX_WAIT_TIME ) );
____/* Broke from block loop above so a message
____must be available. */
____/* ProcessMessage() just accesses the message
____buffer directly. */
____/* Go back to block waiting for next complete
This would be much more efficient than using a queue.