Serial Read with TimeOut - Interrupt, blocked with explicit # char's - UART

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Serial Read with TimeOut - Interrupt, blocked with explicit # char's - UART

897 Views
Cdn_aye
Senior Contributor I

Hi

I am looking for a way to read a specific number of char's from the serial uart channel. If I use blocked and the char's are not received the task hangs... I understand that. But if I use unblocked, I get the number of char's in the stream at that point which may not have been in the window of opportunity.

I can't just put a time delay in and return with whatever is in the buffer; that is non deterministic. We are checking the response from a BT module and the responses are async based on the users response time/or not. I need to call the fread/read function requesting an exact number of char's, but return after a timeout period if we don't get all the char's or any. Other drivers I have worked with have a QIO_TIMEOUT value regardless of blocking/non blocking. Is there anyway to implement this functionality without hacking the mqx driver?

I thought of scheduling a task to do the read using a global buffer and flag, then terminate the task if we timed out. But that seems a bit...lame.

Does anyone have a suggestion please? Thanks

Robert

0 Kudos
1 Reply

338 Views
Cdn_aye
Senior Contributor I

Hi

Would a better way to handle this issue be to not use the MQX driver at all and build a simple UART driver then nstall this with MQX? Does anyone know of a simple code base to start from apart from MQX or would it be best to go to the non-MQX examples that handle the UART and work from that point?

What I am looking for is advice on is the best recommended path forward.

Thanks

Robert

0 Kudos