AnsweredAssumed Answered

CW MobileGT - Recommended Serial Tx/Rx Scheme

Question asked by Tim Hutchinson on Aug 23, 2011
Latest reply on Oct 25, 2011 by Iain Galloway

Hi Everyone,

 

    I've created a task that's main responsibility is to receive data from a serial port and write it into a buffer for later processing by another task. This serial task is always running but blocks so that other tasks can run when the read() function call determines that no serial data is waiting to be received (serial device opened in blocking, interrupt mode).

 

    My question is, what would be the best way to service the transmission of data on this same serial port? Would I open the same serial device in another task and call write(), then terminate that task when the transmit data buffer has been emptied? Is it allowed to have two separate tasks open the same serial device at the same time?

 

    Maybe the task that opened the serial device and services the receipt of data needs to do the transmission as well? But to do that this task would need to open the serial device in a non-blocking fashion (so calls to read() don't block) and then the task would never block and allow other tasks to run. I suppose I could include a _time_delay(xx) if read() returns no data waiting. During the _time_delay(xx) the serial task would block and allow other tasks to run but this doesn't seem like the way this should be done.

 

Any ideas on how others have accomplished this would be really helpful. Thanks!

 

~Tim

 

 

 

Outcomes