mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Fixed writing of empty signature.
This commit is contained in:
parent
0bf4708033
commit
b4c44d8a46
1 changed files with 20 additions and 18 deletions
|
@ -2284,8 +2284,8 @@ static void cliSignature(char *cmdline)
|
||||||
const unsigned int len = strlen(cmdline);
|
const unsigned int len = strlen(cmdline);
|
||||||
|
|
||||||
char signatureStr[SIGNATURE_LENGTH * 2 + 1] = {0};
|
char signatureStr[SIGNATURE_LENGTH * 2 + 1] = {0};
|
||||||
if (len > 0) {
|
|
||||||
uint8_t signature[SIGNATURE_LENGTH];
|
uint8_t signature[SIGNATURE_LENGTH];
|
||||||
|
if (len > 0) {
|
||||||
#define BLOCK_SIZE 2
|
#define BLOCK_SIZE 2
|
||||||
for (unsigned i = 0; i < SIGNATURE_LENGTH; i++) {
|
for (unsigned i = 0; i < SIGNATURE_LENGTH; i++) {
|
||||||
char temp[BLOCK_SIZE + 1];
|
char temp[BLOCK_SIZE + 1];
|
||||||
|
@ -2294,23 +2294,25 @@ static void cliSignature(char *cmdline)
|
||||||
signature[i] = strtoul(temp, NULL, 16);
|
signature[i] = strtoul(temp, NULL, 16);
|
||||||
}
|
}
|
||||||
#undef BLOCK_SIZE
|
#undef BLOCK_SIZE
|
||||||
if (signatureIsSet() && memcmp(signature, getSignature(), SIGNATURE_LENGTH)) {
|
}
|
||||||
|
|
||||||
|
if (len > 0 && signatureIsSet() && memcmp(signature, getSignature(), SIGNATURE_LENGTH)) {
|
||||||
writeSignature(signatureStr, getSignature());
|
writeSignature(signatureStr, getSignature());
|
||||||
cliPrintLinef(ERROR_MESSAGE, "signature", signatureStr);
|
cliPrintLinef(ERROR_MESSAGE, "signature", signatureStr);
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
setSignature(signature);
|
setSignature(signature);
|
||||||
|
|
||||||
signatureUpdated = true;
|
signatureUpdated = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeSignature(signatureStr, getSignature());
|
writeSignature(signatureStr, getSignature());
|
||||||
|
} else if (signatureUpdated || signatureIsSet()) {
|
||||||
|
writeSignature(signatureStr, getSignature());
|
||||||
|
}
|
||||||
|
|
||||||
cliPrintLinef("signature %s", signatureStr);
|
cliPrintLinef("signature %s", signatureStr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef ERROR_MESSAGE
|
#undef ERROR_MESSAGE
|
||||||
|
@ -4089,13 +4091,13 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
#if defined(USE_BOARD_INFO)
|
#if defined(USE_BOARD_INFO)
|
||||||
cliBoardName("");
|
cliBoardName("");
|
||||||
cliManufacturerId("");
|
cliManufacturerId("");
|
||||||
#if defined(USE_SIGNATURE)
|
|
||||||
cliSignature("");
|
|
||||||
#endif
|
#endif
|
||||||
#endif // USE_BOARD_INFO
|
|
||||||
|
|
||||||
if (dumpMask & DUMP_ALL) {
|
if (dumpMask & DUMP_ALL) {
|
||||||
cliMcuId(NULL);
|
cliMcuId(NULL);
|
||||||
|
#if defined(USE_BOARD_INFO) && defined(USE_SIGNATURE)
|
||||||
|
cliSignature("");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) {
|
if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue