OTA_update_AVR_using_ESP32
OTA_update_AVR_using_ESP32 copied to clipboard
waitForSerialData timeout
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;
}