sync
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <usb.h>
|
||||
#include <protocol.h>
|
||||
#include <audio.h>
|
||||
|
||||
#define PROTOCOL_VERSION 1
|
||||
|
||||
@@ -44,7 +45,7 @@ int send_ls(const char *path)
|
||||
const char *ls_path = (path == NULL || path[0] == '\0') ? "/" : path;
|
||||
fs_dir_t_init(&dirp);
|
||||
|
||||
if (fs_opendir(&dirp, ls_path) < 0)
|
||||
if (fs_pm_opendir(&dirp, ls_path) < 0)
|
||||
{
|
||||
LOG_ERR("Failed to open directory '%s'", ls_path);
|
||||
return ENOENT;
|
||||
@@ -57,7 +58,7 @@ int send_ls(const char *path)
|
||||
usb_write_buffer((const uint8_t *)tx_buffer, strlen(tx_buffer));
|
||||
}
|
||||
|
||||
fs_closedir(&dirp);
|
||||
fs_pm_closedir(&dirp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
fs_file_t_init(&file);
|
||||
fs_unlink(filename);
|
||||
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);
|
||||
rc = fs_pm_open(&file, filename, FS_O_CREATE | FS_O_WRITE);
|
||||
if (rc < 0)
|
||||
{
|
||||
LOG_ERR("Failed to open file '%s' for writing: %d", filename, rc);
|
||||
@@ -109,7 +110,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
if (read < 0)
|
||||
{
|
||||
LOG_ERR("Error reading from USB: %d", read);
|
||||
fs_close(&file);
|
||||
fs_pm_close(&file);
|
||||
return -read;
|
||||
}
|
||||
else if (read == 0)
|
||||
@@ -117,7 +118,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
if (retry_count >= 10)
|
||||
{
|
||||
LOG_ERR("No data received from USB after multiple attempts");
|
||||
fs_close(&file);
|
||||
fs_pm_close(&file);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
if (written < 0)
|
||||
{
|
||||
LOG_ERR("Error writing to file '%s': %d", filename, (int)written);
|
||||
fs_close(&file);
|
||||
fs_pm_close(&file);
|
||||
return (int)written;
|
||||
}
|
||||
|
||||
@@ -163,7 +164,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr
|
||||
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);
|
||||
fs_pm_close(&file);
|
||||
LOG_DBG("Closed file '%s' after writing", filename);
|
||||
if (running_crc32 != expected_crc32)
|
||||
{
|
||||
@@ -224,6 +225,7 @@ void execute_current_command(void)
|
||||
if (rc == 0)
|
||||
{
|
||||
send_ok();
|
||||
audio_refresh_file_count(); // Nach erfolgreichem Upload die Anzahl der verfügbaren Audiodateien aktualisieren
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user