From 1541633d40a4c4f4e0339106c1ea481488360647 Mon Sep 17 00:00:00 2001 From: Wolfgang Hoenig Date: Fri, 24 Mar 2023 21:59:32 +0100 Subject: [PATCH] usddeck: improve error handling on write Instead of hitting an assert (and crash), we report an error and stop writing to the card. This can happen if the card is loose, even during flight. --- src/deck/drivers/src/usddeck.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/deck/drivers/src/usddeck.c b/src/deck/drivers/src/usddeck.c index c49081b54a..0ab01b84d8 100644 --- a/src/deck/drivers/src/usddeck.c +++ b/src/deck/drivers/src/usddeck.c @@ -809,9 +809,13 @@ static void usdWriteData(const void *data, size_t size) { UINT bytesWritten; FRESULT status = f_write(&logFile, data, size, &bytesWritten); - ASSERT(status == FR_OK); - crc32Update(&crcContext, data, size); - STATS_CNT_RATE_MULTI_EVENT(&fatWriteRate, bytesWritten); + if (status != FR_OK) { + DEBUG_PRINT("usd deck write failure %d\n", status); + enableLogging = false; + } else { + crc32Update(&crcContext, data, size); + STATS_CNT_RATE_MULTI_EVENT(&fatWriteRate, bytesWritten); + } } static void usdWriteTask(void* prm)