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:
parent
a598d06fe5
commit
57a6060005
3 changed files with 10 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue