1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Prevent sdcard_getMetadata from being called when card is not inserted or not ready

This commit is contained in:
jflyper 2018-10-05 02:22:51 +09:00
parent a598d06fe5
commit 57a6060005
3 changed files with 10 additions and 4 deletions

View file

@ -304,8 +304,13 @@ static void serializeSDCardSummaryReply(sbuf_t *dst)
sbufWriteU8(dst, state);
sbufWriteU8(dst, afatfs_getLastError());
// Write free space and total space in kilobytes
sbufWriteU32(dst, afatfs_getContiguousFreeSpace() / 1024);
sbufWriteU32(dst, sdcard_getMetadata()->numBlocks / 2); // Block size is half a kilobyte
if (state == MSP_SDCARD_STATE_READY) {
sbufWriteU32(dst, afatfs_getContiguousFreeSpace() / 1024);
sbufWriteU32(dst, sdcard_getMetadata()->numBlocks / 2); // Block size is half a kilobyte
} else {
sbufWriteU32(dst, 0);
sbufWriteU32(dst, 0);
}
#else
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);