M66 Uart receive without delay

I know how to read data from OpenCPU UART
I registered and opened the UART in main thread and use it in other thread. So i don’t need to implement QL_OS_GetMessage in that thread.
but my problem is that the UART receive callback when i use QL_Sleep() in my thread so the main thread can handle new system messages.
Is there a way to not use Ql_Sleep and receive uart callbacks? Ql_Sleep time is so much (1ms is big time for me) is there any way to make main thread to check UART received data?

Dear Ahmadreza_Hadidi

What is the detailed model number of the module you are using?What version of SDK is used?There is no need to add a delay to the callback function to read the data. After entering the backfill function, the data is ready to be read directly.

Thank for your response Grey
Im using the latest SDK 2.4 and firmware M66FAR02A07BT
My problem in UART is that if i use write data to UART or want to receive data from UART it should be done with QL_OS_GetMessage
Example: I write some data to UART with QL_UART_Write, it will not send until a Ql_Sleep called. I test it in a situation, i want to send data by UART one by one with this code:

for (int i=0; i<10; i++) {
Ql_UART_Write(UART_PORT1, &data, 1);

if i dont use Ql_Sleep in for loop the whole data will be send in next Ql_Sleep or end of callback function
Its true also for UART receive callback. There will be no callback untill QL_OS_GetMessage called.

is there a function to use to flush UART data immediately or check UART receive buffer without waiting for callbacks.

(Sorry for my bad English)

Dear Ahmadreza_Hadidi

You can actually use UART to send multiple pieces of data and you can pass the parameters directly to the QL_UART_WRITE API, you don’t have to go through a for loop and send it byte by byte, you can just pass it to an array.Example: Ql_UART_Write((enum_serialPort)(DEBUG_PORT), (u8*)(DBG_BUFFER), Ql_strlen((const char *)(DBG_BUFFER)));

Void Callback_UART_Hdlr(enum_serialPort port, enum_uartEventType MSG, bool level, void* param);This process is included in the Demo given on the official website, please check the official Demo. Thank you.

use ring-buffer … example

QL_OS_GetMessage is very important - without this you can not get UART callback