1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

Set MINIMAL_CLI to be default for F3. Added more size reductions to MINIMAL_CLI.

This commit is contained in:
mikeller 2017-01-22 17:29:39 +13:00 committed by borisbstyle
parent b24cdcdbd3
commit 990c13b7ea
3 changed files with 36 additions and 41 deletions

View file

@ -821,7 +821,7 @@ static void cliPrint(const char *str)
bufWriterFlush(cliWriter); bufWriterFlush(cliWriter);
} }
#ifdef CLI_MINIMAL_VERBOSITY #ifdef MINIMAL_CLI
#define cliPrintHashLine(str) #define cliPrintHashLine(str)
#else #else
static void cliPrintHashLine(const char *str) static void cliPrintHashLine(const char *str)
@ -1082,7 +1082,7 @@ static void cliSetVar(const clivalue_t *var, const int_float_value_t value)
} }
} }
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
static void cliRepeat(char ch, uint8_t len) static void cliRepeat(char ch, uint8_t len)
{ {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
@ -1104,7 +1104,7 @@ static void cliShowParseError(void)
static void cliShowArgumentRangeError(char *name, int min, int max) static void cliShowArgumentRangeError(char *name, int min, int max)
{ {
cliPrintf("%s must be between %d and %d\r\n", name, min, max); cliPrintf("%s not between %d and %d\r\n", name, min, max);
} }
static char *nextArg(char *currentArg) static char *nextArg(char *currentArg)
@ -1497,7 +1497,7 @@ static void cliSerialPassthrough(char *cmdline)
serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id); serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) { if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
if (!baud) { if (!baud) {
printf("Port %d is not open, you must specify baud\r\n", id); printf("Port %d is closed, must specify baud.\r\n", id);
return; return;
} }
if (!mode) if (!mode)
@ -1507,30 +1507,29 @@ static void cliSerialPassthrough(char *cmdline)
baud, mode, baud, mode,
SERIAL_NOT_INVERTED); SERIAL_NOT_INVERTED);
if (!passThroughPort) { if (!passThroughPort) {
printf("Port %d could not be opened\r\n", id); printf("Port %d could not be opened.\r\n", id);
return; return;
} }
printf("Port %d opened, baud=%d\r\n", id, baud); printf("Port %d opened, baud = %d.\r\n", id, baud);
} else { } else {
passThroughPort = passThroughPortUsage->serialPort; passThroughPort = passThroughPortUsage->serialPort;
// If the user supplied a mode, override the port's mode, otherwise // If the user supplied a mode, override the port's mode, otherwise
// leave the mode unchanged. serialPassthrough() handles one-way ports. // leave the mode unchanged. serialPassthrough() handles one-way ports.
printf("Port %d already open\r\n", id); printf("Port %d already open.\r\n", id);
if (mode && passThroughPort->mode != mode) { if (mode && passThroughPort->mode != mode) {
printf("Adjusting mode from configured value %d to %d\r\n", printf("Adjusting mode from %d to %d.\r\n",
passThroughPort->mode, mode); passThroughPort->mode, mode);
serialSetMode(passThroughPort, mode); serialSetMode(passThroughPort, mode);
} }
// If this port has a rx callback associated we need to remove it now. // If this port has a rx callback associated we need to remove it now.
// Otherwise no data will be pushed in the serial port buffer! // Otherwise no data will be pushed in the serial port buffer!
if (passThroughPort->rxCallback) { if (passThroughPort->rxCallback) {
printf("Removing rxCallback from port\r\n"); printf("Removing rxCallback\r\n");
passThroughPort->rxCallback = 0; passThroughPort->rxCallback = 0;
} }
} }
printf("Relaying data to device on port %d, Reset your board to exit " printf("Forwarding data to %d, power cycle to exit.\r\n", id);
"serial passthrough mode.\r\n", id);
serialPassthrough(cliPort, passThroughPort, NULL, NULL); serialPassthrough(cliPort, passThroughPort, NULL, NULL);
} }
@ -2343,7 +2342,7 @@ static void cliFlashErase(char *cmdline)
{ {
UNUSED(cmdline); UNUSED(cmdline);
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
uint32_t i; uint32_t i;
cliPrintf("Erasing, please wait ... \r\n"); cliPrintf("Erasing, please wait ... \r\n");
#else #else
@ -2354,7 +2353,7 @@ static void cliFlashErase(char *cmdline)
flashfsEraseCompletely(); flashfsEraseCompletely();
while (!flashfsIsReady()) { while (!flashfsIsReady()) {
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
cliPrintf("."); cliPrintf(".");
if (i++ > 120) { if (i++ > 120) {
i=0; i=0;
@ -2855,14 +2854,14 @@ static void cliEscPassthrough(char *cmdline)
index = atoi(pch); index = atoi(pch);
if(mode == 2 && index == 255) if(mode == 2 && index == 255)
{ {
printf("passthru on all pwm outputs enabled\r\n"); printf("passthrough on all outputs enabled\r\n");
} }
else{ else{
if ((index >= 0) && (index < USABLE_TIMER_CHANNEL_COUNT)) { if ((index >= 0) && (index < USABLE_TIMER_CHANNEL_COUNT)) {
printf("passthru at pwm output %d enabled\r\n", index); printf("passthrough on output %d enabled\r\n", index);
} }
else { else {
printf("invalid pwm output, valid range: 1 to %d\r\n", USABLE_TIMER_CHANNEL_COUNT); printf("invalid output, range: 1 to %d\r\n", USABLE_TIMER_CHANNEL_COUNT);
return; return;
} }
} }
@ -2955,7 +2954,7 @@ static void cliMotor(char *cmdline)
cliPrintf("motor %d: %d\r\n", motor_index, convertMotorToExternal(motor_disarmed[motor_index])); cliPrintf("motor %d: %d\r\n", motor_index, convertMotorToExternal(motor_disarmed[motor_index]));
} }
#if (FLASH_SIZE > 128) #ifndef MINIMAL_CLI
static void cliPlaySound(char *cmdline) static void cliPlaySound(char *cmdline)
{ {
int i; int i;
@ -3247,11 +3246,11 @@ static void cliTasks(char *cmdline)
int maxLoadSum = 0; int maxLoadSum = 0;
int averageLoadSum = 0; int averageLoadSum = 0;
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
if (masterConfig.task_statistics) { if (masterConfig.task_statistics) {
cliPrintf("Task list rate/hz max/us avg/us maxload avgload total/ms\r\n"); cliPrintf("Task list rate/hz max/us avg/us maxload avgload total/ms\r\n");
} else { } else {
cliPrintf("Task list rate/hz\r\n"); cliPrintf("Task list\r\n");
} }
#endif #endif
for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; taskId++) { for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; taskId++) {
@ -3393,7 +3392,6 @@ static void printResource(uint8_t dumpMask, const master_t *defaultConfig)
} }
} }
#ifndef CLI_MINIMAL_VERBOSITY
static bool resourceCheck(uint8_t resourceIndex, uint8_t index, ioTag_t tag) static bool resourceCheck(uint8_t resourceIndex, uint8_t index, ioTag_t tag)
{ {
const char * format = "\r\n* %s * %c%d also used by %s"; const char * format = "\r\n* %s * %c%d also used by %s";
@ -3421,7 +3419,6 @@ static bool resourceCheck(uint8_t resourceIndex, uint8_t index, ioTag_t tag)
} }
return true; return true;
} }
#endif
static void cliResource(char *cmdline) static void cliResource(char *cmdline)
{ {
@ -3432,7 +3429,9 @@ static void cliResource(char *cmdline)
return; return;
} else if (strncasecmp(cmdline, "list", len) == 0) { } else if (strncasecmp(cmdline, "list", len) == 0) {
#ifndef CLI_MINIMAL_VERBOSITY #ifdef MINIMAL_CLI
cliPrintf("Resources:\r\n");
#else
cliPrintf("Currently active IO resource assignments:\r\n(reboot to update)\r\n"); cliPrintf("Currently active IO resource assignments:\r\n(reboot to update)\r\n");
cliRepeat('-', 20); cliRepeat('-', 20);
#endif #endif
@ -3447,8 +3446,10 @@ static void cliResource(char *cmdline)
} }
} }
#ifdef MINIMAL_CLI
cliPrintf("\r\n\r\nDMA:\r\n");
#else
cliPrintf("\r\n\r\nCurrently active DMA:\r\n"); cliPrintf("\r\n\r\nCurrently active DMA:\r\n");
#ifndef CLI_MINIMAL_VERBOSITY
cliRepeat('-', 20); cliRepeat('-', 20);
#endif #endif
for (int i = 0; i < DMA_MAX_DESCRIPTORS; i++) { for (int i = 0; i < DMA_MAX_DESCRIPTORS; i++) {
@ -3464,7 +3465,7 @@ static void cliResource(char *cmdline)
} }
} }
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
cliPrintf("\r\nUse: 'resource' to see how to change resources.\r\n"); cliPrintf("\r\nUse: 'resource' to see how to change resources.\r\n");
#endif #endif
@ -3506,7 +3507,7 @@ static void cliResource(char *cmdline)
if (strlen(pch) > 0) { if (strlen(pch) > 0) {
if (strcasecmp(pch, "NONE") == 0) { if (strcasecmp(pch, "NONE") == 0) {
*tag = IO_TAG_NONE; *tag = IO_TAG_NONE;
cliPrintf("Resource is freed!\r\n"); cliPrintf("Resource freed.\r\n");
return; return;
} else { } else {
uint8_t port = (*pch) - 'A'; uint8_t port = (*pch) - 'A';
@ -3520,17 +3521,14 @@ static void cliResource(char *cmdline)
if (pin < 16) { if (pin < 16) {
ioRec_t *rec = IO_Rec(IOGetByTag(DEFIO_TAG_MAKE(port, pin))); ioRec_t *rec = IO_Rec(IOGetByTag(DEFIO_TAG_MAKE(port, pin)));
if (rec) { if (rec) {
#ifndef CLI_MINIMAL_VERBOSITY
if (!resourceCheck(resourceIndex, index, DEFIO_TAG_MAKE(port, pin))) { if (!resourceCheck(resourceIndex, index, DEFIO_TAG_MAKE(port, pin))) {
return; return;
} }
cliPrintf("\r\nResource is set to %c%02d!\r\n", port + 'A', pin); cliPrintf("\r\nResource set to %c%02d!\r\n", port + 'A', pin);
#else
cliPrintf("Set to %c%02d!", port + 'A', pin);
#endif
*tag = DEFIO_TAG_MAKE(port, pin); *tag = DEFIO_TAG_MAKE(port, pin);
} else { } else {
cliPrintf("Resource is invalid!\r\n"); cliPrintf("Resource invalid!\r\n");
} }
return; return;
} }
@ -3701,14 +3699,14 @@ static void cliDiff(char *cmdline)
typedef struct { typedef struct {
const char *name; const char *name;
#ifndef SKIP_CLI_COMMAND_HELP #ifndef MINIMAL_CLI
const char *description; const char *description;
const char *args; const char *args;
#endif #endif
void (*func)(char *cmdline); void (*func)(char *cmdline);
} clicmd_t; } clicmd_t;
#ifndef SKIP_CLI_COMMAND_HELP #ifndef MINIMAL_CLI
#define CLI_COMMAND_DEF(name, description, args, method) \ #define CLI_COMMAND_DEF(name, description, args, method) \
{ \ { \
name , \ name , \
@ -3776,7 +3774,7 @@ const clicmd_t cmdTable[] = {
#endif #endif
CLI_COMMAND_DEF("motor", "get/set motor", "<index> [<value>]", cliMotor), CLI_COMMAND_DEF("motor", "get/set motor", "<index> [<value>]", cliMotor),
CLI_COMMAND_DEF("name", "name of craft", NULL, cliName), CLI_COMMAND_DEF("name", "name of craft", NULL, cliName),
#if (FLASH_SIZE > 128) #ifndef MINIMAL_CLI
CLI_COMMAND_DEF("play_sound", NULL, "[<index>]", cliPlaySound), CLI_COMMAND_DEF("play_sound", NULL, "[<index>]", cliPlaySound),
#endif #endif
CLI_COMMAND_DEF("profile", "change profile", "[<index>]", cliProfile), CLI_COMMAND_DEF("profile", "change profile", "[<index>]", cliProfile),
@ -3821,7 +3819,7 @@ static void cliHelp(char *cmdline)
for (uint32_t i = 0; i < CMD_COUNT; i++) { for (uint32_t i = 0; i < CMD_COUNT; i++) {
cliPrint(cmdTable[i].name); cliPrint(cmdTable[i].name);
#ifndef SKIP_CLI_COMMAND_HELP #ifndef MINIMAL_CLI
if (cmdTable[i].description) { if (cmdTable[i].description) {
cliPrintf(" - %s", cmdTable[i].description); cliPrintf(" - %s", cmdTable[i].description);
} }
@ -3952,7 +3950,7 @@ void cliEnter(serialPort_t *serialPort)
schedulerSetCalulateTaskStatistics(masterConfig.task_statistics); schedulerSetCalulateTaskStatistics(masterConfig.task_statistics);
#ifndef CLI_MINIMAL_VERBOSITY #ifndef MINIMAL_CLI
cliPrint("\r\nEntering CLI Mode, type 'exit' to return, or 'help'\r\n"); cliPrint("\r\nEntering CLI Mode, type 'exit' to return, or 'help'\r\n");
#else #else
cliPrint("\r\nCLI\r\n"); cliPrint("\r\nCLI\r\n");

View file

@ -130,8 +130,6 @@
#define USE_SERIAL_4WAY_BLHELI_INTERFACE #define USE_SERIAL_4WAY_BLHELI_INTERFACE
#undef GPS
// IO - stm32f303cc in 48pin package // IO - stm32f303cc in 48pin package
#define TARGET_IO_PORTA 0xffff #define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff #define TARGET_IO_PORTB 0xffff

View file

@ -50,6 +50,7 @@
#ifdef STM32F3 #ifdef STM32F3
#define USE_DSHOT #define USE_DSHOT
#undef GPS #undef GPS
#define MINIMAL_CLI
#endif #endif
#ifdef STM32F1 #ifdef STM32F1
@ -57,7 +58,7 @@
#define USE_UART1_RX_DMA #define USE_UART1_RX_DMA
#define USE_UART1_TX_DMA #define USE_UART1_TX_DMA
#define CLI_MINIMAL_VERBOSITY #define MINIMAL_CLI
#endif #endif
#define SERIAL_RX #define SERIAL_RX
@ -109,7 +110,5 @@
#define VTX_SMARTAUDIO #define VTX_SMARTAUDIO
#define VTX_TRAMP #define VTX_TRAMP
#define USE_SENSOR_NAMES #define USE_SENSOR_NAMES
#else
#define SKIP_CLI_COMMAND_HELP
#endif #endif