mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Fixes from review.
This commit is contained in:
parent
b4c44d8a46
commit
432f330e60
3 changed files with 19 additions and 19 deletions
|
@ -47,12 +47,12 @@ void initBoardInformation(void)
|
|||
}
|
||||
}
|
||||
|
||||
char *getManufacturerId(void)
|
||||
const char *getManufacturerId(void)
|
||||
{
|
||||
return manufacturerId;
|
||||
}
|
||||
|
||||
char *getBoardName(void)
|
||||
const char *getBoardName(void)
|
||||
{
|
||||
return boardName;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ bool boardInformationIsSet(void)
|
|||
return boardInformationSet;
|
||||
}
|
||||
|
||||
bool setManufacturerId(char *newManufacturerId)
|
||||
bool setManufacturerId(const char *newManufacturerId)
|
||||
{
|
||||
if (!boardInformationSet) {
|
||||
strncpy(manufacturerId, newManufacturerId, MAX_MANUFACTURER_ID_LENGTH);
|
||||
|
@ -73,7 +73,7 @@ bool setManufacturerId(char *newManufacturerId)
|
|||
}
|
||||
}
|
||||
|
||||
bool setBoardName(char *newBoardName)
|
||||
bool setBoardName(const char *newBoardName)
|
||||
{
|
||||
if (!boardInformationSet) {
|
||||
strncpy(boardName, newBoardName, MAX_BOARD_NAME_LENGTH);
|
||||
|
@ -100,7 +100,7 @@ bool persistBoardInformation(void)
|
|||
}
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
uint8_t *getSignature(void)
|
||||
const uint8_t *getSignature(void)
|
||||
{
|
||||
return signature;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ bool signatureIsSet(void)
|
|||
return signatureSet;
|
||||
}
|
||||
|
||||
bool setSignature(uint8_t *newSignature)
|
||||
bool setSignature(const uint8_t *newSignature)
|
||||
{
|
||||
if (!signatureSet) {
|
||||
memcpy(signature, newSignature, SIGNATURE_LENGTH);
|
||||
|
|
|
@ -2323,11 +2323,7 @@ static void cliMcuId(char *cmdline)
|
|||
{
|
||||
UNUSED(cmdline);
|
||||
|
||||
cliPrint("mcu_id 0x");
|
||||
cliPrintf("%08x", U_ID_0);
|
||||
cliPrintf("%08x", U_ID_1);
|
||||
cliPrintf("%08x", U_ID_2);
|
||||
cliPrintLinefeed();
|
||||
cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2);
|
||||
}
|
||||
|
||||
static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault)
|
||||
|
|
|
@ -464,12 +464,12 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
|||
// Board name with explicit length
|
||||
char *value = getBoardName();
|
||||
sbufWriteU8(dst, strlen(value));
|
||||
sbufWriteData(dst, value, strlen(value));
|
||||
sbufWriteString(dst, value);
|
||||
|
||||
// Manufacturer id with explicit length
|
||||
value = getManufacturerId();
|
||||
sbufWriteU8(dst, strlen(value));
|
||||
sbufWriteData(dst, value, strlen(value));
|
||||
sbufWriteString(dst, value);
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
// Signature
|
||||
|
@ -2078,16 +2078,20 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
#if defined(USE_BOARD_INFO)
|
||||
case MSP_SET_BOARD_INFO:
|
||||
if (!boardInformationIsSet()) {
|
||||
char boardName[MAX_BOARD_NAME_LENGTH + 1] = {0};
|
||||
char manufacturerId[MAX_MANUFACTURER_ID_LENGTH + 1] = {0};
|
||||
uint8_t length = sbufReadU8(src);
|
||||
for (unsigned int i = 0; i < length; i++) {
|
||||
boardName[i] = sbufReadU8(src);
|
||||
char boardName[MAX_BOARD_NAME_LENGTH + 1];
|
||||
sbufReadData(src, boardName, MIN(length, MAX_BOARD_NAME_LENGTH));
|
||||
if (length > MAX_BOARD_NAME_LENGTH) {
|
||||
sbufAdvance(src, length - MAX_BOARD_NAME_LENGTH);
|
||||
}
|
||||
boardName[length] = '\0';
|
||||
length = sbufReadU8(src);
|
||||
for (unsigned int i = 0; i < length; i++) {
|
||||
manufacturerId[i] = sbufReadU8(src);
|
||||
char manufacturerId[MAX_MANUFACTURER_ID_LENGTH + 1];
|
||||
sbufReadData(src, manufacturerId, MIN(length, MAX_MANUFACTURER_ID_LENGTH));
|
||||
if (length > MAX_MANUFACTURER_ID_LENGTH) {
|
||||
sbufAdvance(src, length - MAX_MANUFACTURER_ID_LENGTH);
|
||||
}
|
||||
manufacturerId[length] = '\0';
|
||||
|
||||
setBoardName(boardName);
|
||||
setManufacturerId(manufacturerId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue