mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Fixes after feedback
This commit is contained in:
parent
c04e6a4bd7
commit
1ee8224706
4 changed files with 21 additions and 16 deletions
|
@ -24,7 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define MAX_RATEPROFILES 3
|
#define MAX_RATEPROFILES 3
|
||||||
#define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS 1500
|
#define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS 1500
|
||||||
#define MAX_NAME_LENGTH 32
|
#define MAX_NAME_LENGTH 16
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -162,7 +162,7 @@ typedef struct master_t {
|
||||||
uint8_t magic_ef; // magic number, should be 0xEF
|
uint8_t magic_ef; // magic number, should be 0xEF
|
||||||
uint8_t chk; // XOR checksum
|
uint8_t chk; // XOR checksum
|
||||||
|
|
||||||
char name[MAX_NAME_LENGTH];
|
char name[MAX_NAME_LENGTH+1];
|
||||||
|
|
||||||
} master_t;
|
} master_t;
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ const clicmd_t cmdTable[] = {
|
||||||
#ifdef VTX
|
#ifdef VTX
|
||||||
CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx),
|
CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx),
|
||||||
#endif
|
#endif
|
||||||
CLI_COMMAND_DEF("name", "Name of vessel", NULL, cliName),
|
CLI_COMMAND_DEF("name", "Name of craft", NULL, cliName),
|
||||||
};
|
};
|
||||||
#define CMD_COUNT (sizeof(cmdTable) / sizeof(clicmd_t))
|
#define CMD_COUNT (sizeof(cmdTable) / sizeof(clicmd_t))
|
||||||
|
|
||||||
|
@ -1955,7 +1955,8 @@ static void cliDump(char *cmdline)
|
||||||
cliPrint("\r\n# version\r\n");
|
cliPrint("\r\n# version\r\n");
|
||||||
cliVersion(NULL);
|
cliVersion(NULL);
|
||||||
|
|
||||||
cliName("");
|
cliPrint("\r\n# name\r\n");
|
||||||
|
cliName(NULL);
|
||||||
cliPrint("\r\n# dump master\r\n");
|
cliPrint("\r\n# dump master\r\n");
|
||||||
cliPrint("\r\n# mixer\r\n");
|
cliPrint("\r\n# mixer\r\n");
|
||||||
|
|
||||||
|
@ -2501,16 +2502,15 @@ static void cliName(char *cmdline)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32_t len = strlen(cmdline);
|
uint32_t len = strlen(cmdline);
|
||||||
if (isEmpty(cmdline)) {
|
if (*cmdline == 0) {
|
||||||
cliPrintf("name %s\r\n", masterConfig.name);
|
|
||||||
} else if (len <= MAX_NAME_LENGTH) {
|
|
||||||
strcpy(masterConfig.name, cmdline);
|
|
||||||
for (uint8_t i = len; i<MAX_NAME_LENGTH; i++) {
|
|
||||||
masterConfig.name[i] = '\0';
|
|
||||||
}
|
|
||||||
cliPrintf("name %s\r\n", masterConfig.name);
|
cliPrintf("name %s\r\n", masterConfig.name);
|
||||||
|
} else if ('-' == cmdline[0]) {
|
||||||
|
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||||
|
cliPrintf("name removed\r\n");
|
||||||
} else {
|
} else {
|
||||||
cliPrintf("Max allowed name length is %d\r\n", MAX_NAME_LENGTH);
|
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||||
|
strncpy(masterConfig.name, cmdline, MIN(len, MAX_NAME_LENGTH));
|
||||||
|
cliPrintf("name %s\r\n", masterConfig.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -659,7 +659,7 @@ static uint32_t packFlightModeFlags(void)
|
||||||
static bool processOutCommand(uint8_t cmdMSP)
|
static bool processOutCommand(uint8_t cmdMSP)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
uint8_t len;
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
uint8_t wp_no;
|
uint8_t wp_no;
|
||||||
int32_t lat = 0, lon = 0;
|
int32_t lat = 0, lon = 0;
|
||||||
|
@ -751,8 +751,9 @@ static bool processOutCommand(uint8_t cmdMSP)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_NAME:
|
case MSP_NAME:
|
||||||
headSerialReply(MAX_NAME_LENGTH);
|
len = strlen(masterConfig.name);
|
||||||
for (uint8_t i=0; i<MAX_NAME_LENGTH; i++) {
|
headSerialReply(len);
|
||||||
|
for (uint8_t i=0; i<len; i++) {
|
||||||
serialize8(masterConfig.name[i]);
|
serialize8(masterConfig.name[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1877,9 +1878,13 @@ static bool processInCommand(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_NAME:
|
case MSP_SET_NAME:
|
||||||
for (i = 0; i < MAX_NAME_LENGTH; i++) {
|
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||||
|
for (i = 0; i < MIN(MAX_NAME_LENGTH, currentPort->dataSize); i++) {
|
||||||
masterConfig.name[i] = read8();
|
masterConfig.name[i] = read8();
|
||||||
}
|
}
|
||||||
|
if (masterConfig.name[0] == '-') {
|
||||||
|
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// we do not know how to handle the (valid) message, indicate error MSP $M!
|
// we do not know how to handle the (valid) message, indicate error MSP $M!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue