mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-21 07:09:48 -05:00
Faster usb serial file download (#1674)
* Made file read much faster via USB serial * Remove old code
This commit is contained in:
parent
459e8d0b24
commit
7bf3e02f6c
@ -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;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user