Rui_uart_recv function not working

I Used void rui_uart_recv(RUI_UART_DEF uart_def, uint8_t *pdata, uint16_t len) this Function.

above function is used as below. where Buffer I define as
uint8_t *Buffer;
rui_uart_recv(RUI_UART1, Buffer, 1 );

and mode i Define as
rui_uart_mode_config(RUI_UART1, RUI_UART_UNVARNISHED);

when I send data through the terminal I did not get my send data. I get Error 86.

My question is how can I Receive my send data using UART.?
which rui_uart_mode_config i configure?
which UART1 or UART3 used?

There may be several issues here.

But first uint8_t *Buffer does not define a buffer, but merely a pointer which could point to one. But unless you do something else, it will point nowhere.

What you probably want is something like uint8_t Buffer[64] or whatever a reasonable length is. If you really only wanted one byte then you sould do something like:

uint8_t rx_byte;
rui_uart_recv(RUI_UART1, &rx_byte, 1 );

Where the function would fill in the value of that variable. But only do that if the 1 in the above means it will write a maximum of one byte (it appears to, but I’m not familiar with RUI, so its up to you to check).

But that may not be your only challenge. You probably need to check the return value of the function to see if it got anything. And if it is not reading the UART in an interrupt and buffering behind the scenes, you’d also need to make sure you were polling it frequently enough. Of course there are the configuration issues you raised, too.

I suspect your best path would be to try to find an example under RUI that reads from a UART for any purpose and study that and then try to adapt it to your specific need.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.