1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Fixed reporting of SD card when not configured.

This commit is contained in:
mikeller 2019-08-04 15:45:50 +12:00
parent 08e6ae39ab
commit 14994afad5

View file

@ -157,7 +157,7 @@ typedef enum {
} mspSDCardState_e; } mspSDCardState_e;
typedef enum { typedef enum {
MSP_SDCARD_FLAG_SUPPORTTED = 1 MSP_SDCARD_FLAG_SUPPORTED = 1
} mspSDCardFlags_e; } mspSDCardFlags_e;
typedef enum { typedef enum {
@ -296,11 +296,15 @@ static void mspRebootFn(serialPort_t *serialPort)
static void serializeSDCardSummaryReply(sbuf_t *dst) static void serializeSDCardSummaryReply(sbuf_t *dst)
{ {
#ifdef USE_SDCARD uint8_t flags = 0;
uint8_t flags = MSP_SDCARD_FLAG_SUPPORTTED;
uint8_t state = 0; uint8_t state = 0;
uint8_t lastError = 0;
uint32_t freeSpace = 0;
uint32_t totalSpace = 0;
sbufWriteU8(dst, flags); #if defined(USE_SDCARD)
if (sdcardConfig()->mode) {
flags = MSP_SDCARD_FLAG_SUPPORTED;
// Merge the card and filesystem states together // Merge the card and filesystem states together
if (!sdcard_isInserted()) { if (!sdcard_isInserted()) {
@ -329,23 +333,20 @@ static void serializeSDCardSummaryReply(sbuf_t *dst)
} }
} }
sbufWriteU8(dst, state); lastError = afatfs_getLastError();
sbufWriteU8(dst, afatfs_getLastError());
// Write free space and total space in kilobytes // Write free space and total space in kilobytes
if (state == MSP_SDCARD_STATE_READY) { if (state == MSP_SDCARD_STATE_READY) {
sbufWriteU32(dst, afatfs_getContiguousFreeSpace() / 1024); freeSpace = afatfs_getContiguousFreeSpace() / 1024;
sbufWriteU32(dst, sdcard_getMetadata()->numBlocks / 2); // Block size is half a kilobyte totalSpace = sdcard_getMetadata()->numBlocks / 2;
} else { }
sbufWriteU32(dst, 0);
sbufWriteU32(dst, 0);
} }
#else
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
sbufWriteU32(dst, 0);
sbufWriteU32(dst, 0);
#endif #endif
sbufWriteU8(dst, flags);
sbufWriteU8(dst, state);
sbufWriteU8(dst, lastError);
sbufWriteU32(dst, freeSpace);
sbufWriteU32(dst, totalSpace);
} }
static void serializeDataflashSummaryReply(sbuf_t *dst) static void serializeDataflashSummaryReply(sbuf_t *dst)