Skip to content

Commit

Permalink
esp32s3 serial: flush serial on esp32s3 no more often than needed
Browse files Browse the repository at this point in the history
  • Loading branch information
greenaddress authored and JamieDriver committed Nov 1, 2024
1 parent 570bf87 commit ecfe49c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions main/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,6 @@ static bool write_serial(const uint8_t* msg, const size_t length, void* ignore)
}
written += wrote;
}
#ifdef CONFIG_IDF_TARGET_ESP32S3
#ifndef CONFIG_JADE_USE_USB_JTAG_SERIAL
return tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0) != ESP_OK;
#else
fflush(stdout);
/* it is necessary to wait a little for fflush to have an effect before
* fsync has all the data */
vTaskDelay(10 / portTICK_PERIOD_MS);
fsync(fileno(stdout));
#endif
#endif
return true;
}

Expand All @@ -228,6 +217,18 @@ static void serial_writer(void* ignore)
while (jade_process_get_out_message(&write_serial, SOURCE_SERIAL, NULL)) {
// process messages
}
#ifdef CONFIG_IDF_TARGET_ESP32S3
#ifndef CONFIG_JADE_USE_USB_JTAG_SERIAL
/* if flush fails we ignore it */
tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0);
#else
fflush(stdout);
/* it is necessary to wait a little for fflush to have an effect before
* fsync has all the data */
vTaskDelay(10 / portTICK_PERIOD_MS);
fsync(fileno(stdout));
#endif
#endif
xTaskNotifyWait(0x00, ULONG_MAX, NULL, 100 / portTICK_PERIOD_MS);
}
post_exit_event_and_await_death(&writer_shutdown_done);
Expand Down

0 comments on commit ecfe49c

Please sign in to comment.