Faster usb serial file download (#1674)

* Made file read much faster via USB serial
* Remove old code
This commit is contained in:
Totoo 2023-12-25 17:25:16 +01:00 committed by GitHub
parent 459e8d0b24
commit 7bf3e02f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -418,21 +418,18 @@ static void cmd_sd_read(BaseSequentialStream* chp, int argc, char* argv[]) {
int size = (int)strtol(argv[0], NULL, 10); int size = (int)strtol(argv[0], NULL, 10);
uint8_t buffer[16]; uint8_t buffer[62];
do { 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); auto bytes_read = shell_file->read(buffer, bytes_to_read);
if (bytes_read.is_error()) { if (bytes_read.is_error()) {
chprintf(chp, "error %d\r\n", bytes_read.error()); chprintf(chp, "error %d\r\n", bytes_read.error());
return; return;
} }
std::string res = to_string_hex_array(buffer, bytes_read.value());
for (size_t i = 0; i < bytes_read.value(); i++) res += "\r\n";
chprintf(chp, "%02X", buffer[i]); fillOBuffer(&((SerialUSBDriver*)chp)->oqueue, (const uint8_t*)res.c_str(), res.size());
chprintf(chp, "\r\n");
if (bytes_to_read != bytes_read.value()) if (bytes_to_read != bytes_read.value())
return; return;