Thanks for reaching out.
Well, I'm not sure if it is possible to know the number of received bytes, but did you try with MAX_BUF instead of 1 on the functions uart_read and host send?
The function uart_read returns 0 if it is successful, I think that you get garbage because you are using the if with >=0.
With all that said, I recommend you to use the following lines:
if (uart_read(1, &buf_r, MAX_BUF)==0) host_send(&buf_r, MAX_BUF);
Let me know if it works.
Thanks for the answer.
I try it and in this case uart_read is blocking (wait until it is read MAX_BUF bytes). Changing >=0 to ==0 also did not help: uart_read always return 0, even if in reality the data has not been sent to the UART (Therefore, I can not understand what has been read - data or garbage).
I think this is not possible with the APIs to access UART, I recommend you to use another GPIO as a flag, that indicates when the data is in the port.
You can also check the example to read from UART in your folder: MCU_SDK_HOME/docs/api_doc/html/sample__uart__receive_8c_source.html, it is the only information available to read data from UART.
I hope you find this information useful.