I may have a short coming in my understanding, but I am using the following to read serial data from UART0 built as ittya: interrupt mode, ca_rs485_rx_buff is for any characters received,
gs_File_RS485 is the file block and I only have one for the read and write.
MQX_FILE_PTR gs_File_RS485 = NULL;
u32_result = fread(ca_rs485_rx_buff, 1, sizeof(ca_rs485_rx_buff), gs_File_RS485);
The input buffer is size of 80. When I do a read I always get 80 as the # chars received. But the buffer contains old transmissions (this is a BT connection and the BTM is sending 'OK' etc for every transmission).
I expected to get 0 when nothing was received and I thought the buffer would be cleared. It is not, the last string still is in there. I rebuilt all the MQX libraries etc, the Tx is working correctly.
I have read through the posts and doc set but don't see where the error is. Is this an error on my side? If does the buffer get cleared in the FB, and should there be 0 for no new char's??
Any suggestion as to where this is going sideways would be appreciated.
I just found that IO_SERIAL_ECHO, was enabled. I disabled this in twrk40x256.h rebuilt mqx.
Now I don't see the Rx buffer filling with Tx characters. I have a logic analyzer on the Rx, Tx lines and can see char's on the Rx line but now the fread(...) does not return.
I am using ittya:, UART0, the Tx works, but not the Rx now. I enabled ittya: in user_config.h, it must be ok because the fwrite(...) works.
I thought this was non blocking, ie: that if there were no characters it would return 0, or the number it found with the buffer filled in. Is there something else that needs to be built / enabled to get this to work.