sync
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# core/connection.py
|
||||
import serial
|
||||
import time
|
||||
import os
|
||||
|
||||
class BuzzerError(Exception):
|
||||
pass
|
||||
|
||||
@@ -83,7 +83,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
uint32_t retry_count = 0;
|
||||
|
||||
fs_file_t_init(&file);
|
||||
|
||||
LOG_DBG("Opening file '%s' for writing (expected size: %zd bytes, expected CRC32: 0x%08x)", filename, filesize, expected_crc32);
|
||||
rc = fs_open(&file, filename, FS_O_CREATE | FS_O_WRITE);
|
||||
if (rc < 0)
|
||||
{
|
||||
@@ -93,6 +93,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
|
||||
usb_write_buffer((const uint8_t *)"READY\n", 6);
|
||||
|
||||
uint32_t start = k_uptime_get_32();
|
||||
while (bytes_written < filesize)
|
||||
{
|
||||
size_t to_write = MIN(sizeof(buffer), filesize - bytes_written);
|
||||
@@ -140,7 +141,9 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
|
||||
bytes_written += written;
|
||||
}
|
||||
|
||||
uint32_t duration = k_uptime_get_32() - start;
|
||||
uint32_t kb_per_s = (filesize * 1000) / (duration * 1024 +1);
|
||||
LOG_DBG("Received file '%s' (%zd bytes) in %u ms (%u kb/s), CRC32: 0x%08x", filename, filesize, duration, kb_per_s, running_crc32);
|
||||
fs_close(&file);
|
||||
|
||||
if (running_crc32 != expected_crc32)
|
||||
|
||||
Reference in New Issue
Block a user