OTA_update_AVR_using_ESP32 icon indicating copy to clipboard operation
OTA_update_AVR_using_ESP32 copied to clipboard

waitForSerialData timeout

Open zama737 opened this issue 1 year ago • 1 comments

Noticed time out in waitForSerialData seems not to work as expected. In case MAX_DELAY_MS is intended to be 1000ms, function has 250ms for timer, so timeout is multiplied by 250x.

 int sendBytes(char *bytes, int count)
{
    sendData(TAG_AVR_PRO, bytes, count);
    int length = waitForSerialData(MIN_DELAY_MS, MAX_DELAY_MS);

    if (length > 0)
    {
   
int waitForSerialData(int dataCount, int timeout)
{
    int timer = 0;
    int length = 0;
    while (timer < timeout)
    {
        uart_get_buffered_data_len(UART_NUM_1, (size_t *)&length);
        if (length >= dataCount)
        {
            return length;
        }
        vTaskDelay(250 / portTICK_PERIOD_MS);
        timer++;
    }
    return 0;
}

zama737 avatar Dec 09 '22 20:12 zama737