Hello.
I am using a K60D100M tower system with MQX4.0.2. I have successfully sent data using UART3 and am now trying to receive data. I have tried using fread() and _io_read() in order to do so and the data transfer works, but both functions block the task until data is received. Is there a way to receive data without blocking the task while waiting for it?
Solved! Go to Solution.
Hi Andreea,
In addition please check the below thread.
Serial IO_SERIAL_NON_BLOCKING flag
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Andreea,
In addition please check the below thread.
Serial IO_SERIAL_NON_BLOCKING flag
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
fgetc is non-blocking:
int c;
while ((c = fgetc(fp)) != -1) {
/* do something with (char)c */
}
Actually, I should clarify that a bit. Both fgetc() and fread() are blocking or non-blocking depending on how you open the port.
fp = fopen("ittyc:", (pointer)(IO_SERIAL_NON_BLOCKING));
The IO_SERIAL_NON_BLOCKING flag is explained in the MQX I/O Drivers User's Guide, which is in ...\Freescale\Freescale_MQX_4_0\doc\mqx\MQXIOUG.pdf
I have tried opening the port with IO_SERIAL_NON_BLOCKING, but the task is still blocked if no data is received. Do you have any other suggestions?
Opening it with the IO_SERIAL_NON_BLOCKING flag works for me. I am using the interrupt-driver version of the driver but I don't know if that makes a difference; I wouldn't think so. Do you have any other flags set on the port; hardware handshaking for example? I wonder if that could cause it to block.
If nothing is obvious I would suggest using the debugger to pause execution at a time when you think it is blocked and seeing where that thread is (presumably somewhere down in the driver). If it is not clear how it got there run it again with a breakpoint on the fgetc() call then step into it to see why it blocks.
Hi Andreea
I recommend posting in the MQX forum since the issue is related to the use of MQX SW rather than the Kinetis itself.
Regards
Mark