From 7bf3e02f6c2b66568afb0b45b8a1a6576030b524 Mon Sep 17 00:00:00 2001 From: Totoo Date: Mon, 25 Dec 2023 17:25:16 +0100 Subject: [PATCH] Faster usb serial file download (#1674) * Made file read much faster via USB serial * Remove old code --- firmware/application/usb_serial_shell.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/firmware/application/usb_serial_shell.cpp b/firmware/application/usb_serial_shell.cpp index 4a37ae7eb..c7a3516a5 100644 --- a/firmware/application/usb_serial_shell.cpp +++ b/firmware/application/usb_serial_shell.cpp @@ -418,21 +418,18 @@ static void cmd_sd_read(BaseSequentialStream* chp, int argc, char* argv[]) { int size = (int)strtol(argv[0], NULL, 10); - uint8_t buffer[16]; + uint8_t buffer[62]; do { - File::Size bytes_to_read = size > 16 ? 16 : size; + File::Size bytes_to_read = size > 62 ? 62 : size; auto bytes_read = shell_file->read(buffer, bytes_to_read); if (bytes_read.is_error()) { chprintf(chp, "error %d\r\n", bytes_read.error()); return; } - - for (size_t i = 0; i < bytes_read.value(); i++) - chprintf(chp, "%02X", buffer[i]); - - chprintf(chp, "\r\n"); - + std::string res = to_string_hex_array(buffer, bytes_read.value()); + res += "\r\n"; + fillOBuffer(&((SerialUSBDriver*)chp)->oqueue, (const uint8_t*)res.c_str(), res.size()); if (bytes_to_read != bytes_read.value()) return;