Skip to content

Commit ecfe49c

Browse files
Lawrence NahumJamie C. Driver
authored andcommitted
esp32s3 serial: flush serial on esp32s3 no more often than needed
1 parent 570bf87 commit ecfe49c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

main/serial.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,6 @@ static bool write_serial(const uint8_t* msg, const size_t length, void* ignore)
204204
}
205205
written += wrote;
206206
}
207-
#ifdef CONFIG_IDF_TARGET_ESP32S3
208-
#ifndef CONFIG_JADE_USE_USB_JTAG_SERIAL
209-
return tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0) != ESP_OK;
210-
#else
211-
fflush(stdout);
212-
/* it is necessary to wait a little for fflush to have an effect before
213-
* fsync has all the data */
214-
vTaskDelay(10 / portTICK_PERIOD_MS);
215-
fsync(fileno(stdout));
216-
#endif
217-
#endif
218207
return true;
219208
}
220209

@@ -228,6 +217,18 @@ static void serial_writer(void* ignore)
228217
while (jade_process_get_out_message(&write_serial, SOURCE_SERIAL, NULL)) {
229218
// process messages
230219
}
220+
#ifdef CONFIG_IDF_TARGET_ESP32S3
221+
#ifndef CONFIG_JADE_USE_USB_JTAG_SERIAL
222+
/* if flush fails we ignore it */
223+
tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0);
224+
#else
225+
fflush(stdout);
226+
/* it is necessary to wait a little for fflush to have an effect before
227+
* fsync has all the data */
228+
vTaskDelay(10 / portTICK_PERIOD_MS);
229+
fsync(fileno(stdout));
230+
#endif
231+
#endif
231232
xTaskNotifyWait(0x00, ULONG_MAX, NULL, 100 / portTICK_PERIOD_MS);
232233
}
233234
post_exit_event_and_await_death(&writer_shutdown_done);

0 commit comments

Comments
 (0)