mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 15:55:48 +03:00
Merge pull request #6882 from jflyper/bfdev-fix-msp-from-calling-sdcard_getMetadata-when-card-is-not-present
SDCARD: Prevent msp from calling sdcard_getMetadata when card is not ready
This commit is contained in:
commit
ba05be54b1
3 changed files with 10 additions and 4 deletions
|
@ -150,7 +150,8 @@ bool sdcard_poll(void)
|
||||||
|
|
||||||
bool sdcard_isFunctional(void)
|
bool sdcard_isFunctional(void)
|
||||||
{
|
{
|
||||||
// sdcard_isFunctional is called from multiple places
|
// sdcard_isFunctional is called from multiple places, including the case of hardware implementation
|
||||||
|
// without a detect pin in which case sdcard_isInserted() always returns true.
|
||||||
if (sdcardVTable) {
|
if (sdcardVTable) {
|
||||||
return sdcardVTable->sdcard_isFunctional();
|
return sdcardVTable->sdcard_isFunctional();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1999,7 +1999,7 @@ static void cliSdInfo(char *cmdline)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sdcard_isInitialized()) {
|
if (!sdcard_isFunctional() || !sdcard_isInitialized()) {
|
||||||
cliPrintLine("Startup failed");
|
cliPrintLine("Startup failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,8 +304,13 @@ static void serializeSDCardSummaryReply(sbuf_t *dst)
|
||||||
sbufWriteU8(dst, state);
|
sbufWriteU8(dst, state);
|
||||||
sbufWriteU8(dst, 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) {
|
||||||
sbufWriteU32(dst, afatfs_getContiguousFreeSpace() / 1024);
|
sbufWriteU32(dst, afatfs_getContiguousFreeSpace() / 1024);
|
||||||
sbufWriteU32(dst, sdcard_getMetadata()->numBlocks / 2); // Block size is half a kilobyte
|
sbufWriteU32(dst, sdcard_getMetadata()->numBlocks / 2); // Block size is half a kilobyte
|
||||||
|
} else {
|
||||||
|
sbufWriteU32(dst, 0);
|
||||||
|
sbufWriteU32(dst, 0);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
sbufWriteU8(dst, 0);
|
sbufWriteU8(dst, 0);
|
||||||
sbufWriteU8(dst, 0);
|
sbufWriteU8(dst, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue