Skip to content

Commit 1541633

Browse files
committed
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.
1 parent 1346781 commit 1541633

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/deck/drivers/src/usddeck.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,13 @@ static void usdWriteData(const void *data, size_t size)
809809
{
810810
UINT bytesWritten;
811811
FRESULT status = f_write(&logFile, data, size, &bytesWritten);
812-
ASSERT(status == FR_OK);
813-
crc32Update(&crcContext, data, size);
814-
STATS_CNT_RATE_MULTI_EVENT(&fatWriteRate, bytesWritten);
812+
if (status != FR_OK) {
813+
DEBUG_PRINT("usd deck write failure %d\n", status);
814+
enableLogging = false;
815+
} else {
816+
crc32Update(&crcContext, data, size);
817+
STATS_CNT_RATE_MULTI_EVENT(&fatWriteRate, bytesWritten);
818+
}
815819
}
816820

817821
static void usdWriteTask(void* prm)

0 commit comments

Comments
 (0)