Problem while reading response from Ql_UART_GetOption function for UART_TX_BUF_SEND_OUT parameter

Hi,

I am trying to make M66 OpenCPU as ModBus Master device, I want to control pin of SP3485 pin which is connected to GPIO of M66,
while trying to read status of UART3 whether all data is sent out or not, I am calling Ql_UART_GetOption this function with UART_TX_BUF_SEND_OUT as parameter, I am getting always -10000 response that is Ql_RET_NOT_SUPPORT,

Is there any example of this Ql_UART_GetOption function?
below is my code:
void waitTillSendDataOut(void)
{
s32 ret_val = 0;s32 count = 0;
u64 prev_millis = Ql_GetMsSincePwrOn();
while((Ql_GetMsSincePwrOn() - prev_millis) < 20)
{
count++;
ret_val = Ql_UART_GetOption(UART_PORT3,UART_TX_BUF_SEND_OUT, NULL);
APP_DEBUG(“Data Sent Status:%d Count:%d\r\n”, ret_val,count);
if(ret_val == QL_RET_OK)
{
APP_DEBUG(“Data has been sent out\r\n”);
break;
}
}
}

regards

1 Like

SDK did not add this interface, or SDK added but the kernel did not add, so it returns -10000.

Do you any example for this ?
I want to know status of UART data is sent out completely or not. i.e. TX buffer is empty or not.

The API Ql_UART_GetOption exists in the SDK, but this API is not actually implemented in the kernel, so querying in this way is not supported, and -10000 will be returned when used, and there is no related example.

I’m trying to implement the same funcionality and as far i understand there is no way to figure out when all data have been transmited, as there is neither a callback, neither an event. Hardware flow is also impossible to use, as RTS is input, i.e. uses legacy HW flow. Please Quectel, add support for this!

@proembsys
I suggest the following method to control the direction pin, which i have not yet tested.
Use GPIO for that purpose. Use the same function, but with argument UART_TX_BUF_LEFT_ROOM - it will return how many bytes are available in the TX fifo.

  1. clear TX FIFO
  2. call Ql_UART_GetOption(port, UART_TX_BUF_LEFT_ROOM, &bytesFree)
  3. send out your data
  4. in a while loop call the same function (2) until the returned bytes count is equal to bytesFree.

@Milenski I have tried this method, I always get 0 bytes by calling Ql_UART_GetOption(port, UART_TX_BUF_LEFT_ROOM, &bytesFree)

So I decided to use some other MCU which will do only ModBus communication in my circuit.

Regards