Azure / embedded-wireless-framework

Microsoft's Embedded Wireless Framework is a design concept that enables users to abstract application code from host port drivers and communication adapter drivers primarily in microcontroller-based projects.
MIT License
63 stars 31 forks source link

Buffer full error when using RYZ014A with RX MCU #16

Closed KeitaKashima closed 1 year ago

KeitaKashima commented 1 year ago

All of EWF projects for RX has an issue not to communicate the RYZ014A module when disable the "debug log". The cause of issue is that R_SCI_Send API is called quite frequently then, the API has an error of internal buffer full and returned error.

The below Line should be changed to wait sometime when the error happen.

https://github.com/Azure/embedded-wireless-framework/blob/1.0.0-preview.2.renesas.rx/src/ewf_interface_rx_uart.c#L143

Below is the proposal code. It adds the wait and retry there.

uint32_t local_retry = (length * UINT16_MAX);
    do {
        err = R_SCI_Send(ewf_rx_sci_handle, (uint8_t*) buffer, length);
        if(SCI_SUCCESS != err)
        {
            tx_thread_sleep(10);       
        }
       local_retry--;
    } while ((SCI_SUCCESS != err) && (0 < local_retry));
    if (SCI_SUCCESS != err)
    {
        return EWF_RESULT_ADAPTER_TRANSMIT_FAILED;
    }
    /* Check for event transfer complete */    while ((SCI_EVT_TEI != g_uart_event) && (--local_timeout))
    {
        /* Check if any error event occurred */        if (UART_ERROR_EVENTS == g_uart_event)
        {
            return EWF_RESULT_ADAPTER_TRANSMIT_FAILED;
        }
    }
    if (0 == local_timeout)
    {
        return EWF_RESULT_TIMEOUT;
    }
    /* All ok! */    return EWF_RESULT_OK;
bhnaphade commented 1 year ago

Updated the code.