2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
28 // FIXME remove this for targets that don't need a CLI. Perhaps use a no-op macro when USE_CLI is not enabled
29 // signal that we're in cli mode
31 extern uint8_t __config_start
; // configured via linker script when building binaries.
32 extern uint8_t __config_end
;
36 #include "blackbox/blackbox.h"
38 #include "build/build_config.h"
39 #include "build/debug.h"
40 #include "build/version.h"
44 #include "common/axis.h"
45 #include "common/color.h"
46 #include "common/maths.h"
47 #include "common/printf.h"
48 #include "common/typeconversion.h"
49 #include "common/utils.h"
51 #include "config/config_eeprom.h"
52 #include "config/feature.h"
53 #include "config/parameter_group.h"
54 #include "config/parameter_group_ids.h"
56 #include "drivers/accgyro.h"
57 #include "drivers/buf_writer.h"
58 #include "drivers/bus_i2c.h"
59 #include "drivers/compass.h"
60 #include "drivers/display.h"
61 #include "drivers/dma.h"
62 #include "drivers/flash.h"
63 #include "drivers/io.h"
64 #include "drivers/io_impl.h"
65 #include "drivers/rx_pwm.h"
66 #include "drivers/sdcard.h"
67 #include "drivers/sensor.h"
68 #include "drivers/serial.h"
69 #include "drivers/serial_escserial.h"
70 #include "drivers/sonar_hcsr04.h"
71 #include "drivers/stack_check.h"
72 #include "drivers/system.h"
73 #include "drivers/timer.h"
74 #include "drivers/vcd.h"
77 #include "fc/config.h"
78 #include "fc/controlrate_profile.h"
79 #include "fc/fc_core.h"
80 #include "fc/rc_adjustments.h"
81 #include "fc/rc_controls.h"
82 #include "fc/runtime_config.h"
83 #include "fc/fc_msp.h"
85 #include "flight/altitude.h"
86 #include "flight/failsafe.h"
87 #include "flight/imu.h"
88 #include "flight/mixer.h"
89 #include "flight/navigation.h"
90 #include "flight/pid.h"
91 #include "flight/servos.h"
93 #include "io/asyncfatfs/asyncfatfs.h"
94 #include "io/beeper.h"
95 #include "io/flashfs.h"
96 #include "io/displayport_max7456.h"
97 #include "io/displayport_msp.h"
98 #include "io/gimbal.h"
100 #include "io/ledstrip.h"
102 #include "io/serial.h"
103 #include "io/vtx_rtc6705.h"
104 #include "io/vtx_control.h"
107 #include "rx/spektrum.h"
109 #include "scheduler/scheduler.h"
111 #include "sensors/acceleration.h"
112 #include "sensors/barometer.h"
113 #include "sensors/battery.h"
114 #include "sensors/boardalignment.h"
115 #include "sensors/compass.h"
116 #include "sensors/gyro.h"
117 #include "sensors/sensors.h"
119 #include "telemetry/frsky.h"
120 #include "telemetry/telemetry.h"
123 static serialPort_t
*cliPort
;
124 static bufWriter_t
*cliWriter
;
125 static uint8_t cliWriteBuffer
[sizeof(*cliWriter
) + 128];
127 static char cliBuffer
[64];
128 static uint32_t bufferIndex
= 0;
130 static const char* const emptyName
= "-";
132 #ifndef USE_QUAD_MIXER_ONLY
133 // sync this with mixerMode_e
134 static const char * const mixerNames
[] = {
135 "TRI", "QUADP", "QUADX", "BI",
136 "GIMBAL", "Y6", "HEX6",
137 "FLYING_WING", "Y4", "HEX6X", "OCTOX8", "OCTOFLATP", "OCTOFLATX",
138 "AIRPLANE", "HELI_120_CCPM", "HELI_90_DEG", "VTAIL4",
139 "HEX6H", "PPM_TO_SERVO", "DUALCOPTER", "SINGLECOPTER",
140 "ATAIL4", "CUSTOM", "CUSTOMAIRPLANE", "CUSTOMTRI", "QUADX1234", NULL
144 // sync this with features_e
145 static const char * const featureNames
[] = {
146 "RX_PPM", "VBAT", "INFLIGHT_ACC_CAL", "RX_SERIAL", "MOTOR_STOP",
147 "SERVO_TILT", "SOFTSERIAL", "GPS", "FAILSAFE",
148 "SONAR", "TELEMETRY", "CURRENT_METER", "3D", "RX_PARALLEL_PWM",
149 "RX_MSP", "RSSI_ADC", "LED_STRIP", "DISPLAY", "OSD",
150 "UNUSED", "CHANNEL_FORWARDING", "TRANSPONDER", "AIRMODE",
151 "SDCARD", "VTX", "RX_SPI", "SOFTSPI", "ESC_SENSOR", "ANTI_GRAVITY", NULL
154 // sync this with rxFailsafeChannelMode_e
155 static const char rxFailsafeModeCharacters
[] = "ahs";
157 static const rxFailsafeChannelMode_e rxFailsafeModesTable
[RX_FAILSAFE_TYPE_COUNT
][RX_FAILSAFE_MODE_COUNT
] = {
158 { RX_FAILSAFE_MODE_AUTO
, RX_FAILSAFE_MODE_HOLD
, RX_FAILSAFE_MODE_INVALID
},
159 { RX_FAILSAFE_MODE_INVALID
, RX_FAILSAFE_MODE_HOLD
, RX_FAILSAFE_MODE_SET
}
162 // sync this with accelerationSensor_e
163 static const char * const lookupTableAccHardware
[] = {
183 // sync this with baroSensor_e
184 static const char * const lookupTableBaroHardware
[] = {
194 // sync this with magSensor_e
195 static const char * const lookupTableMagHardware
[] = {
204 #if defined(USE_SENSOR_NAMES)
205 // sync this with sensors_e
206 static const char * const sensorTypeNames
[] = {
207 "GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL
210 #define SENSOR_NAMES_MASK (SENSOR_GYRO | SENSOR_ACC | SENSOR_BARO | SENSOR_MAG)
212 static const char * const sensorHardwareNames
[4][16] = {
213 { "", "None", "MPU6050", "L3G4200D", "MPU3050", "L3GD20", "MPU6000", "MPU6500", "MPU9250", "ICM20601", "ICM20602", "ICM20608G", "ICM20689", "BMI160", "FAKE", NULL
},
214 { "", "None", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "MPU9250", "ICM20601", "ICM20602", "ICM20608G", "ICM20689", "BMI160", "FAKE", NULL
},
215 { "", "None", "BMP085", "MS5611", "BMP280", NULL
},
216 { "", "None", "HMC5883", "AK8975", "AK8963", NULL
}
218 #endif /* USE_SENSOR_NAMES */
220 static const char * const lookupTableOffOn
[] = {
224 static const char * const lookupTableUnit
[] = {
228 static const char * const lookupTableAlignment
[] = {
241 static const char * const lookupTableGPSProvider
[] = {
245 static const char * const lookupTableGPSSBASMode
[] = {
246 "AUTO", "EGNOS", "WAAS", "MSAS", "GAGAN"
250 static const char * const lookupTableCurrentSensor
[] = {
251 "NONE", "ADC", "VIRTUAL", "ESC"
254 static const char * const lookupTableBatterySensor
[] = {
259 static const char * const lookupTableGimbalMode
[] = {
265 static const char * const lookupTableBlackboxDevice
[] = {
266 "SERIAL", "SPIFLASH", "SDCARD"
271 static const char * const lookupTableSerialRX
[] = {
287 // sync with rx_spi_protocol_e
288 static const char * const lookupTableRxSpi
[] = {
300 static const char * const lookupTableGyroLpf
[] = {
311 static const char * const lookupTableDebug
[DEBUG_COUNT
] = {
334 static const char * const lookupTableOsdType
[] = {
341 static const char * const lookupTableSuperExpoYaw
[] = {
342 "OFF", "ON", "ALWAYS"
345 static const char * const lookupTablePwmProtocol
[] = {
346 "OFF", "ONESHOT125", "ONESHOT42", "MULTISHOT", "BRUSHED",
348 "DSHOT150", "DSHOT300", "DSHOT600", "DSHOT1200"
352 static const char * const lookupTableRcInterpolation
[] = {
353 "OFF", "PRESET", "AUTO", "MANUAL"
356 static const char * const lookupTableRcInterpolationChannels
[] = {
360 static const char * const lookupTableLowpassType
[] = {
361 "PT1", "BIQUAD", "FIR"
364 static const char * const lookupTableFailsafe
[] = {
368 typedef struct lookupTableEntry_s
{
369 const char * const *values
;
370 const uint8_t valueCount
;
371 } lookupTableEntry_t
;
382 TABLE_BLACKBOX_DEVICE
,
405 TABLE_MOTOR_PWM_PROTOCOL
,
406 TABLE_RC_INTERPOLATION
,
407 TABLE_RC_INTERPOLATION_CHANNELS
,
414 } lookupTableIndex_e
;
416 static const lookupTableEntry_t lookupTables
[] = {
417 { lookupTableOffOn
, sizeof(lookupTableOffOn
) / sizeof(char *) },
418 { lookupTableUnit
, sizeof(lookupTableUnit
) / sizeof(char *) },
419 { lookupTableAlignment
, sizeof(lookupTableAlignment
) / sizeof(char *) },
421 { lookupTableGPSProvider
, sizeof(lookupTableGPSProvider
) / sizeof(char *) },
422 { lookupTableGPSSBASMode
, sizeof(lookupTableGPSSBASMode
) / sizeof(char *) },
425 { lookupTableBlackboxDevice
, sizeof(lookupTableBlackboxDevice
) / sizeof(char *) },
427 { lookupTableCurrentSensor
, sizeof(lookupTableCurrentSensor
) / sizeof(char *) },
428 { lookupTableBatterySensor
, sizeof(lookupTableBatterySensor
) / sizeof(char *) },
430 { lookupTableGimbalMode
, sizeof(lookupTableGimbalMode
) / sizeof(char *) },
433 { lookupTableSerialRX
, sizeof(lookupTableSerialRX
) / sizeof(char *) },
436 { lookupTableRxSpi
, sizeof(lookupTableRxSpi
) / sizeof(char *) },
438 { lookupTableGyroLpf
, sizeof(lookupTableGyroLpf
) / sizeof(char *) },
439 { lookupTableAccHardware
, sizeof(lookupTableAccHardware
) / sizeof(char *) },
441 { lookupTableBaroHardware
, sizeof(lookupTableBaroHardware
) / sizeof(char *) },
444 { lookupTableMagHardware
, sizeof(lookupTableMagHardware
) / sizeof(char *) },
446 { lookupTableDebug
, sizeof(lookupTableDebug
) / sizeof(char *) },
447 { lookupTableSuperExpoYaw
, sizeof(lookupTableSuperExpoYaw
) / sizeof(char *) },
448 { lookupTablePwmProtocol
, sizeof(lookupTablePwmProtocol
) / sizeof(char *) },
449 { lookupTableRcInterpolation
, sizeof(lookupTableRcInterpolation
) / sizeof(char *) },
450 { lookupTableRcInterpolationChannels
, sizeof(lookupTableRcInterpolationChannels
) / sizeof(char *) },
451 { lookupTableLowpassType
, sizeof(lookupTableLowpassType
) / sizeof(char *) },
452 { lookupTableFailsafe
, sizeof(lookupTableFailsafe
) / sizeof(char *) },
454 { lookupTableOsdType
, sizeof(lookupTableOsdType
) / sizeof(char *) },
458 #define VALUE_TYPE_OFFSET 0
459 #define VALUE_SECTION_OFFSET 4
460 #define VALUE_MODE_OFFSET 6
463 // value type, bits 0-3
464 VAR_UINT8
= (0 << VALUE_TYPE_OFFSET
),
465 VAR_INT8
= (1 << VALUE_TYPE_OFFSET
),
466 VAR_UINT16
= (2 << VALUE_TYPE_OFFSET
),
467 VAR_INT16
= (3 << VALUE_TYPE_OFFSET
),
469 // value section, bits 4-5
470 MASTER_VALUE
= (0 << VALUE_SECTION_OFFSET
),
471 PROFILE_VALUE
= (1 << VALUE_SECTION_OFFSET
),
472 PROFILE_RATE_VALUE
= (2 << VALUE_SECTION_OFFSET
), // 0x20
474 MODE_DIRECT
= (0 << VALUE_MODE_OFFSET
), // 0x40
475 MODE_LOOKUP
= (1 << VALUE_MODE_OFFSET
) // 0x80
478 #define VALUE_TYPE_MASK (0x0F)
479 #define VALUE_SECTION_MASK (0x30)
480 #define VALUE_MODE_MASK (0xC0)
489 typedef struct cliMinMaxConfig_s
{
494 typedef struct cliLookupTableConfig_s
{
495 const lookupTableIndex_e tableIndex
;
496 } cliLookupTableConfig_t
;
499 cliLookupTableConfig_t lookup
;
500 cliMinMaxConfig_t minmax
;
505 const uint8_t type
; // see cliValueFlag_e
506 const cliValueConfig_t config
;
510 } __attribute__((packed
)) clivalue_t
;
512 static const clivalue_t valueTable
[] = {
514 { "align_gyro", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_ALIGNMENT
}, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_align
) },
515 { "gyro_lpf", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_GYRO_LPF
}, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_lpf
) },
516 { "gyro_sync_denom", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 32 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_sync_denom
) },
517 { "gyro_lowpass_type", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_LOWPASS_TYPE
}, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_lpf_type
) },
518 { "gyro_lowpass", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 255 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_lpf_hz
) },
519 { "gyro_notch1_hz", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 16000 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_notch_hz_1
) },
520 { "gyro_notch1_cutoff", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 1, 16000 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_notch_cutoff_1
) },
521 { "gyro_notch2_hz", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 16000 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_notch_hz_2
) },
522 { "gyro_notch2_cutoff", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 1, 16000 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_soft_notch_cutoff_2
) },
523 { "moron_threshold", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 200 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyroMovementCalibrationThreshold
) },
524 #if defined(GYRO_USES_SPI)
525 #if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
526 { "gyro_use_32khz", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_use_32khz
) },
528 #if defined(USE_MPU_DATA_READY_SIGNAL)
529 { "gyro_isr_update", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_isr_update
) },
533 { "gyro_to_use", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 1 }, PG_GYRO_CONFIG
, offsetof(gyroConfig_t
, gyro_to_use
) },
536 // PG_ACCELEROMETER_CONFIG
537 { "align_acc", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_ALIGNMENT
}, PG_ACCELEROMETER_CONFIG
, offsetof(accelerometerConfig_t
, acc_align
) },
538 { "acc_hardware", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_ACC_HARDWARE
}, PG_ACCELEROMETER_CONFIG
, offsetof(accelerometerConfig_t
, acc_hardware
) },
539 { "acc_lpf_hz", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 400 }, PG_ACCELEROMETER_CONFIG
, offsetof(accelerometerConfig_t
, acc_lpf_hz
) },
540 { "acc_trim_pitch", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -300, 300 }, PG_ACCELEROMETER_CONFIG
, offsetof(accelerometerConfig_t
, accelerometerTrims
.values
.pitch
) },
541 { "acc_trim_roll", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -300, 300 }, PG_ACCELEROMETER_CONFIG
, offsetof(accelerometerConfig_t
, accelerometerTrims
.values
.roll
) },
545 { "align_mag", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_ALIGNMENT
}, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, mag_align
) },
546 { "mag_hardware", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_MAG_HARDWARE
}, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, mag_hardware
) },
547 { "mag_declination", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -18000, 18000 }, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, mag_declination
) },
548 { "magzero_x", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { INT16_MIN
, INT16_MAX
}, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, magZero
.raw
[X
]) },
549 { "magzero_y", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { INT16_MIN
, INT16_MAX
}, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, magZero
.raw
[Y
]) },
550 { "magzero_z", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { INT16_MIN
, INT16_MAX
}, PG_COMPASS_CONFIG
, offsetof(compassConfig_t
, magZero
.raw
[Z
]) },
553 // PG_BAROMETER_CONFIG
555 { "baro_hardware", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_BARO_HARDWARE
}, PG_BAROMETER_CONFIG
, offsetof(barometerConfig_t
, baro_hardware
) },
556 { "baro_tab_size", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, BARO_SAMPLE_COUNT_MAX
}, PG_BAROMETER_CONFIG
, offsetof(barometerConfig_t
, baro_sample_count
) },
557 { "baro_noise_lpf", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 1000 }, PG_BAROMETER_CONFIG
, offsetof(barometerConfig_t
, baro_noise_lpf
) },
558 { "baro_cf_vel", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 1000 }, PG_BAROMETER_CONFIG
, offsetof(barometerConfig_t
, baro_cf_vel
) },
559 { "baro_cf_alt", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 1000 }, PG_BAROMETER_CONFIG
, offsetof(barometerConfig_t
, baro_cf_alt
) },
563 { "mid_rc", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 1200, 1700 }, PG_RX_CONFIG
, offsetof(rxConfig_t
, midrc
) },
564 { "min_check", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, mincheck
) },
565 { "max_check", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, maxcheck
) },
566 { "rssi_channel", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { 0, MAX_SUPPORTED_RC_CHANNEL_COUNT
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rssi_channel
) },
567 { "rssi_scale", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { RSSI_SCALE_MIN
, RSSI_SCALE_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rssi_scale
) },
568 { "rssi_invert", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rssi_invert
) },
569 { "rc_interp", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_RC_INTERPOLATION
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rcInterpolation
) },
570 { "rc_interp_ch", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_RC_INTERPOLATION_CHANNELS
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rcInterpolationChannels
) },
571 { "rc_interp_int", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 50 }, PG_RX_CONFIG
, offsetof(rxConfig_t
, rcInterpolationInterval
) },
572 { "fpv_mix_degrees", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 50 }, PG_RX_CONFIG
, offsetof(rxConfig_t
, fpvCamAngleDegrees
) },
573 { "max_aux_channels", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, MAX_AUX_CHANNEL_COUNT
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, max_aux_channel
) },
575 { "serialrx_provider", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_SERIAL_RX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, serialrx_provider
) },
576 { "sbus_inversion", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, sbus_inversion
) },
578 #ifdef SPEKTRUM_BIND_PIN
579 { "spektrum_sat_bind", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { SPEKTRUM_SAT_BIND_DISABLED
, SPEKTRUM_SAT_BIND_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, spektrum_sat_bind
) },
580 { "spektrum_sat_bind_autoreset",VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 1 }, PG_RX_CONFIG
, offsetof(rxConfig_t
, spektrum_sat_bind_autoreset
) },
582 { "airmode_start_throttle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 1000, 2000 }, PG_RX_CONFIG
, offsetof(rxConfig_t
, airModeActivateThreshold
) },
583 { "rx_min_usec", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_PULSE_MIN
, PWM_PULSE_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rx_min_usec
) },
584 { "rx_max_usec", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_PULSE_MIN
, PWM_PULSE_MAX
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, rx_max_usec
) },
586 { "serialrx_halfduplex", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_RX_CONFIG
, offsetof(rxConfig_t
, halfDuplex
) },
591 { "input_filtering_mode", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_PWM_CONFIG
, offsetof(pwmConfig_t
, inputFilteringMode
) },
594 // PG_BLACKBOX_CONFIG
596 { "blackbox_rate_num", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 32 }, PG_BLACKBOX_CONFIG
, offsetof(blackboxConfig_t
, rate_num
) },
597 { "blackbox_rate_denom", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 32 }, PG_BLACKBOX_CONFIG
, offsetof(blackboxConfig_t
, rate_denom
) },
598 { "blackbox_device", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_BLACKBOX_DEVICE
}, PG_BLACKBOX_CONFIG
, offsetof(blackboxConfig_t
, device
) },
599 { "blackbox_on_motor_test", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_BLACKBOX_CONFIG
, offsetof(blackboxConfig_t
, on_motor_test
) },
603 { "min_throttle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, minthrottle
) },
604 { "max_throttle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, maxthrottle
) },
605 { "min_command", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, mincommand
) },
607 { "digital_idle_value", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 2000 }, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, digitalIdleOffsetValue
) },
609 { "use_unsynced_pwm", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, dev
.useUnsyncedPwm
) },
610 { "motor_pwm_protocol", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_MOTOR_PWM_PROTOCOL
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, dev
.motorPwmProtocol
) },
611 { "motor_pwm_rate", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 200, 32000 }, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, dev
.motorPwmRate
) },
612 { "motor_pwm_inversion", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, dev
.motorPwmInversion
) },
614 // PG_THROTTLE_CORRECTION_CONFIG
615 { "thr_corr_value", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 150 }, PG_THROTTLE_CORRECTION_CONFIG
, offsetof(throttleCorrectionConfig_t
, throttle_correction_value
) },
616 { "thr_corr_angle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 1, 900 }, PG_THROTTLE_CORRECTION_CONFIG
, offsetof(throttleCorrectionConfig_t
, throttle_correction_angle
) },
618 // PG_FAILSAFE_CONFIG
619 { "failsafe_delay", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 200 }, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_delay
) },
620 { "failsafe_off_delay", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 200 }, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_off_delay
) },
621 { "failsafe_throttle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_MIN
, PWM_RANGE_MAX
}, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_throttle
) },
622 { "failsafe_kill_switch", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_kill_switch
) },
623 { "failsafe_throttle_low_delay",VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 300 }, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_throttle_low_delay
) },
624 { "failsafe_procedure", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_FAILSAFE
}, PG_FAILSAFE_CONFIG
, offsetof(failsafeConfig_t
, failsafe_procedure
) },
626 // PG_BOARDALIGNMENT_CONFIG
627 { "align_board_roll", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { 0, 360 }, PG_BOARD_ALIGNMENT
, offsetof(boardAlignment_t
, rollDegrees
) },
628 { "align_board_pitch", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { 0, 360 }, PG_BOARD_ALIGNMENT
, offsetof(boardAlignment_t
, pitchDegrees
) },
629 { "align_board_yaw", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { 0, 360 }, PG_BOARD_ALIGNMENT
, offsetof(boardAlignment_t
, yawDegrees
) },
633 { "gimbal_mode", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_GIMBAL_MODE
}, PG_GIMBAL_CONFIG
, offsetof(gimbalConfig_t
, mode
) },
637 { "bat_capacity", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 20000 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, batteryCapacity
) },
638 { "vbat_max_cell_voltage", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 10, 50 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, vbatmaxcellvoltage
) },
639 { "vbat_min_cell_voltage", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 10, 50 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, vbatmincellvoltage
) },
640 { "vbat_warning_cell_voltage", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 10, 50 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, vbatwarningcellvoltage
) },
641 { "vbat_hysteresis", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 250 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, vbathysteresis
) },
642 { "current_meter", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_CURRENT_METER
}, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, currentMeterSource
) },
643 { "battery_meter", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_VOLTAGE_METER
}, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, voltageMeterSource
) },
644 { "bat_detect_thresh", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 200 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, batteryNotPresentLevel
) },
645 { "use_vbat_alerts", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, useVBatAlerts
) },
646 { "use_cbat_alerts", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, useConsumptionAlerts
) },
647 { "cbat_alert_percent", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_BATTERY_CONFIG
, offsetof(batteryConfig_t
, consumptionWarningPercentage
) },
649 // PG_VOLTAGE_SENSOR_ADC_CONFIG
650 { "vbat_scale", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { VBAT_SCALE_MIN
, VBAT_SCALE_MAX
}, PG_VOLTAGE_SENSOR_ADC_CONFIG
, offsetof(voltageSensorADCConfig_t
, vbatscale
) },
652 // PG_CURRENT_SENSOR_ADC_CONFIG
653 { "ibata_scale", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -16000, 16000 }, PG_CURRENT_SENSOR_ADC_CONFIG
, offsetof(currentSensorADCConfig_t
, scale
) },
654 { "ibata_offset", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -16000, 16000 }, PG_CURRENT_SENSOR_ADC_CONFIG
, offsetof(currentSensorADCConfig_t
, offset
) },
655 // PG_CURRENT_SENSOR_ADC_CONFIG
656 #ifdef USE_VIRTUAL_CURRENT_METER
657 { "ibatv_scale", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG
, offsetof(currentSensorVirtualConfig_t
, scale
) },
658 { "ibatv_offset", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG
, offsetof(currentSensorVirtualConfig_t
, offset
) },
661 // PG_BEEPER_DEV_CONFIG
663 { "beeper_inversion", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_BEEPER_DEV_CONFIG
, offsetof(beeperDevConfig_t
, isInverted
) },
664 { "beeper_od", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_BEEPER_DEV_CONFIG
, offsetof(beeperDevConfig_t
, isOpenDrain
) },
665 { "beeper_frequency", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { 0, 16000 }, PG_BEEPER_DEV_CONFIG
, offsetof(beeperDevConfig_t
, frequency
) },
669 { "yaw_motors_reversed", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_MIXER_CONFIG
, offsetof(mixerConfig_t
, yaw_motors_reversed
) },
671 // PG_MOTOR_3D_CONFIG
672 { "3d_deadband_low", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_3D_CONFIG
, offsetof(flight3DConfig_t
, deadband3d_low
) }, // FIXME upper limit should match code in the mixer, 1500 currently
673 { "3d_deadband_high", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_3D_CONFIG
, offsetof(flight3DConfig_t
, deadband3d_high
) }, // FIXME lower limit should match code in the mixer, 1500 currently,
674 { "3d_neutral", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_3D_CONFIG
, offsetof(flight3DConfig_t
, neutral3d
) },
675 { "3d_deadband_throttle", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_MOTOR_3D_CONFIG
, offsetof(flight3DConfig_t
, deadband3d_throttle
) },
679 { "servo_center_pulse", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { PWM_RANGE_ZERO
, PWM_RANGE_MAX
}, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, dev
.servoCenterPulse
) },
680 { "servo_pwm_rate", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 50, 498 }, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, dev
.servoPwmRate
) },
681 { "servo_lowpass_hz", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 400}, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, servo_lowpass_freq
) },
682 { "tri_unarmed_servo", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, tri_unarmed_servo
) },
683 { "channel_forwarding_start", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { AUX1
, MAX_SUPPORTED_RC_CHANNEL_COUNT
}, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, channelForwardingStartChannel
) },
686 // PG_CONTROLRATE_PROFILES
687 { "rc_rate", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 255 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rcRate8
) },
688 { "rc_rate_yaw", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 255 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rcYawRate8
) },
689 { "rc_expo", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 100 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rcExpo8
) },
690 { "rc_yaw_expo", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 100 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rcYawExpo8
) },
691 { "thr_mid", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 100 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, thrMid8
) },
692 { "thr_expo", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, 100 }, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, thrExpo8
) },
693 { "roll_srate", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX
}, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rates
[FD_ROLL
]) },
694 { "pitch_srate", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX
}, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rates
[FD_PITCH
]) },
695 { "yaw_srate", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, CONTROL_RATE_CONFIG_YAW_RATE_MAX
}, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, rates
[FD_YAW
]) },
696 { "tpa_rate", VAR_UINT8
| PROFILE_RATE_VALUE
, .config
.minmax
= { 0, CONTROL_RATE_CONFIG_TPA_MAX
}, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, dynThrPID
) },
697 { "tpa_breakpoint", VAR_UINT16
| PROFILE_RATE_VALUE
, .config
.minmax
= { PWM_RANGE_MIN
, PWM_RANGE_MAX
}, PG_CONTROL_RATE_PROFILES
, offsetof(controlRateConfig_t
, tpa_breakpoint
) },
700 { "reboot_character", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 48, 126 }, PG_SERIAL_CONFIG
, offsetof(serialConfig_t
, reboot_character
) },
701 { "serial_update_rate_hz", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 100, 2000 }, PG_SERIAL_CONFIG
, offsetof(serialConfig_t
, serial_update_rate_hz
) },
704 { "accxy_deadband", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_IMU_CONFIG
, offsetof(imuConfig_t
, accDeadband
.xy
) },
705 { "accz_deadband", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_IMU_CONFIG
, offsetof(imuConfig_t
, accDeadband
.z
) },
706 { "acc_unarmedcal", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_IMU_CONFIG
, offsetof(imuConfig_t
, acc_unarmedcal
) },
707 { "imu_dcm_kp", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 32000 }, PG_IMU_CONFIG
, offsetof(imuConfig_t
, dcm_kp
) },
708 { "imu_dcm_ki", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 32000 }, PG_IMU_CONFIG
, offsetof(imuConfig_t
, dcm_ki
) },
709 { "small_angle", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 180 }, PG_IMU_CONFIG
, offsetof(imuConfig_t
, small_angle
) },
712 { "auto_disarm_delay", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 60 }, PG_ARMING_CONFIG
, offsetof(armingConfig_t
, auto_disarm_delay
) },
713 { "disarm_kill_switch", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_ARMING_CONFIG
, offsetof(armingConfig_t
, disarm_kill_switch
) },
714 { "gyro_cal_on_first_arm", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_ARMING_CONFIG
, offsetof(armingConfig_t
, gyro_cal_on_first_arm
) },
719 { "gps_provider", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_GPS_PROVIDER
}, PG_GPS_CONFIG
, offsetof(gpsConfig_t
, provider
) },
720 { "gps_sbas_mode", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_GPS_SBAS_MODE
}, PG_GPS_CONFIG
, offsetof(gpsConfig_t
, sbasMode
) },
721 { "gps_auto_config", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_GPS_CONFIG
, offsetof(gpsConfig_t
, autoConfig
) },
722 { "gps_auto_baud", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_GPS_CONFIG
, offsetof(gpsConfig_t
, autoBaud
) },
725 // PG_NAVIGATION_CONFIG
727 { "gps_wp_radius", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 2000 }, PG_NAVIGATION_CONFIG
, offsetof(navigationConfig_t
, gps_wp_radius
) },
728 { "nav_controls_heading", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_NAVIGATION_CONFIG
, offsetof(navigationConfig_t
, nav_controls_heading
) },
729 { "nav_speed_min", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 10, 2000 }, PG_NAVIGATION_CONFIG
, offsetof(navigationConfig_t
, nav_speed_min
) },
730 { "nav_speed_max", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 10, 2000 }, PG_NAVIGATION_CONFIG
, offsetof(navigationConfig_t
, nav_speed_max
) },
731 { "nav_slew_rate", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_NAVIGATION_CONFIG
, offsetof(navigationConfig_t
, nav_slew_rate
) },
734 // PG_AIRPLANE_CONFIG
735 { "fixedwing_althold_reversed", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_AIRPLANE_CONFIG
, offsetof(airplaneConfig_t
, fixedwing_althold_reversed
) },
737 // PG_RC_CONTROLS_CONFIG
738 { "alt_hold_deadband", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 250 }, PG_RC_CONTROLS_CONFIG
, offsetof(rcControlsConfig_t
, alt_hold_deadband
) },
739 { "alt_hold_fast_change", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_RC_CONTROLS_CONFIG
, offsetof(rcControlsConfig_t
, alt_hold_fast_change
) },
740 { "deadband", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 32 }, PG_RC_CONTROLS_CONFIG
, offsetof(rcControlsConfig_t
, deadband
) },
741 { "yaw_deadband", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_RC_CONTROLS_CONFIG
, offsetof(rcControlsConfig_t
, yaw_deadband
) },
742 { "yaw_control_reversed", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_RC_CONTROLS_CONFIG
, offsetof(rcControlsConfig_t
, yaw_control_reversed
) },
745 { "pid_process_denom", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, MAX_PID_PROCESS_DENOM
}, PG_PID_CONFIG
, offsetof(pidConfig_t
, pid_process_denom
) },
748 { "d_lowpass_type", VAR_UINT8
| PROFILE_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_LOWPASS_TYPE
}, PG_PID_PROFILE
, offsetof(pidProfile_t
, dterm_filter_type
) },
749 { "d_lowpass", VAR_INT16
| PROFILE_VALUE
, .config
.minmax
= { 0, 16000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, dterm_lpf_hz
) },
750 { "d_notch_hz", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 0, 16000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, dterm_notch_hz
) },
751 { "d_notch_cut", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 1, 16000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, dterm_notch_cutoff
) },
752 { "vbat_pid_gain", VAR_UINT8
| PROFILE_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_PID_PROFILE
, offsetof(pidProfile_t
, vbatPidCompensation
) },
753 { "pid_at_min_throttle", VAR_UINT8
| PROFILE_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_PID_PROFILE
, offsetof(pidProfile_t
, pidAtMinThrottle
) },
754 { "anti_gravity_thresh", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 20, 1000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, itermThrottleThreshold
) },
755 { "anti_gravity_gain", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 1, 30000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, itermAcceleratorGain
) },
756 { "setpoint_relax_ratio", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 100 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, setpointRelaxRatio
) },
757 { "d_setpoint_weight", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 254 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, dtermSetpointWeight
) },
758 { "yaw_accel_limit", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 1, 500 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, yawRateAccelLimit
) },
759 { "accel_limit", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 1, 500 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, rateAccelLimit
) },
761 { "iterm_windup", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 30, 100 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, itermWindupPointPercent
) },
762 { "yaw_lowpass", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 0, 500 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, yaw_lpf_hz
) },
763 { "pidsum_limit", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 100, 1000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, pidSumLimit
) },
764 { "pidsum_limit_yaw", VAR_UINT16
| PROFILE_VALUE
, .config
.minmax
= { 100, 1000 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, pidSumLimitYaw
) },
766 { "p_pitch", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PITCH
]) },
767 { "i_pitch", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PITCH
]) },
768 { "d_pitch", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PITCH
]) },
769 { "p_roll", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[ROLL
]) },
770 { "i_roll", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[ROLL
]) },
771 { "d_roll", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[ROLL
]) },
772 { "p_yaw", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[YAW
]) },
773 { "i_yaw", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[YAW
]) },
774 { "d_yaw", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[YAW
]) },
776 { "p_alt", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDALT
]) },
777 { "i_alt", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDALT
]) },
778 { "d_alt", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDALT
]) },
780 { "p_level", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDLEVEL
]) },
781 { "i_level", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDLEVEL
]) },
782 { "d_level", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDLEVEL
]) },
784 { "p_vel", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDVEL
]) },
785 { "i_vel", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDVEL
]) },
786 { "d_vel", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDVEL
]) },
788 { "level_sensitivity", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 10, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, levelSensitivity
) },
789 { "level_limit", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 10, 120 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, levelAngleLimit
) },
791 { "gps_pos_p", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDPOS
]) },
792 { "gps_pos_i", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDPOS
]) },
793 { "gps_pos_d", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDPOS
]) },
794 { "gps_posr_p", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDPOSR
]) },
795 { "gps_posr_i", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDPOSR
]) },
796 { "gps_posr_d", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDPOSR
]) },
797 { "gps_nav_p", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, P8
[PIDNAVR
]) },
798 { "gps_nav_i", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, I8
[PIDNAVR
]) },
799 { "gps_nav_d", VAR_UINT8
| PROFILE_VALUE
, .config
.minmax
= { 0, 200 }, PG_PID_PROFILE
, offsetof(pidProfile_t
, D8
[PIDNAVR
]) },
802 // PG_TELEMETRY_CONFIG
804 { "tlm_switch", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, telemetry_switch
) },
805 { "tlm_inversion", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, telemetry_inversion
) },
806 { "tlm_halfduplex", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, halfDuplex
) },
807 { "frsky_default_lat", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -9000, 9000 }, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, gpsNoFixLatitude
) },
808 { "frsky_default_long", VAR_INT16
| MASTER_VALUE
, .config
.minmax
= { -18000, 18000 }, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, gpsNoFixLongitude
) },
809 { "frsky_gps_format", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, FRSKY_FORMAT_NMEA
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, frsky_coordinate_format
) },
810 { "frsky_unit", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_UNIT
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, frsky_unit
) },
811 { "frsky_vfas_precision", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { FRSKY_VFAS_PRECISION_LOW
, FRSKY_VFAS_PRECISION_HIGH
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, frsky_vfas_precision
) },
812 { "frsky_vfas_cell_voltage", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, frsky_vfas_cell_voltage
) },
813 { "hott_alarm_int", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 120 }, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, hottAlarmSoundInterval
) },
814 { "pid_in_tlm", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= {TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, pidValuesAsTelemetry
) },
815 #if defined(TELEMETRY_IBUS)
816 { "ibus_report_cell_voltage", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_TELEMETRY_CONFIG
, offsetof(telemetryConfig_t
, report_cell_voltage
) },
820 // PG_LED_STRIP_CONFIG
822 { "ledstrip_visual_beeper", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_LED_STRIP_CONFIG
, offsetof(ledStripConfig_t
, ledstrip_visual_beeper
) },
827 { "sdcard_dma", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_SDCARD_CONFIG
, offsetof(sdcardConfig_t
, useDma
) },
832 { "osd_units", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_UNIT
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, units
) },
834 { "osd_rssi_alarm", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 100 }, PG_OSD_CONFIG
, offsetof(osdConfig_t
, rssi_alarm
) },
835 { "osd_cap_alarm", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 20000 }, PG_OSD_CONFIG
, offsetof(osdConfig_t
, cap_alarm
) },
836 { "osd_time_alarm", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 60 }, PG_OSD_CONFIG
, offsetof(osdConfig_t
, time_alarm
) },
837 { "osd_alt_alarm", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, 10000 }, PG_OSD_CONFIG
, offsetof(osdConfig_t
, alt_alarm
) },
839 { "osd_vbat_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_MAIN_BATT_VOLTAGE
]) },
840 { "osd_rssi_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_RSSI_VALUE
]) },
841 { "osd_flytimer_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_FLYTIME
]) },
842 { "osd_ontimer_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_ONTIME
]) },
843 { "osd_flymode_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_FLYMODE
]) },
844 { "osd_throttle_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_THROTTLE_POS
]) },
845 { "osd_vtx_channel_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_VTX_CHANNEL
]) },
846 { "osd_crosshairs", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_CROSSHAIRS
]) },
847 { "osd_horizon_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_ARTIFICIAL_HORIZON
]) },
848 { "osd_current_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_CURRENT_DRAW
]) },
849 { "osd_mah_drawn_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_MAH_DRAWN
]) },
850 { "osd_craft_name_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_CRAFT_NAME
]) },
851 { "osd_gps_speed_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_GPS_SPEED
]) },
852 { "osd_gps_lon", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_GPS_LON
]) },
853 { "osd_gps_lat", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_GPS_LAT
]) },
854 { "osd_gps_sats_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_GPS_SATS
]) },
855 { "osd_altitude_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_ALTITUDE
]) },
856 { "osd_pid_roll_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_ROLL_PIDS
]) },
857 { "osd_pid_pitch_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_PITCH_PIDS
]) },
858 { "osd_pid_yaw_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_YAW_PIDS
]) },
859 { "osd_power_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_POWER
]) },
860 { "osd_pidrate_profile_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_PIDRATE_PROFILE
]) },
861 { "osd_battery_warning_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_MAIN_BATT_WARNING
]) },
862 { "osd_avg_cell_voltage_pos", VAR_UINT16
| MASTER_VALUE
, .config
.minmax
= { 0, OSD_POSCFG_MAX
}, PG_OSD_CONFIG
, offsetof(osdConfig_t
, item_pos
[OSD_AVG_CELL_VOLTAGE
]) },
866 #ifndef SKIP_TASK_STATISTICS
867 { "task_statistics", VAR_INT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_OFF_ON
}, PG_SYSTEM_CONFIG
, offsetof(systemConfig_t
, task_statistics
) },
869 { "debug_mode", VAR_UINT8
| MASTER_VALUE
| MODE_LOOKUP
, .config
.lookup
= { TABLE_DEBUG
}, PG_SYSTEM_CONFIG
, offsetof(systemConfig_t
, debug_mode
) },
873 { "vtx_band", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 5 }, PG_VTX_RTC6705_CONFIG
, offsetof(vtxRTC6705Config_t
, band
) },
874 { "vtx_channel", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 1, 8 }, PG_VTX_RTC6705_CONFIG
, offsetof(vtxRTC6705Config_t
, channel
) },
875 { "vtx_power", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, RTC6705_POWER_COUNT
- 1 }, PG_VTX_RTC6705_CONFIG
, offsetof(vtxRTC6705Config_t
, power
) },
880 { "vcd_video_system", VAR_UINT8
| MASTER_VALUE
, .config
.minmax
= { 0, 2 }, PG_VCD_CONFIG
, offsetof(vcdProfile_t
, video_system
) },
881 { "vcd_h_offset", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -32, 31 }, PG_VCD_CONFIG
, offsetof(vcdProfile_t
, h_offset
) },
882 { "vcd_v_offset", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -15, 16 }, PG_VCD_CONFIG
, offsetof(vcdProfile_t
, v_offset
) },
885 // PG_DISPLAY_PORT_MSP_CONFIG
886 #ifdef USE_MSP_DISPLAYPORT
887 { "displayport_msp_col_adjust", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -6, 0 }, PG_DISPLAY_PORT_MSP_CONFIG
, offsetof(displayPortProfile_t
, colAdjust
) },
888 { "displayport_msp_row_adjust", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -3, 0 }, PG_DISPLAY_PORT_MSP_CONFIG
, offsetof(displayPortProfile_t
, rowAdjust
) },
891 // PG_DISPLAY_PORT_MSP_CONFIG
893 { "displayport_max7456_col_adjust", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -6, 0 }, PG_DISPLAY_PORT_MSP_CONFIG
, offsetof(displayPortProfile_t
, colAdjust
) },
894 { "displayport_max7456_row_adjust", VAR_INT8
| MASTER_VALUE
, .config
.minmax
= { -3, 0 }, PG_DISPLAY_PORT_MAX7456_CONFIG
, offsetof(displayPortProfile_t
, rowAdjust
) },
898 static gyroConfig_t gyroConfigCopy
;
899 static accelerometerConfig_t accelerometerConfigCopy
;
901 static compassConfig_t compassConfigCopy
;
904 static barometerConfig_t barometerConfigCopy
;
907 static pitotmeterConfig_t pitotmeterConfigCopy
;
909 static featureConfig_t featureConfigCopy
;
910 static rxConfig_t rxConfigCopy
;
913 static pwmConfig_t pwmConfigCopy
;
916 static blackboxConfig_t blackboxConfigCopy
;
918 static rxFailsafeChannelConfig_t rxFailsafeChannelConfigsCopy
[MAX_SUPPORTED_RC_CHANNEL_COUNT
];
919 static rxChannelRangeConfig_t rxChannelRangeConfigsCopy
[NON_AUX_CHANNEL_COUNT
];
920 static motorConfig_t motorConfigCopy
;
921 static throttleCorrectionConfig_t throttleCorrectionConfigCopy
;
922 static failsafeConfig_t failsafeConfigCopy
;
923 static boardAlignment_t boardAlignmentCopy
;
925 static servoConfig_t servoConfigCopy
;
926 static gimbalConfig_t gimbalConfigCopy
;
927 static servoMixer_t customServoMixersCopy
[MAX_SERVO_RULES
];
928 static servoParam_t servoParamsCopy
[MAX_SUPPORTED_SERVOS
];
930 static batteryConfig_t batteryConfigCopy
;
931 static voltageSensorADCConfig_t voltageSensorADCConfigCopy
[MAX_VOLTAGE_SENSOR_ADC
];
932 static currentSensorADCConfig_t currentSensorADCConfigCopy
;
933 #ifdef USE_VIRTUAL_CURRENT_METER
934 static currentSensorVirtualConfig_t currentSensorVirtualConfigCopy
;
936 static motorMixer_t customMotorMixerCopy
[MAX_SUPPORTED_MOTORS
];
937 static mixerConfig_t mixerConfigCopy
;
938 static flight3DConfig_t flight3DConfigCopy
;
939 static serialConfig_t serialConfigCopy
;
940 static serialPinConfig_t serialPinConfigCopy
;
941 static imuConfig_t imuConfigCopy
;
942 static armingConfig_t armingConfigCopy
;
943 static rcControlsConfig_t rcControlsConfigCopy
;
945 static gpsConfig_t gpsConfigCopy
;
946 static navigationConfig_t navigationConfigCopy
;
948 static airplaneConfig_t airplaneConfigCopy
;
950 static telemetryConfig_t telemetryConfigCopy
;
952 static modeActivationCondition_t modeActivationConditionsCopy
[MAX_MODE_ACTIVATION_CONDITION_COUNT
];
953 static adjustmentRange_t adjustmentRangesCopy
[MAX_ADJUSTMENT_RANGE_COUNT
];
955 static ledStripConfig_t ledStripConfigCopy
;
958 static sdcardConfig_t sdcardConfigCopy
;
961 static osdConfig_t osdConfigCopy
;
963 static systemConfig_t systemConfigCopy
;
965 static beeperDevConfig_t beeperDevConfigCopy
;
966 static beeperConfig_t beeperConfigCopy
;
969 static vtxRTC6705Config_t vtxRTC6705ConfigCopy
;
972 static vtxConfig_t vtxConfigCopy
;
975 vcdProfile_t vcdProfileCopy
;
977 #ifdef USE_MSP_DISPLAYPORT
978 displayPortProfile_t displayPortProfileMspCopy
;
981 displayPortProfile_t displayPortProfileMax7456Copy
;
983 static pidConfig_t pidConfigCopy
;
984 static controlRateConfig_t controlRateProfilesCopy
[CONTROL_RATE_PROFILE_COUNT
];
985 static pidProfile_t pidProfileCopy
[MAX_PROFILE_COUNT
];
987 static void cliPrint(const char *str
)
990 bufWriterAppend(cliWriter
, *str
++);
992 bufWriterFlush(cliWriter
);
996 #define cliPrintHashLine(str)
998 static void cliPrintHashLine(const char *str
)
1006 static void cliPutp(void *p
, char ch
)
1008 bufWriterAppend(p
, ch
);
1012 DUMP_MASTER
= (1 << 0),
1013 DUMP_PROFILE
= (1 << 1),
1014 DUMP_RATES
= (1 << 2),
1015 DUMP_ALL
= (1 << 3),
1017 SHOW_DEFAULTS
= (1 << 5),
1018 HIDE_UNUSED
= (1 << 6)
1021 static bool cliDumpPrintf(uint8_t dumpMask
, bool equalsDefault
, const char *format
, ...)
1023 if (!((dumpMask
& DO_DIFF
) && equalsDefault
)) {
1025 va_start(va
, format
);
1026 tfp_format(cliWriter
, cliPutp
, format
, va
);
1028 bufWriterFlush(cliWriter
);
1035 static void cliWrite(uint8_t ch
)
1037 bufWriterAppend(cliWriter
, ch
);
1040 static bool cliDefaultPrintf(uint8_t dumpMask
, bool equalsDefault
, const char *format
, ...)
1042 if ((dumpMask
& SHOW_DEFAULTS
) && !equalsDefault
) {
1046 va_start(va
, format
);
1047 tfp_format(cliWriter
, cliPutp
, format
, va
);
1049 bufWriterFlush(cliWriter
);
1056 static void cliPrintf(const char *format
, ...)
1059 va_start(va
, format
);
1060 tfp_format(cliWriter
, cliPutp
, format
, va
);
1062 bufWriterFlush(cliWriter
);
1065 static void printValuePointer(const clivalue_t
*var
, const void *valuePointer
, bool full
)
1067 cliVar_t value
= { .uint16
= 0 };
1069 switch (var
->type
& VALUE_TYPE_MASK
) {
1071 value
.uint8
= *(uint8_t *)valuePointer
;
1075 value
.int8
= *(int8_t *)valuePointer
;
1079 value
.uint16
= *(uint16_t *)valuePointer
;
1083 value
.int16
= *(int16_t *)valuePointer
;
1087 switch(var
->type
& VALUE_MODE_MASK
) {
1089 cliPrintf("%d", value
);
1091 cliPrintf(" %d %d", var
->config
.minmax
.min
, var
->config
.minmax
.max
);
1095 cliPrint(lookupTables
[var
->config
.lookup
.tableIndex
].values
[value
.uint16
]);
1100 static bool valuePtrEqualsDefault(uint8_t type
, const void *ptr
, const void *ptrDefault
)
1102 bool result
= false;
1103 switch (type
& VALUE_TYPE_MASK
) {
1105 result
= *(uint8_t *)ptr
== *(uint8_t *)ptrDefault
;
1109 result
= *(int8_t *)ptr
== *(int8_t *)ptrDefault
;
1113 result
= *(uint16_t *)ptr
== *(uint16_t *)ptrDefault
;
1117 result
= *(int16_t *)ptr
== *(int16_t *)ptrDefault
;
1124 typedef struct cliCurrentAndDefaultConfig_s
{
1125 const void *currentConfig
; // the copy
1126 const void *defaultConfig
; // the PG value as set by default
1127 } cliCurrentAndDefaultConfig_t
;
1129 static const cliCurrentAndDefaultConfig_t
*getCurrentAndDefaultConfigs(pgn_t pgn
)
1131 static cliCurrentAndDefaultConfig_t ret
;
1134 case PG_GYRO_CONFIG
:
1135 ret
.currentConfig
= &gyroConfigCopy
;
1136 ret
.defaultConfig
= gyroConfig();
1138 case PG_ACCELEROMETER_CONFIG
:
1139 ret
.currentConfig
= &accelerometerConfigCopy
;
1140 ret
.defaultConfig
= accelerometerConfig();
1143 case PG_COMPASS_CONFIG
:
1144 ret
.currentConfig
= &compassConfigCopy
;
1145 ret
.defaultConfig
= compassConfig();
1149 case PG_BAROMETER_CONFIG
:
1150 ret
.currentConfig
= &barometerConfigCopy
;
1151 ret
.defaultConfig
= barometerConfig();
1155 case PG_PITOTMETER_CONFIG
:
1156 ret
.currentConfig
= &pitotmeterConfigCopy
;
1157 ret
.defaultConfig
= pitotmeterConfig();
1160 case PG_FEATURE_CONFIG
:
1161 ret
.currentConfig
= &featureConfigCopy
;
1162 ret
.defaultConfig
= featureConfig();
1165 ret
.currentConfig
= &rxConfigCopy
;
1166 ret
.defaultConfig
= rxConfig();
1170 ret
.currentConfig
= &pwmConfigCopy
;
1171 ret
.defaultConfig
= pwmConfig();
1175 case PG_BLACKBOX_CONFIG
:
1176 ret
.currentConfig
= &blackboxConfigCopy
;
1177 ret
.defaultConfig
= blackboxConfig();
1180 case PG_MOTOR_CONFIG
:
1181 ret
.currentConfig
= &motorConfigCopy
;
1182 ret
.defaultConfig
= motorConfig();
1184 case PG_THROTTLE_CORRECTION_CONFIG
:
1185 ret
.currentConfig
= &throttleCorrectionConfigCopy
;
1186 ret
.defaultConfig
= throttleCorrectionConfig();
1188 case PG_FAILSAFE_CONFIG
:
1189 ret
.currentConfig
= &failsafeConfigCopy
;
1190 ret
.defaultConfig
= failsafeConfig();
1192 case PG_BOARD_ALIGNMENT
:
1193 ret
.currentConfig
= &boardAlignmentCopy
;
1194 ret
.defaultConfig
= boardAlignment();
1196 case PG_MIXER_CONFIG
:
1197 ret
.currentConfig
= &mixerConfigCopy
;
1198 ret
.defaultConfig
= mixerConfig();
1200 case PG_MOTOR_3D_CONFIG
:
1201 ret
.currentConfig
= &flight3DConfigCopy
;
1202 ret
.defaultConfig
= flight3DConfig();
1205 case PG_SERVO_CONFIG
:
1206 ret
.currentConfig
= &servoConfigCopy
;
1207 ret
.defaultConfig
= servoConfig();
1209 case PG_GIMBAL_CONFIG
:
1210 ret
.currentConfig
= &gimbalConfigCopy
;
1211 ret
.defaultConfig
= gimbalConfig();
1214 case PG_BATTERY_CONFIG
:
1215 ret
.currentConfig
= &batteryConfigCopy
;
1216 ret
.defaultConfig
= batteryConfig();
1218 case PG_VOLTAGE_SENSOR_ADC_CONFIG
:
1219 ret
.currentConfig
= &voltageSensorADCConfigCopy
[0];
1220 ret
.defaultConfig
= voltageSensorADCConfig(0);
1222 case PG_CURRENT_SENSOR_ADC_CONFIG
:
1223 ret
.currentConfig
= ¤tSensorADCConfigCopy
;
1224 ret
.defaultConfig
= currentSensorADCConfig();
1226 #ifdef USE_VIRTUAL_CURRENT_METER
1227 case PG_CURRENT_SENSOR_VIRTUAL_CONFIG
:
1228 ret
.currentConfig
= ¤tSensorVirtualConfigCopy
;
1229 ret
.defaultConfig
= currentSensorVirtualConfig();
1232 case PG_SERIAL_CONFIG
:
1233 ret
.currentConfig
= &serialConfigCopy
;
1234 ret
.defaultConfig
= serialConfig();
1236 case PG_SERIAL_PIN_CONFIG
:
1237 ret
.currentConfig
= &serialPinConfigCopy
;
1238 ret
.defaultConfig
= serialPinConfig();
1241 ret
.currentConfig
= &imuConfigCopy
;
1242 ret
.defaultConfig
= imuConfig();
1244 case PG_RC_CONTROLS_CONFIG
:
1245 ret
.currentConfig
= &rcControlsConfigCopy
;
1246 ret
.defaultConfig
= rcControlsConfig();
1248 case PG_ARMING_CONFIG
:
1249 ret
.currentConfig
= &armingConfigCopy
;
1250 ret
.defaultConfig
= armingConfig();
1254 ret
.currentConfig
= &gpsConfigCopy
;
1255 ret
.defaultConfig
= gpsConfig();
1257 case PG_NAVIGATION_CONFIG
:
1258 ret
.currentConfig
= &navigationConfigCopy
;
1259 ret
.defaultConfig
= navigationConfig();
1262 case PG_AIRPLANE_CONFIG
:
1263 ret
.currentConfig
= &airplaneConfigCopy
;
1264 ret
.defaultConfig
= airplaneConfig();
1267 case PG_TELEMETRY_CONFIG
:
1268 ret
.currentConfig
= &telemetryConfigCopy
;
1269 ret
.defaultConfig
= telemetryConfig();
1273 case PG_LED_STRIP_CONFIG
:
1274 ret
.currentConfig
= &ledStripConfigCopy
;
1275 ret
.defaultConfig
= ledStripConfig();
1279 case PG_SDCARD_CONFIG
:
1280 ret
.currentConfig
= &sdcardConfigCopy
;
1281 ret
.defaultConfig
= sdcardConfig();
1286 ret
.currentConfig
= &osdConfigCopy
;
1287 ret
.defaultConfig
= osdConfig();
1290 case PG_SYSTEM_CONFIG
:
1291 ret
.currentConfig
= &systemConfigCopy
;
1292 ret
.defaultConfig
= systemConfig();
1294 case PG_CONTROL_RATE_PROFILES
:
1295 ret
.currentConfig
= &controlRateProfilesCopy
[0];
1296 ret
.defaultConfig
= controlRateProfiles(0);
1298 case PG_PID_PROFILE
:
1299 ret
.currentConfig
= &pidProfileCopy
[0];
1300 ret
.defaultConfig
= pidProfiles(0);
1302 case PG_RX_FAILSAFE_CHANNEL_CONFIG
:
1303 ret
.currentConfig
= &rxFailsafeChannelConfigsCopy
[0];
1304 ret
.defaultConfig
= rxFailsafeChannelConfigs(0);
1306 case PG_RX_CHANNEL_RANGE_CONFIG
:
1307 ret
.currentConfig
= &rxChannelRangeConfigsCopy
[0];
1308 ret
.defaultConfig
= rxChannelRangeConfigs(0);
1311 case PG_SERVO_MIXER
:
1312 ret
.currentConfig
= &customServoMixersCopy
[0];
1313 ret
.defaultConfig
= customServoMixers(0);
1315 case PG_SERVO_PARAMS
:
1316 ret
.currentConfig
= &servoParamsCopy
[0];
1317 ret
.defaultConfig
= servoParams(0);
1320 case PG_MOTOR_MIXER
:
1321 ret
.currentConfig
= &customMotorMixerCopy
[0];
1322 ret
.defaultConfig
= customMotorMixer(0);
1324 case PG_MODE_ACTIVATION_PROFILE
:
1325 ret
.currentConfig
= &modeActivationConditionsCopy
[0];
1326 ret
.defaultConfig
= modeActivationConditions(0);
1328 case PG_ADJUSTMENT_RANGE_CONFIG
:
1329 ret
.currentConfig
= &adjustmentRangesCopy
[0];
1330 ret
.defaultConfig
= adjustmentRanges(0);
1333 case PG_BEEPER_CONFIG
:
1334 ret
.currentConfig
= &beeperConfigCopy
;
1335 ret
.defaultConfig
= beeperConfig();
1337 case PG_BEEPER_DEV_CONFIG
:
1338 ret
.currentConfig
= &beeperDevConfigCopy
;
1339 ret
.defaultConfig
= beeperDevConfig();
1343 case PG_VTX_RTC6705_CONFIG
:
1344 ret
.currentConfig
= &vtxRTC6705ConfigCopy
;
1345 ret
.defaultConfig
= vtxRTC6705Config();
1350 ret
.currentConfig
= &vtxConfigCopy
;
1351 ret
.defaultConfig
= vtxConfig();
1356 ret
.currentConfig
= &vcdProfileCopy
;
1357 ret
.defaultConfig
= vcdProfile();
1360 #ifdef USE_MSP_DISPLAYPORT
1361 case PG_DISPLAY_PORT_MSP_CONFIG
:
1362 ret
.currentConfig
= &displayPortProfileMspCopy
;
1363 ret
.defaultConfig
= displayPortProfileMsp();
1367 case PG_DISPLAY_PORT_MAX7456_CONFIG
:
1368 ret
.currentConfig
= &displayPortProfileMax7456Copy
;
1369 ret
.defaultConfig
= displayPortProfileMax7456();
1373 ret
.currentConfig
= &pidConfigCopy
;
1374 ret
.defaultConfig
= pidConfig();
1377 ret
.currentConfig
= NULL
;
1378 ret
.defaultConfig
= NULL
;
1384 static uint16_t getValueOffset(const clivalue_t
*value
)
1386 switch (value
->type
& VALUE_SECTION_MASK
) {
1388 return value
->offset
;
1390 return value
->offset
+ sizeof(pidProfile_t
) * getCurrentPidProfileIndex();
1391 case PROFILE_RATE_VALUE
:
1392 return value
->offset
+ sizeof(controlRateConfig_t
) * getCurrentControlRateProfileIndex();
1397 static void *getValuePointer(const clivalue_t
*value
)
1399 const pgRegistry_t
* rec
= pgFind(value
->pgn
);
1400 return CONST_CAST(void *, rec
->address
+ getValueOffset(value
));
1403 static void dumpPgValue(const clivalue_t
*value
, uint8_t dumpMask
)
1405 const cliCurrentAndDefaultConfig_t
*config
= getCurrentAndDefaultConfigs(value
->pgn
);
1406 if (config
->currentConfig
== NULL
|| config
->defaultConfig
== NULL
) {
1407 // has not been set up properly
1408 cliPrintf("VALUE %s ERROR\r\n", value
->name
);
1412 const char *format
= "set %s = ";
1413 const char *defaultFormat
= "#set %s = ";
1414 const int valueOffset
= getValueOffset(value
);
1415 const bool equalsDefault
= valuePtrEqualsDefault(value
->type
, (uint8_t*)config
->currentConfig
+ valueOffset
, (uint8_t*)config
->defaultConfig
+ valueOffset
);
1416 if (((dumpMask
& DO_DIFF
) == 0) || !equalsDefault
) {
1417 if (dumpMask
& SHOW_DEFAULTS
&& !equalsDefault
) {
1418 cliPrintf(defaultFormat
, value
->name
);
1419 printValuePointer(value
, (uint8_t*)config
->defaultConfig
+ valueOffset
, 0);
1422 cliPrintf(format
, value
->name
);
1423 printValuePointer(value
, (uint8_t*)config
->currentConfig
+ valueOffset
, 0);
1428 static void dumpAllValues(uint16_t valueSection
, uint8_t dumpMask
)
1430 for (uint32_t i
= 0; i
< ARRAYLEN(valueTable
); i
++) {
1431 const clivalue_t
*value
= &valueTable
[i
];
1432 bufWriterFlush(cliWriter
);
1433 if ((value
->type
& VALUE_SECTION_MASK
) == valueSection
) {
1434 dumpPgValue(value
, dumpMask
);
1439 static void cliPrintVar(const clivalue_t
*var
, bool full
)
1441 const void *ptr
= getValuePointer(var
);
1443 printValuePointer(var
, ptr
, full
);
1446 static void cliPrintVarRange(const clivalue_t
*var
)
1448 switch (var
->type
& VALUE_MODE_MASK
) {
1449 case (MODE_DIRECT
): {
1450 cliPrintf("Allowed range: %d - %d\r\n", var
->config
.minmax
.min
, var
->config
.minmax
.max
);
1453 case (MODE_LOOKUP
): {
1454 const lookupTableEntry_t
*tableEntry
= &lookupTables
[var
->config
.lookup
.tableIndex
];
1455 cliPrint("Allowed values:");
1456 for (uint32_t i
= 0; i
< tableEntry
->valueCount
; i
++) {
1459 cliPrintf(" %s", tableEntry
->values
[i
]);
1467 static void cliSetVar(const clivalue_t
*var
, const cliVar_t value
)
1469 void *ptr
= getValuePointer(var
);
1471 switch (var
->type
& VALUE_TYPE_MASK
) {
1473 *(uint8_t *)ptr
= value
.uint8
;
1477 *(int8_t *)ptr
= value
.int8
;
1481 *(uint16_t *)ptr
= value
.uint16
;
1485 *(int16_t *)ptr
= value
.int16
;
1491 static void cliRepeat(char ch
, uint8_t len
)
1493 for (int i
= 0; i
< len
; i
++) {
1494 bufWriterAppend(cliWriter
, ch
);
1500 static void cliPrompt(void)
1505 static void cliShowParseError(void)
1507 cliPrint("Parse error\r\n");
1510 static void cliShowArgumentRangeError(char *name
, int min
, int max
)
1512 cliPrintf("%s not between %d and %d\r\n", name
, min
, max
);
1515 static const char *nextArg(const char *currentArg
)
1517 const char *ptr
= strchr(currentArg
, ' ');
1518 while (ptr
&& *ptr
== ' ') {
1525 static const char *processChannelRangeArgs(const char *ptr
, channelRange_t
*range
, uint8_t *validArgumentCount
)
1527 for (uint32_t argIndex
= 0; argIndex
< 2; argIndex
++) {
1530 int val
= atoi(ptr
);
1531 val
= CHANNEL_VALUE_TO_STEP(val
);
1532 if (val
>= MIN_MODE_RANGE_STEP
&& val
<= MAX_MODE_RANGE_STEP
) {
1533 if (argIndex
== 0) {
1534 range
->startStep
= val
;
1536 range
->endStep
= val
;
1538 (*validArgumentCount
)++;
1546 // Check if a string's length is zero
1547 static bool isEmpty(const char *string
)
1549 return (string
== NULL
|| *string
== '\0') ? true : false;
1552 static void printRxFailsafe(uint8_t dumpMask
, const rxFailsafeChannelConfig_t
*rxFailsafeChannelConfigs
, const rxFailsafeChannelConfig_t
*defaultRxFailsafeChannelConfigs
)
1554 // print out rxConfig failsafe settings
1555 for (uint32_t channel
= 0; channel
< MAX_SUPPORTED_RC_CHANNEL_COUNT
; channel
++) {
1556 const rxFailsafeChannelConfig_t
*channelFailsafeConfig
= &rxFailsafeChannelConfigs
[channel
];
1557 const rxFailsafeChannelConfig_t
*defaultChannelFailsafeConfig
= &defaultRxFailsafeChannelConfigs
[channel
];
1558 const bool equalsDefault
= channelFailsafeConfig
->mode
== defaultChannelFailsafeConfig
->mode
1559 && channelFailsafeConfig
->step
== defaultChannelFailsafeConfig
->step
;
1560 const bool requireValue
= channelFailsafeConfig
->mode
== RX_FAILSAFE_MODE_SET
;
1562 const char *format
= "rxfail %u %c %d\r\n";
1563 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
1565 rxFailsafeModeCharacters
[defaultChannelFailsafeConfig
->mode
],
1566 RXFAIL_STEP_TO_CHANNEL_VALUE(defaultChannelFailsafeConfig
->step
)
1568 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
1570 rxFailsafeModeCharacters
[channelFailsafeConfig
->mode
],
1571 RXFAIL_STEP_TO_CHANNEL_VALUE(channelFailsafeConfig
->step
)
1574 const char *format
= "rxfail %u %c\r\n";
1575 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
1577 rxFailsafeModeCharacters
[defaultChannelFailsafeConfig
->mode
]
1579 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
1581 rxFailsafeModeCharacters
[channelFailsafeConfig
->mode
]
1587 static void cliRxFailsafe(char *cmdline
)
1592 if (isEmpty(cmdline
)) {
1593 // print out rxConfig failsafe settings
1594 for (channel
= 0; channel
< MAX_SUPPORTED_RC_CHANNEL_COUNT
; channel
++) {
1595 cliRxFailsafe(itoa(channel
, buf
, 10));
1598 const char *ptr
= cmdline
;
1599 channel
= atoi(ptr
++);
1600 if ((channel
< MAX_SUPPORTED_RC_CHANNEL_COUNT
)) {
1602 rxFailsafeChannelConfig_t
*channelFailsafeConfig
= rxFailsafeChannelConfigsMutable(channel
);
1604 const rxFailsafeChannelType_e type
= (channel
< NON_AUX_CHANNEL_COUNT
) ? RX_FAILSAFE_TYPE_FLIGHT
: RX_FAILSAFE_TYPE_AUX
;
1605 rxFailsafeChannelMode_e mode
= channelFailsafeConfig
->mode
;
1606 bool requireValue
= channelFailsafeConfig
->mode
== RX_FAILSAFE_MODE_SET
;
1610 const char *p
= strchr(rxFailsafeModeCharacters
, *(ptr
));
1612 const uint8_t requestedMode
= p
- rxFailsafeModeCharacters
;
1613 mode
= rxFailsafeModesTable
[type
][requestedMode
];
1615 mode
= RX_FAILSAFE_MODE_INVALID
;
1617 if (mode
== RX_FAILSAFE_MODE_INVALID
) {
1618 cliShowParseError();
1622 requireValue
= mode
== RX_FAILSAFE_MODE_SET
;
1626 if (!requireValue
) {
1627 cliShowParseError();
1630 uint16_t value
= atoi(ptr
);
1631 value
= CHANNEL_VALUE_TO_RXFAIL_STEP(value
);
1632 if (value
> MAX_RXFAIL_RANGE_STEP
) {
1633 cliPrint("Value out of range\r\n");
1637 channelFailsafeConfig
->step
= value
;
1638 } else if (requireValue
) {
1639 cliShowParseError();
1642 channelFailsafeConfig
->mode
= mode
;
1645 char modeCharacter
= rxFailsafeModeCharacters
[channelFailsafeConfig
->mode
];
1647 // double use of cliPrintf below
1648 // 1. acknowledge interpretation on command,
1649 // 2. query current setting on single item,
1652 cliPrintf("rxfail %u %c %d\r\n",
1655 RXFAIL_STEP_TO_CHANNEL_VALUE(channelFailsafeConfig
->step
)
1658 cliPrintf("rxfail %u %c\r\n",
1664 cliShowArgumentRangeError("channel", 0, MAX_SUPPORTED_RC_CHANNEL_COUNT
- 1);
1669 static void printAux(uint8_t dumpMask
, const modeActivationCondition_t
*modeActivationConditions
, const modeActivationCondition_t
*defaultModeActivationConditions
)
1671 const char *format
= "aux %u %u %u %u %u\r\n";
1672 // print out aux channel settings
1673 for (uint32_t i
= 0; i
< MAX_MODE_ACTIVATION_CONDITION_COUNT
; i
++) {
1674 const modeActivationCondition_t
*mac
= &modeActivationConditions
[i
];
1675 bool equalsDefault
= false;
1676 if (defaultModeActivationConditions
) {
1677 const modeActivationCondition_t
*macDefault
= &defaultModeActivationConditions
[i
];
1678 equalsDefault
= mac
->modeId
== macDefault
->modeId
1679 && mac
->auxChannelIndex
== macDefault
->auxChannelIndex
1680 && mac
->range
.startStep
== macDefault
->range
.startStep
1681 && mac
->range
.endStep
== macDefault
->range
.endStep
;
1682 const box_t
*box
= findBoxByBoxId(macDefault
->modeId
);
1684 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
1687 macDefault
->auxChannelIndex
,
1688 MODE_STEP_TO_CHANNEL_VALUE(macDefault
->range
.startStep
),
1689 MODE_STEP_TO_CHANNEL_VALUE(macDefault
->range
.endStep
)
1693 const box_t
*box
= findBoxByBoxId(mac
->modeId
);
1695 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
1698 mac
->auxChannelIndex
,
1699 MODE_STEP_TO_CHANNEL_VALUE(mac
->range
.startStep
),
1700 MODE_STEP_TO_CHANNEL_VALUE(mac
->range
.endStep
)
1706 static void cliAux(char *cmdline
)
1711 if (isEmpty(cmdline
)) {
1712 printAux(DUMP_MASTER
, modeActivationConditions(0), NULL
);
1716 if (i
< MAX_MODE_ACTIVATION_CONDITION_COUNT
) {
1717 modeActivationCondition_t
*mac
= modeActivationConditionsMutable(i
);
1718 uint8_t validArgumentCount
= 0;
1722 const box_t
*box
= findBoxByPermanentId(val
);
1724 mac
->modeId
= box
->boxId
;
1725 validArgumentCount
++;
1731 if (val
>= 0 && val
< MAX_AUX_CHANNEL_COUNT
) {
1732 mac
->auxChannelIndex
= val
;
1733 validArgumentCount
++;
1736 ptr
= processChannelRangeArgs(ptr
, &mac
->range
, &validArgumentCount
);
1738 if (validArgumentCount
!= 4) {
1739 memset(mac
, 0, sizeof(modeActivationCondition_t
));
1742 cliShowArgumentRangeError("index", 0, MAX_MODE_ACTIVATION_CONDITION_COUNT
- 1);
1747 static void printSerial(uint8_t dumpMask
, const serialConfig_t
*serialConfig
, const serialConfig_t
*serialConfigDefault
)
1749 const char *format
= "serial %d %d %ld %ld %ld %ld\r\n";
1750 for (uint32_t i
= 0; i
< SERIAL_PORT_COUNT
; i
++) {
1751 if (!serialIsPortAvailable(serialConfig
->portConfigs
[i
].identifier
)) {
1754 bool equalsDefault
= false;
1755 if (serialConfigDefault
) {
1756 equalsDefault
= serialConfig
->portConfigs
[i
].identifier
== serialConfigDefault
->portConfigs
[i
].identifier
1757 && serialConfig
->portConfigs
[i
].functionMask
== serialConfigDefault
->portConfigs
[i
].functionMask
1758 && serialConfig
->portConfigs
[i
].msp_baudrateIndex
== serialConfigDefault
->portConfigs
[i
].msp_baudrateIndex
1759 && serialConfig
->portConfigs
[i
].gps_baudrateIndex
== serialConfigDefault
->portConfigs
[i
].gps_baudrateIndex
1760 && serialConfig
->portConfigs
[i
].telemetry_baudrateIndex
== serialConfigDefault
->portConfigs
[i
].telemetry_baudrateIndex
1761 && serialConfig
->portConfigs
[i
].blackbox_baudrateIndex
== serialConfigDefault
->portConfigs
[i
].blackbox_baudrateIndex
;
1762 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
1763 serialConfigDefault
->portConfigs
[i
].identifier
,
1764 serialConfigDefault
->portConfigs
[i
].functionMask
,
1765 baudRates
[serialConfigDefault
->portConfigs
[i
].msp_baudrateIndex
],
1766 baudRates
[serialConfigDefault
->portConfigs
[i
].gps_baudrateIndex
],
1767 baudRates
[serialConfigDefault
->portConfigs
[i
].telemetry_baudrateIndex
],
1768 baudRates
[serialConfigDefault
->portConfigs
[i
].blackbox_baudrateIndex
]
1771 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
1772 serialConfig
->portConfigs
[i
].identifier
,
1773 serialConfig
->portConfigs
[i
].functionMask
,
1774 baudRates
[serialConfig
->portConfigs
[i
].msp_baudrateIndex
],
1775 baudRates
[serialConfig
->portConfigs
[i
].gps_baudrateIndex
],
1776 baudRates
[serialConfig
->portConfigs
[i
].telemetry_baudrateIndex
],
1777 baudRates
[serialConfig
->portConfigs
[i
].blackbox_baudrateIndex
]
1782 static void cliSerial(char *cmdline
)
1784 if (isEmpty(cmdline
)) {
1785 printSerial(DUMP_MASTER
, serialConfig(), NULL
);
1788 serialPortConfig_t portConfig
;
1789 memset(&portConfig
, 0 , sizeof(portConfig
));
1791 serialPortConfig_t
*currentConfig
;
1793 uint8_t validArgumentCount
= 0;
1795 const char *ptr
= cmdline
;
1797 int val
= atoi(ptr
++);
1798 currentConfig
= serialFindPortConfiguration(val
);
1799 if (currentConfig
) {
1800 portConfig
.identifier
= val
;
1801 validArgumentCount
++;
1807 portConfig
.functionMask
= val
& 0xFFFF;
1808 validArgumentCount
++;
1811 for (int i
= 0; i
< 4; i
++) {
1819 uint8_t baudRateIndex
= lookupBaudRateIndex(val
);
1820 if (baudRates
[baudRateIndex
] != (uint32_t) val
) {
1826 if (baudRateIndex
< BAUD_9600
|| baudRateIndex
> BAUD_1000000
) {
1829 portConfig
.msp_baudrateIndex
= baudRateIndex
;
1832 if (baudRateIndex
< BAUD_9600
|| baudRateIndex
> BAUD_115200
) {
1835 portConfig
.gps_baudrateIndex
= baudRateIndex
;
1838 if (baudRateIndex
!= BAUD_AUTO
&& baudRateIndex
> BAUD_115200
) {
1841 portConfig
.telemetry_baudrateIndex
= baudRateIndex
;
1844 if (baudRateIndex
< BAUD_19200
|| baudRateIndex
> BAUD_250000
) {
1847 portConfig
.blackbox_baudrateIndex
= baudRateIndex
;
1851 validArgumentCount
++;
1854 if (validArgumentCount
< 6) {
1855 cliShowParseError();
1859 memcpy(currentConfig
, &portConfig
, sizeof(portConfig
));
1862 #ifndef SKIP_SERIAL_PASSTHROUGH
1863 static void cliSerialPassthrough(char *cmdline
)
1865 if (isEmpty(cmdline
)) {
1866 cliShowParseError();
1874 char* tok
= strtok_r(cmdline
, " ", &saveptr
);
1877 while (tok
!= NULL
) {
1886 if (strstr(tok
, "rx") || strstr(tok
, "RX"))
1888 if (strstr(tok
, "tx") || strstr(tok
, "TX"))
1893 tok
= strtok_r(NULL
, " ", &saveptr
);
1896 printf("Port %d ", id
);
1897 serialPort_t
*passThroughPort
;
1898 serialPortUsage_t
*passThroughPortUsage
= findSerialPortUsageByIdentifier(id
);
1899 if (!passThroughPortUsage
|| passThroughPortUsage
->serialPort
== NULL
) {
1901 printf("closed, specify baud.\r\n");
1907 passThroughPort
= openSerialPort(id
, FUNCTION_NONE
, NULL
,
1909 SERIAL_NOT_INVERTED
);
1910 if (!passThroughPort
) {
1911 printf("could not be opened.\r\n");
1914 printf("opened, baud = %d.\r\n", baud
);
1916 passThroughPort
= passThroughPortUsage
->serialPort
;
1917 // If the user supplied a mode, override the port's mode, otherwise
1918 // leave the mode unchanged. serialPassthrough() handles one-way ports.
1919 printf("already open.\r\n");
1920 if (mode
&& passThroughPort
->mode
!= mode
) {
1921 printf("mode changed from %d to %d.\r\n",
1922 passThroughPort
->mode
, mode
);
1923 serialSetMode(passThroughPort
, mode
);
1925 // If this port has a rx callback associated we need to remove it now.
1926 // Otherwise no data will be pushed in the serial port buffer!
1927 if (passThroughPort
->rxCallback
) {
1928 passThroughPort
->rxCallback
= 0;
1932 printf("forwarding, power cycle to exit.\r\n");
1934 serialPassthrough(cliPort
, passThroughPort
, NULL
, NULL
);
1938 static void printAdjustmentRange(uint8_t dumpMask
, const adjustmentRange_t
*adjustmentRanges
, const adjustmentRange_t
*defaultAdjustmentRanges
)
1940 const char *format
= "adjrange %u %u %u %u %u %u %u\r\n";
1941 // print out adjustment ranges channel settings
1942 for (uint32_t i
= 0; i
< MAX_ADJUSTMENT_RANGE_COUNT
; i
++) {
1943 const adjustmentRange_t
*ar
= &adjustmentRanges
[i
];
1944 bool equalsDefault
= false;
1945 if (defaultAdjustmentRanges
) {
1946 const adjustmentRange_t
*arDefault
= &defaultAdjustmentRanges
[i
];
1947 equalsDefault
= ar
->auxChannelIndex
== arDefault
->auxChannelIndex
1948 && ar
->range
.startStep
== arDefault
->range
.startStep
1949 && ar
->range
.endStep
== arDefault
->range
.endStep
1950 && ar
->adjustmentFunction
== arDefault
->adjustmentFunction
1951 && ar
->auxSwitchChannelIndex
== arDefault
->auxSwitchChannelIndex
1952 && ar
->adjustmentIndex
== arDefault
->adjustmentIndex
;
1953 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
1955 arDefault
->adjustmentIndex
,
1956 arDefault
->auxChannelIndex
,
1957 MODE_STEP_TO_CHANNEL_VALUE(arDefault
->range
.startStep
),
1958 MODE_STEP_TO_CHANNEL_VALUE(arDefault
->range
.endStep
),
1959 arDefault
->adjustmentFunction
,
1960 arDefault
->auxSwitchChannelIndex
1963 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
1965 ar
->adjustmentIndex
,
1966 ar
->auxChannelIndex
,
1967 MODE_STEP_TO_CHANNEL_VALUE(ar
->range
.startStep
),
1968 MODE_STEP_TO_CHANNEL_VALUE(ar
->range
.endStep
),
1969 ar
->adjustmentFunction
,
1970 ar
->auxSwitchChannelIndex
1975 static void cliAdjustmentRange(char *cmdline
)
1980 if (isEmpty(cmdline
)) {
1981 printAdjustmentRange(DUMP_MASTER
, adjustmentRanges(0), NULL
);
1985 if (i
< MAX_ADJUSTMENT_RANGE_COUNT
) {
1986 adjustmentRange_t
*ar
= adjustmentRangesMutable(i
);
1987 uint8_t validArgumentCount
= 0;
1992 if (val
>= 0 && val
< MAX_SIMULTANEOUS_ADJUSTMENT_COUNT
) {
1993 ar
->adjustmentIndex
= val
;
1994 validArgumentCount
++;
2000 if (val
>= 0 && val
< MAX_AUX_CHANNEL_COUNT
) {
2001 ar
->auxChannelIndex
= val
;
2002 validArgumentCount
++;
2006 ptr
= processChannelRangeArgs(ptr
, &ar
->range
, &validArgumentCount
);
2011 if (val
>= 0 && val
< ADJUSTMENT_FUNCTION_COUNT
) {
2012 ar
->adjustmentFunction
= val
;
2013 validArgumentCount
++;
2019 if (val
>= 0 && val
< MAX_AUX_CHANNEL_COUNT
) {
2020 ar
->auxSwitchChannelIndex
= val
;
2021 validArgumentCount
++;
2025 if (validArgumentCount
!= 6) {
2026 memset(ar
, 0, sizeof(adjustmentRange_t
));
2027 cliShowParseError();
2030 cliShowArgumentRangeError("index", 0, MAX_ADJUSTMENT_RANGE_COUNT
- 1);
2035 #ifndef USE_QUAD_MIXER_ONLY
2036 static void printMotorMix(uint8_t dumpMask
, const motorMixer_t
*customMotorMixer
, const motorMixer_t
*defaultCustomMotorMixer
)
2038 const char *format
= "mmix %d %s %s %s %s\r\n";
2040 char buf1
[FTOA_BUFFER_LENGTH
];
2041 char buf2
[FTOA_BUFFER_LENGTH
];
2042 char buf3
[FTOA_BUFFER_LENGTH
];
2043 for (uint32_t i
= 0; i
< MAX_SUPPORTED_MOTORS
; i
++) {
2044 if (customMotorMixer
[i
].throttle
== 0.0f
)
2046 const float thr
= customMotorMixer
[i
].throttle
;
2047 const float roll
= customMotorMixer
[i
].roll
;
2048 const float pitch
= customMotorMixer
[i
].pitch
;
2049 const float yaw
= customMotorMixer
[i
].yaw
;
2050 bool equalsDefault
= false;
2051 if (defaultCustomMotorMixer
) {
2052 const float thrDefault
= defaultCustomMotorMixer
[i
].throttle
;
2053 const float rollDefault
= defaultCustomMotorMixer
[i
].roll
;
2054 const float pitchDefault
= defaultCustomMotorMixer
[i
].pitch
;
2055 const float yawDefault
= defaultCustomMotorMixer
[i
].yaw
;
2056 const bool equalsDefault
= thr
== thrDefault
&& roll
== rollDefault
&& pitch
== pitchDefault
&& yaw
== yawDefault
;
2058 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
2060 ftoa(thrDefault
, buf0
),
2061 ftoa(rollDefault
, buf1
),
2062 ftoa(pitchDefault
, buf2
),
2063 ftoa(yawDefault
, buf3
));
2065 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
2073 #endif // USE_QUAD_MIXER_ONLY
2075 static void cliMotorMix(char *cmdline
)
2077 #ifdef USE_QUAD_MIXER_ONLY
2084 if (isEmpty(cmdline
)) {
2085 printMotorMix(DUMP_MASTER
, customMotorMixer(0), NULL
);
2086 } else if (strncasecmp(cmdline
, "reset", 5) == 0) {
2087 // erase custom mixer
2088 for (uint32_t i
= 0; i
< MAX_SUPPORTED_MOTORS
; i
++) {
2089 customMotorMixerMutable(i
)->throttle
= 0.0f
;
2091 } else if (strncasecmp(cmdline
, "load", 4) == 0) {
2092 ptr
= nextArg(cmdline
);
2095 for (uint32_t i
= 0; ; i
++) {
2096 if (mixerNames
[i
] == NULL
) {
2097 cliPrint("Invalid name\r\n");
2100 if (strncasecmp(ptr
, mixerNames
[i
], len
) == 0) {
2101 mixerLoadMix(i
, customMotorMixerMutable(0));
2102 cliPrintf("Loaded %s\r\n", mixerNames
[i
]);
2110 uint32_t i
= atoi(ptr
); // get motor number
2111 if (i
< MAX_SUPPORTED_MOTORS
) {
2114 customMotorMixerMutable(i
)->throttle
= fastA2F(ptr
);
2119 customMotorMixerMutable(i
)->roll
= fastA2F(ptr
);
2124 customMotorMixerMutable(i
)->pitch
= fastA2F(ptr
);
2129 customMotorMixerMutable(i
)->yaw
= fastA2F(ptr
);
2133 cliShowParseError();
2135 printMotorMix(DUMP_MASTER
, customMotorMixer(0), NULL
);
2138 cliShowArgumentRangeError("index", 0, MAX_SUPPORTED_MOTORS
- 1);
2144 static void printRxRange(uint8_t dumpMask
, const rxChannelRangeConfig_t
*channelRangeConfigs
, const rxChannelRangeConfig_t
*defaultChannelRangeConfigs
)
2146 const char *format
= "rxrange %u %u %u\r\n";
2147 for (uint32_t i
= 0; i
< NON_AUX_CHANNEL_COUNT
; i
++) {
2148 bool equalsDefault
= false;
2149 if (defaultChannelRangeConfigs
) {
2150 equalsDefault
= channelRangeConfigs
[i
].min
== defaultChannelRangeConfigs
[i
].min
2151 && channelRangeConfigs
[i
].max
== defaultChannelRangeConfigs
[i
].max
;
2152 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
2154 defaultChannelRangeConfigs
[i
].min
,
2155 defaultChannelRangeConfigs
[i
].max
2158 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
2160 channelRangeConfigs
[i
].min
,
2161 channelRangeConfigs
[i
].max
2166 static void cliRxRange(char *cmdline
)
2168 int i
, validArgumentCount
= 0;
2171 if (isEmpty(cmdline
)) {
2172 printRxRange(DUMP_MASTER
, rxChannelRangeConfigs(0), NULL
);
2173 } else if (strcasecmp(cmdline
, "reset") == 0) {
2174 resetAllRxChannelRangeConfigurations(rxChannelRangeConfigsMutable(0));
2178 if (i
>= 0 && i
< NON_AUX_CHANNEL_COUNT
) {
2179 int rangeMin
, rangeMax
;
2183 rangeMin
= atoi(ptr
);
2184 validArgumentCount
++;
2189 rangeMax
= atoi(ptr
);
2190 validArgumentCount
++;
2193 if (validArgumentCount
!= 2) {
2194 cliShowParseError();
2195 } else if (rangeMin
< PWM_PULSE_MIN
|| rangeMin
> PWM_PULSE_MAX
|| rangeMax
< PWM_PULSE_MIN
|| rangeMax
> PWM_PULSE_MAX
) {
2196 cliShowParseError();
2198 rxChannelRangeConfig_t
*channelRangeConfig
= rxChannelRangeConfigsMutable(i
);
2199 channelRangeConfig
->min
= rangeMin
;
2200 channelRangeConfig
->max
= rangeMax
;
2203 cliShowArgumentRangeError("channel", 0, NON_AUX_CHANNEL_COUNT
- 1);
2209 static void printLed(uint8_t dumpMask
, const ledConfig_t
*ledConfigs
, const ledConfig_t
*defaultLedConfigs
)
2211 const char *format
= "led %u %s\r\n";
2212 char ledConfigBuffer
[20];
2213 char ledConfigDefaultBuffer
[20];
2214 for (uint32_t i
= 0; i
< LED_MAX_STRIP_LENGTH
; i
++) {
2215 ledConfig_t ledConfig
= ledConfigs
[i
];
2216 generateLedConfig(&ledConfig
, ledConfigBuffer
, sizeof(ledConfigBuffer
));
2217 bool equalsDefault
= false;
2218 if (defaultLedConfigs
) {
2219 ledConfig_t ledConfigDefault
= defaultLedConfigs
[i
];
2220 equalsDefault
= ledConfig
== ledConfigDefault
;
2221 generateLedConfig(&ledConfigDefault
, ledConfigDefaultBuffer
, sizeof(ledConfigDefaultBuffer
));
2222 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, i
, ledConfigDefaultBuffer
);
2224 cliDumpPrintf(dumpMask
, equalsDefault
, format
, i
, ledConfigBuffer
);
2228 static void cliLed(char *cmdline
)
2233 if (isEmpty(cmdline
)) {
2234 printLed(DUMP_MASTER
, ledStripConfig()->ledConfigs
, NULL
);
2238 if (i
< LED_MAX_STRIP_LENGTH
) {
2239 ptr
= nextArg(cmdline
);
2240 if (!parseLedStripConfig(i
, ptr
)) {
2241 cliShowParseError();
2244 cliShowArgumentRangeError("index", 0, LED_MAX_STRIP_LENGTH
- 1);
2249 static void printColor(uint8_t dumpMask
, const hsvColor_t
*colors
, const hsvColor_t
*defaultColors
)
2251 const char *format
= "color %u %d,%u,%u\r\n";
2252 for (uint32_t i
= 0; i
< LED_CONFIGURABLE_COLOR_COUNT
; i
++) {
2253 const hsvColor_t
*color
= &colors
[i
];
2254 bool equalsDefault
= false;
2255 if (defaultColors
) {
2256 const hsvColor_t
*colorDefault
= &defaultColors
[i
];
2257 equalsDefault
= color
->h
== colorDefault
->h
2258 && color
->s
== colorDefault
->s
2259 && color
->v
== colorDefault
->v
;
2260 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, i
,colorDefault
->h
, colorDefault
->s
, colorDefault
->v
);
2262 cliDumpPrintf(dumpMask
, equalsDefault
, format
, i
, color
->h
, color
->s
, color
->v
);
2266 static void cliColor(char *cmdline
)
2268 if (isEmpty(cmdline
)) {
2269 printColor(DUMP_MASTER
, ledStripConfig()->colors
, NULL
);
2271 const char *ptr
= cmdline
;
2272 const int i
= atoi(ptr
);
2273 if (i
< LED_CONFIGURABLE_COLOR_COUNT
) {
2274 ptr
= nextArg(cmdline
);
2275 if (!parseColor(i
, ptr
)) {
2276 cliShowParseError();
2279 cliShowArgumentRangeError("index", 0, LED_CONFIGURABLE_COLOR_COUNT
- 1);
2284 static void printModeColor(uint8_t dumpMask
, const ledStripConfig_t
*ledStripConfig
, const ledStripConfig_t
*defaultLedStripConfig
)
2286 const char *format
= "mode_color %u %u %u\r\n";
2287 for (uint32_t i
= 0; i
< LED_MODE_COUNT
; i
++) {
2288 for (uint32_t j
= 0; j
< LED_DIRECTION_COUNT
; j
++) {
2289 int colorIndex
= ledStripConfig
->modeColors
[i
].color
[j
];
2290 bool equalsDefault
= false;
2291 if (defaultLedStripConfig
) {
2292 int colorIndexDefault
= defaultLedStripConfig
->modeColors
[i
].color
[j
];
2293 equalsDefault
= colorIndex
== colorIndexDefault
;
2294 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, i
, j
, colorIndexDefault
);
2296 cliDumpPrintf(dumpMask
, equalsDefault
, format
, i
, j
, colorIndex
);
2300 for (uint32_t j
= 0; j
< LED_SPECIAL_COLOR_COUNT
; j
++) {
2301 const int colorIndex
= ledStripConfig
->specialColors
.color
[j
];
2302 bool equalsDefault
= false;
2303 if (defaultLedStripConfig
) {
2304 const int colorIndexDefault
= defaultLedStripConfig
->specialColors
.color
[j
];
2305 equalsDefault
= colorIndex
== colorIndexDefault
;
2306 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, LED_SPECIAL
, j
, colorIndexDefault
);
2308 cliDumpPrintf(dumpMask
, equalsDefault
, format
, LED_SPECIAL
, j
, colorIndex
);
2311 const int ledStripAuxChannel
= ledStripConfig
->ledstrip_aux_channel
;
2312 bool equalsDefault
= false;
2313 if (defaultLedStripConfig
) {
2314 const int ledStripAuxChannelDefault
= defaultLedStripConfig
->ledstrip_aux_channel
;
2315 equalsDefault
= ledStripAuxChannel
== ledStripAuxChannelDefault
;
2316 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, LED_AUX_CHANNEL
, 0, ledStripAuxChannelDefault
);
2318 cliDumpPrintf(dumpMask
, equalsDefault
, format
, LED_AUX_CHANNEL
, 0, ledStripAuxChannel
);
2321 static void cliModeColor(char *cmdline
)
2323 if (isEmpty(cmdline
)) {
2324 printModeColor(DUMP_MASTER
, ledStripConfig(), NULL
);
2326 enum {MODE
= 0, FUNCTION
, COLOR
, ARGS_COUNT
};
2327 int args
[ARGS_COUNT
];
2330 const char* ptr
= strtok_r(cmdline
, " ", &saveptr
);
2331 while (ptr
&& argNo
< ARGS_COUNT
) {
2332 args
[argNo
++] = atoi(ptr
);
2333 ptr
= strtok_r(NULL
, " ", &saveptr
);
2336 if (ptr
!= NULL
|| argNo
!= ARGS_COUNT
) {
2337 cliShowParseError();
2341 int modeIdx
= args
[MODE
];
2342 int funIdx
= args
[FUNCTION
];
2343 int color
= args
[COLOR
];
2344 if(!setModeColor(modeIdx
, funIdx
, color
)) {
2345 cliShowParseError();
2348 // values are validated
2349 cliPrintf("mode_color %u %u %u\r\n", modeIdx
, funIdx
, color
);
2355 static void printServo(uint8_t dumpMask
, const servoParam_t
*servoParams
, const servoParam_t
*defaultServoParams
)
2357 // print out servo settings
2358 const char *format
= "servo %u %d %d %d %d %d\r\n";
2359 for (uint32_t i
= 0; i
< MAX_SUPPORTED_SERVOS
; i
++) {
2360 const servoParam_t
*servoConf
= &servoParams
[i
];
2361 bool equalsDefault
= false;
2362 if (defaultServoParams
) {
2363 const servoParam_t
*defaultServoConf
= &defaultServoParams
[i
];
2364 equalsDefault
= servoConf
->min
== defaultServoConf
->min
2365 && servoConf
->max
== defaultServoConf
->max
2366 && servoConf
->middle
== defaultServoConf
->middle
2367 && servoConf
->rate
== defaultServoConf
->rate
2368 && servoConf
->forwardFromChannel
== defaultServoConf
->forwardFromChannel
;
2369 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
2371 defaultServoConf
->min
,
2372 defaultServoConf
->max
,
2373 defaultServoConf
->middle
,
2374 defaultServoConf
->rate
,
2375 defaultServoConf
->forwardFromChannel
2378 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
2384 servoConf
->forwardFromChannel
2387 // print servo directions
2388 for (uint32_t i
= 0; i
< MAX_SUPPORTED_SERVOS
; i
++) {
2389 const char *format
= "smix reverse %d %d r\r\n";
2390 const servoParam_t
*servoConf
= &servoParams
[i
];
2391 const servoParam_t
*servoConfDefault
= &defaultServoParams
[i
];
2392 if (defaultServoParams
) {
2393 bool equalsDefault
= servoConf
->reversedSources
== servoConfDefault
->reversedSources
;
2394 for (uint32_t channel
= 0; channel
< INPUT_SOURCE_COUNT
; channel
++) {
2395 equalsDefault
= ~(servoConf
->reversedSources
^ servoConfDefault
->reversedSources
) & (1 << channel
);
2396 if (servoConfDefault
->reversedSources
& (1 << channel
)) {
2397 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, i
, channel
);
2399 if (servoConf
->reversedSources
& (1 << channel
)) {
2400 cliDumpPrintf(dumpMask
, equalsDefault
, format
, i
, channel
);
2404 for (uint32_t channel
= 0; channel
< INPUT_SOURCE_COUNT
; channel
++) {
2405 if (servoConf
->reversedSources
& (1 << channel
)) {
2406 cliDumpPrintf(dumpMask
, true, format
, i
, channel
);
2413 static void cliServo(char *cmdline
)
2415 enum { SERVO_ARGUMENT_COUNT
= 6 };
2416 int16_t arguments
[SERVO_ARGUMENT_COUNT
];
2418 servoParam_t
*servo
;
2423 if (isEmpty(cmdline
)) {
2424 printServo(DUMP_MASTER
, servoParams(0), NULL
);
2426 int validArgumentCount
= 0;
2430 // Command line is integers (possibly negative) separated by spaces, no other characters allowed.
2432 // If command line doesn't fit the format, don't modify the config
2434 if (*ptr
== '-' || (*ptr
>= '0' && *ptr
<= '9')) {
2435 if (validArgumentCount
>= SERVO_ARGUMENT_COUNT
) {
2436 cliShowParseError();
2440 arguments
[validArgumentCount
++] = atoi(ptr
);
2444 } while (*ptr
>= '0' && *ptr
<= '9');
2445 } else if (*ptr
== ' ') {
2448 cliShowParseError();
2453 enum {INDEX
= 0, MIN
, MAX
, MIDDLE
, RATE
, FORWARD
};
2455 i
= arguments
[INDEX
];
2457 // Check we got the right number of args and the servo index is correct (don't validate the other values)
2458 if (validArgumentCount
!= SERVO_ARGUMENT_COUNT
|| i
< 0 || i
>= MAX_SUPPORTED_SERVOS
) {
2459 cliShowParseError();
2463 servo
= servoParamsMutable(i
);
2466 arguments
[MIN
] < PWM_PULSE_MIN
|| arguments
[MIN
] > PWM_PULSE_MAX
||
2467 arguments
[MAX
] < PWM_PULSE_MIN
|| arguments
[MAX
] > PWM_PULSE_MAX
||
2468 arguments
[MIDDLE
] < arguments
[MIN
] || arguments
[MIDDLE
] > arguments
[MAX
] ||
2469 arguments
[MIN
] > arguments
[MAX
] || arguments
[MAX
] < arguments
[MIN
] ||
2470 arguments
[RATE
] < -100 || arguments
[RATE
] > 100 ||
2471 arguments
[FORWARD
] >= MAX_SUPPORTED_RC_CHANNEL_COUNT
2473 cliShowParseError();
2477 servo
->min
= arguments
[MIN
];
2478 servo
->max
= arguments
[MAX
];
2479 servo
->middle
= arguments
[MIDDLE
];
2480 servo
->rate
= arguments
[RATE
];
2481 servo
->forwardFromChannel
= arguments
[FORWARD
];
2487 static void printServoMix(uint8_t dumpMask
, const servoMixer_t
*customServoMixers
, const servoMixer_t
*defaultCustomServoMixers
)
2489 const char *format
= "smix %d %d %d %d %d %d %d %d\r\n";
2490 for (uint32_t i
= 0; i
< MAX_SERVO_RULES
; i
++) {
2491 const servoMixer_t customServoMixer
= customServoMixers
[i
];
2492 if (customServoMixer
.rate
== 0) {
2496 bool equalsDefault
= false;
2497 if (defaultCustomServoMixers
) {
2498 servoMixer_t customServoMixerDefault
= defaultCustomServoMixers
[i
];
2499 equalsDefault
= customServoMixer
.targetChannel
== customServoMixerDefault
.targetChannel
2500 && customServoMixer
.inputSource
== customServoMixerDefault
.inputSource
2501 && customServoMixer
.rate
== customServoMixerDefault
.rate
2502 && customServoMixer
.speed
== customServoMixerDefault
.speed
2503 && customServoMixer
.min
== customServoMixerDefault
.min
2504 && customServoMixer
.max
== customServoMixerDefault
.max
2505 && customServoMixer
.box
== customServoMixerDefault
.box
;
2507 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
2509 customServoMixerDefault
.targetChannel
,
2510 customServoMixerDefault
.inputSource
,
2511 customServoMixerDefault
.rate
,
2512 customServoMixerDefault
.speed
,
2513 customServoMixerDefault
.min
,
2514 customServoMixerDefault
.max
,
2515 customServoMixerDefault
.box
2518 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
2520 customServoMixer
.targetChannel
,
2521 customServoMixer
.inputSource
,
2522 customServoMixer
.rate
,
2523 customServoMixer
.speed
,
2524 customServoMixer
.min
,
2525 customServoMixer
.max
,
2526 customServoMixer
.box
2533 static void cliServoMix(char *cmdline
)
2535 int args
[8], check
= 0;
2536 int len
= strlen(cmdline
);
2539 printServoMix(DUMP_MASTER
, customServoMixers(0), NULL
);
2540 } else if (strncasecmp(cmdline
, "reset", 5) == 0) {
2541 // erase custom mixer
2542 memset(customServoMixers_array(), 0, sizeof(*customServoMixers_array()));
2543 for (uint32_t i
= 0; i
< MAX_SUPPORTED_SERVOS
; i
++) {
2544 servoParamsMutable(i
)->reversedSources
= 0;
2546 } else if (strncasecmp(cmdline
, "load", 4) == 0) {
2547 const char *ptr
= nextArg(cmdline
);
2550 for (uint32_t i
= 0; ; i
++) {
2551 if (mixerNames
[i
] == NULL
) {
2552 cliPrintf("Invalid name\r\n");
2555 if (strncasecmp(ptr
, mixerNames
[i
], len
) == 0) {
2556 servoMixerLoadMix(i
);
2557 cliPrintf("Loaded %s\r\n", mixerNames
[i
]);
2563 } else if (strncasecmp(cmdline
, "reverse", 7) == 0) {
2564 enum {SERVO
= 0, INPUT
, REVERSE
, ARGS_COUNT
};
2565 char *ptr
= strchr(cmdline
, ' ');
2570 for (uint32_t inputSource
= 0; inputSource
< INPUT_SOURCE_COUNT
; inputSource
++)
2571 cliPrintf("\ti%d", inputSource
);
2574 for (uint32_t servoIndex
= 0; servoIndex
< MAX_SUPPORTED_SERVOS
; servoIndex
++) {
2575 cliPrintf("%d", servoIndex
);
2576 for (uint32_t inputSource
= 0; inputSource
< INPUT_SOURCE_COUNT
; inputSource
++)
2577 cliPrintf("\t%s ", (servoParams(servoIndex
)->reversedSources
& (1 << inputSource
)) ? "r" : "n");
2584 ptr
= strtok_r(ptr
, " ", &saveptr
);
2585 while (ptr
!= NULL
&& check
< ARGS_COUNT
- 1) {
2586 args
[check
++] = atoi(ptr
);
2587 ptr
= strtok_r(NULL
, " ", &saveptr
);
2590 if (ptr
== NULL
|| check
!= ARGS_COUNT
- 1) {
2591 cliShowParseError();
2595 if (args
[SERVO
] >= 0 && args
[SERVO
] < MAX_SUPPORTED_SERVOS
2596 && args
[INPUT
] >= 0 && args
[INPUT
] < INPUT_SOURCE_COUNT
2597 && (*ptr
== 'r' || *ptr
== 'n')) {
2599 servoParamsMutable(args
[SERVO
])->reversedSources
|= 1 << args
[INPUT
];
2601 servoParamsMutable(args
[SERVO
])->reversedSources
&= ~(1 << args
[INPUT
]);
2603 cliShowParseError();
2605 cliServoMix("reverse");
2607 enum {RULE
= 0, TARGET
, INPUT
, RATE
, SPEED
, MIN
, MAX
, BOX
, ARGS_COUNT
};
2609 char *ptr
= strtok_r(cmdline
, " ", &saveptr
);
2610 while (ptr
!= NULL
&& check
< ARGS_COUNT
) {
2611 args
[check
++] = atoi(ptr
);
2612 ptr
= strtok_r(NULL
, " ", &saveptr
);
2615 if (ptr
!= NULL
|| check
!= ARGS_COUNT
) {
2616 cliShowParseError();
2620 int32_t i
= args
[RULE
];
2621 if (i
>= 0 && i
< MAX_SERVO_RULES
&&
2622 args
[TARGET
] >= 0 && args
[TARGET
] < MAX_SUPPORTED_SERVOS
&&
2623 args
[INPUT
] >= 0 && args
[INPUT
] < INPUT_SOURCE_COUNT
&&
2624 args
[RATE
] >= -100 && args
[RATE
] <= 100 &&
2625 args
[SPEED
] >= 0 && args
[SPEED
] <= MAX_SERVO_SPEED
&&
2626 args
[MIN
] >= 0 && args
[MIN
] <= 100 &&
2627 args
[MAX
] >= 0 && args
[MAX
] <= 100 && args
[MIN
] < args
[MAX
] &&
2628 args
[BOX
] >= 0 && args
[BOX
] <= MAX_SERVO_BOXES
) {
2629 customServoMixersMutable(i
)->targetChannel
= args
[TARGET
];
2630 customServoMixersMutable(i
)->inputSource
= args
[INPUT
];
2631 customServoMixersMutable(i
)->rate
= args
[RATE
];
2632 customServoMixersMutable(i
)->speed
= args
[SPEED
];
2633 customServoMixersMutable(i
)->min
= args
[MIN
];
2634 customServoMixersMutable(i
)->max
= args
[MAX
];
2635 customServoMixersMutable(i
)->box
= args
[BOX
];
2638 cliShowParseError();
2646 static void cliWriteBytes(const uint8_t *buffer
, int count
)
2655 static void cliSdInfo(char *cmdline
)
2659 cliPrint("SD card: ");
2661 if (!sdcard_isInserted()) {
2662 cliPrint("None inserted\r\n");
2666 if (!sdcard_isInitialized()) {
2667 cliPrint("Startup failed\r\n");
2671 const sdcardMetadata_t
*metadata
= sdcard_getMetadata();
2673 cliPrintf("Manufacturer 0x%x, %ukB, %02d/%04d, v%d.%d, '",
2674 metadata
->manufacturerID
,
2675 metadata
->numBlocks
/ 2, /* One block is half a kB */
2676 metadata
->productionMonth
,
2677 metadata
->productionYear
,
2678 metadata
->productRevisionMajor
,
2679 metadata
->productRevisionMinor
2682 cliWriteBytes((uint8_t*)metadata
->productName
, sizeof(metadata
->productName
));
2684 cliPrint("'\r\n" "Filesystem: ");
2686 switch (afatfs_getFilesystemState()) {
2687 case AFATFS_FILESYSTEM_STATE_READY
:
2690 case AFATFS_FILESYSTEM_STATE_INITIALIZATION
:
2691 cliPrint("Initializing");
2693 case AFATFS_FILESYSTEM_STATE_UNKNOWN
:
2694 case AFATFS_FILESYSTEM_STATE_FATAL
:
2697 switch (afatfs_getLastError()) {
2698 case AFATFS_ERROR_BAD_MBR
:
2699 cliPrint(" - no FAT MBR partitions");
2701 case AFATFS_ERROR_BAD_FILESYSTEM_HEADER
:
2702 cliPrint(" - bad FAT header");
2704 case AFATFS_ERROR_GENERIC
:
2705 case AFATFS_ERROR_NONE
:
2706 ; // Nothing more detailed to print
2718 static void cliFlashInfo(char *cmdline
)
2720 const flashGeometry_t
*layout
= flashfsGetGeometry();
2724 cliPrintf("Flash sectors=%u, sectorSize=%u, pagesPerSector=%u, pageSize=%u, totalSize=%u, usedSize=%u\r\n",
2725 layout
->sectors
, layout
->sectorSize
, layout
->pagesPerSector
, layout
->pageSize
, layout
->totalSize
, flashfsGetOffset());
2729 static void cliFlashErase(char *cmdline
)
2735 cliPrintf("Erasing, please wait ... \r\n");
2737 cliPrintf("Erasing,\r\n");
2740 bufWriterFlush(cliWriter
);
2741 flashfsEraseCompletely();
2743 while (!flashfsIsReady()) {
2751 bufWriterFlush(cliWriter
);
2755 beeper(BEEPER_BLACKBOX_ERASE
);
2756 cliPrintf("\r\nDone.\r\n");
2759 #ifdef USE_FLASH_TOOLS
2761 static void cliFlashWrite(char *cmdline
)
2763 const uint32_t address
= atoi(cmdline
);
2764 const char *text
= strchr(cmdline
, ' ');
2767 cliShowParseError();
2769 flashfsSeekAbs(address
);
2770 flashfsWrite((uint8_t*)text
, strlen(text
), true);
2773 cliPrintf("Wrote %u bytes at %u.\r\n", strlen(text
), address
);
2777 static void cliFlashRead(char *cmdline
)
2779 uint32_t address
= atoi(cmdline
);
2781 const char *nextArg
= strchr(cmdline
, ' ');
2784 cliShowParseError();
2786 uint32_t length
= atoi(nextArg
);
2788 cliPrintf("Reading %u bytes at %u:\r\n", length
, address
);
2791 while (length
> 0) {
2792 int bytesRead
= flashfsReadAbs(address
, buffer
, length
< sizeof(buffer
) ? length
: sizeof(buffer
));
2794 for (int i
= 0; i
< bytesRead
; i
++) {
2795 cliWrite(buffer
[i
]);
2798 length
-= bytesRead
;
2799 address
+= bytesRead
;
2801 if (bytesRead
== 0) {
2802 //Assume we reached the end of the volume or something fatal happened
2814 static void printVtx(uint8_t dumpMask
, const vtxConfig_t
*vtxConfig
, const vtxConfig_t
*vtxConfigDefault
)
2816 // print out vtx channel settings
2817 const char *format
= "vtx %u %u %u %u %u %u\r\n";
2818 bool equalsDefault
= false;
2819 for (uint32_t i
= 0; i
< MAX_CHANNEL_ACTIVATION_CONDITION_COUNT
; i
++) {
2820 const vtxChannelActivationCondition_t
*cac
= &vtxConfig
->vtxChannelActivationConditions
[i
];
2821 if (vtxConfigDefault
) {
2822 const vtxChannelActivationCondition_t
*cacDefault
= &vtxConfigDefault
->vtxChannelActivationConditions
[i
];
2823 equalsDefault
= cac
->auxChannelIndex
== cacDefault
->auxChannelIndex
2824 && cac
->band
== cacDefault
->band
2825 && cac
->channel
== cacDefault
->channel
2826 && cac
->range
.startStep
== cacDefault
->range
.startStep
2827 && cac
->range
.endStep
== cacDefault
->range
.endStep
;
2828 cliDefaultPrintf(dumpMask
, equalsDefault
, format
,
2830 cacDefault
->auxChannelIndex
,
2832 cacDefault
->channel
,
2833 MODE_STEP_TO_CHANNEL_VALUE(cacDefault
->range
.startStep
),
2834 MODE_STEP_TO_CHANNEL_VALUE(cacDefault
->range
.endStep
)
2837 cliDumpPrintf(dumpMask
, equalsDefault
, format
,
2839 cac
->auxChannelIndex
,
2842 MODE_STEP_TO_CHANNEL_VALUE(cac
->range
.startStep
),
2843 MODE_STEP_TO_CHANNEL_VALUE(cac
->range
.endStep
)
2848 // FIXME remove these and use the VTX API
2849 #define VTX_BAND_MIN 1
2850 #define VTX_BAND_MAX 5
2851 #define VTX_CHANNEL_MIN 1
2852 #define VTX_CHANNEL_MAX 8
2854 static void cliVtx(char *cmdline
)
2859 if (isEmpty(cmdline
)) {
2860 printVtx(DUMP_MASTER
, vtxConfig(), NULL
);
2864 if (i
< MAX_CHANNEL_ACTIVATION_CONDITION_COUNT
) {
2865 vtxChannelActivationCondition_t
*cac
= &vtxConfigMutable()->vtxChannelActivationConditions
[i
];
2866 uint8_t validArgumentCount
= 0;
2870 if (val
>= 0 && val
< MAX_AUX_CHANNEL_COUNT
) {
2871 cac
->auxChannelIndex
= val
;
2872 validArgumentCount
++;
2878 // FIXME Use VTX API to get min/max
2879 if (val
>= VTX_BAND_MIN
&& val
<= VTX_BAND_MAX
) {
2881 validArgumentCount
++;
2887 // FIXME Use VTX API to get min/max
2888 if (val
>= VTX_CHANNEL_MIN
&& val
<= VTX_CHANNEL_MAX
) {
2890 validArgumentCount
++;
2893 ptr
= processChannelRangeArgs(ptr
, &cac
->range
, &validArgumentCount
);
2895 if (validArgumentCount
!= 5) {
2896 memset(cac
, 0, sizeof(vtxChannelActivationCondition_t
));
2899 cliShowArgumentRangeError("index", 0, MAX_CHANNEL_ACTIVATION_CONDITION_COUNT
- 1);
2904 #endif // VTX_CONTROL
2906 static void printName(uint8_t dumpMask
, const systemConfig_t
*systemConfig
)
2908 const bool equalsDefault
= strlen(systemConfig
->name
) == 0;
2909 cliDumpPrintf(dumpMask
, equalsDefault
, "name %s\r\n", equalsDefault
? emptyName
: systemConfig
->name
);
2912 static void cliName(char *cmdline
)
2914 const uint32_t len
= strlen(cmdline
);
2916 memset(systemConfigMutable()->name
, 0, ARRAYLEN(systemConfig()->name
));
2917 if (strncmp(cmdline
, emptyName
, len
)) {
2918 strncpy(systemConfigMutable()->name
, cmdline
, MIN(len
, MAX_NAME_LENGTH
));
2921 printName(DUMP_MASTER
, systemConfig());
2924 static void printFeature(uint8_t dumpMask
, const featureConfig_t
*featureConfig
, const featureConfig_t
*featureConfigDefault
)
2926 const uint32_t mask
= featureConfig
->enabledFeatures
;
2927 const uint32_t defaultMask
= featureConfigDefault
->enabledFeatures
;
2928 for (uint32_t i
= 0; featureNames
[i
]; i
++) { // disable all feature first
2929 const char *format
= "feature -%s\r\n";
2930 cliDefaultPrintf(dumpMask
, (defaultMask
| ~mask
) & (1 << i
), format
, featureNames
[i
]);
2931 cliDumpPrintf(dumpMask
, (~defaultMask
| mask
) & (1 << i
), format
, featureNames
[i
]);
2933 for (uint32_t i
= 0; featureNames
[i
]; i
++) { // reenable what we want.
2934 const char *format
= "feature %s\r\n";
2935 if (defaultMask
& (1 << i
)) {
2936 cliDefaultPrintf(dumpMask
, (~defaultMask
| mask
) & (1 << i
), format
, featureNames
[i
]);
2938 if (mask
& (1 << i
)) {
2939 cliDumpPrintf(dumpMask
, (defaultMask
| ~mask
) & (1 << i
), format
, featureNames
[i
]);
2944 static void cliFeature(char *cmdline
)
2946 uint32_t len
= strlen(cmdline
);
2947 uint32_t mask
= featureMask();
2950 cliPrint("Enabled: ");
2951 for (uint32_t i
= 0; ; i
++) {
2952 if (featureNames
[i
] == NULL
)
2954 if (mask
& (1 << i
))
2955 cliPrintf("%s ", featureNames
[i
]);
2958 } else if (strncasecmp(cmdline
, "list", len
) == 0) {
2959 cliPrint("Available:");
2960 for (uint32_t i
= 0; ; i
++) {
2961 if (featureNames
[i
] == NULL
)
2963 cliPrintf(" %s", featureNames
[i
]);
2968 bool remove
= false;
2969 if (cmdline
[0] == '-') {
2972 cmdline
++; // skip over -
2976 for (uint32_t i
= 0; ; i
++) {
2977 if (featureNames
[i
] == NULL
) {
2978 cliPrint("Invalid name\r\n");
2982 if (strncasecmp(cmdline
, featureNames
[i
], len
) == 0) {
2986 if (mask
& FEATURE_GPS
) {
2987 cliPrint("unavailable\r\n");
2992 if (mask
& FEATURE_SONAR
) {
2993 cliPrint("unavailable\r\n");
2999 cliPrint("Disabled");
3002 cliPrint("Enabled");
3004 cliPrintf(" %s\r\n", featureNames
[i
]);
3012 static void printBeeper(uint8_t dumpMask
, const beeperConfig_t
*beeperConfig
, const beeperConfig_t
*beeperConfigDefault
)
3014 const uint8_t beeperCount
= beeperTableEntryCount();
3015 const uint32_t mask
= beeperConfig
->beeper_off_flags
;
3016 const uint32_t defaultMask
= beeperConfigDefault
->beeper_off_flags
;
3017 for (int32_t i
= 0; i
< beeperCount
- 2; i
++) {
3018 const char *formatOff
= "beeper -%s\r\n";
3019 const char *formatOn
= "beeper %s\r\n";
3020 cliDefaultPrintf(dumpMask
, ~(mask
^ defaultMask
) & (1 << i
), mask
& (1 << i
) ? formatOn
: formatOff
, beeperNameForTableIndex(i
));
3021 cliDumpPrintf(dumpMask
, ~(mask
^ defaultMask
) & (1 << i
), mask
& (1 << i
) ? formatOff
: formatOn
, beeperNameForTableIndex(i
));
3025 static void cliBeeper(char *cmdline
)
3027 uint32_t len
= strlen(cmdline
);
3028 uint8_t beeperCount
= beeperTableEntryCount();
3029 uint32_t mask
= getBeeperOffMask();
3032 cliPrintf("Disabled:");
3033 for (int32_t i
= 0; ; i
++) {
3034 if (i
== beeperCount
- 2){
3039 if (mask
& (1 << i
))
3040 cliPrintf(" %s", beeperNameForTableIndex(i
));
3043 } else if (strncasecmp(cmdline
, "list", len
) == 0) {
3044 cliPrint("Available:");
3045 for (uint32_t i
= 0; i
< beeperCount
; i
++)
3046 cliPrintf(" %s", beeperNameForTableIndex(i
));
3050 bool remove
= false;
3051 if (cmdline
[0] == '-') {
3052 remove
= true; // this is for beeper OFF condition
3057 for (uint32_t i
= 0; ; i
++) {
3058 if (i
== beeperCount
) {
3059 cliPrint("Invalid name\r\n");
3062 if (strncasecmp(cmdline
, beeperNameForTableIndex(i
), len
) == 0) {
3063 if (remove
) { // beeper off
3064 if (i
== BEEPER_ALL
-1)
3065 beeperOffSetAll(beeperCount
-2);
3067 if (i
== BEEPER_PREFERENCE
-1)
3068 setBeeperOffMask(getPreferredBeeperOffMask());
3073 cliPrint("Disabled");
3076 if (i
== BEEPER_ALL
-1)
3077 beeperOffClearAll();
3079 if (i
== BEEPER_PREFERENCE
-1)
3080 setPreferredBeeperOffMask(getBeeperOffMask());
3083 beeperOffClear(mask
);
3085 cliPrint("Enabled");
3087 cliPrintf(" %s\r\n", beeperNameForTableIndex(i
));
3095 static void printMap(uint8_t dumpMask
, const rxConfig_t
*rxConfig
, const rxConfig_t
*defaultRxConfig
)
3097 bool equalsDefault
= true;
3099 char bufDefault
[16];
3101 for (i
= 0; i
< MAX_MAPPABLE_RX_INPUTS
; i
++) {
3102 buf
[rxConfig
->rcmap
[i
]] = rcChannelLetters
[i
];
3103 if (defaultRxConfig
) {
3104 bufDefault
[defaultRxConfig
->rcmap
[i
]] = rcChannelLetters
[i
];
3105 equalsDefault
= equalsDefault
&& (rxConfig
->rcmap
[i
] == defaultRxConfig
->rcmap
[i
]);
3110 const char *formatMap
= "map %s\r\n";
3111 cliDefaultPrintf(dumpMask
, equalsDefault
, formatMap
, bufDefault
);
3112 cliDumpPrintf(dumpMask
, equalsDefault
, formatMap
, buf
);
3115 static void cliMap(char *cmdline
)
3120 len
= strlen(cmdline
);
3124 for (uint32_t i
= 0; i
< 8; i
++)
3125 cmdline
[i
] = toupper((unsigned char)cmdline
[i
]);
3126 for (uint32_t i
= 0; i
< 8; i
++) {
3127 if (strchr(rcChannelLetters
, cmdline
[i
]) && !strchr(cmdline
+ i
+ 1, cmdline
[i
]))
3129 cliShowParseError();
3132 parseRcChannels(cmdline
, rxConfigMutable());
3136 for (i
= 0; i
< 8; i
++)
3137 out
[rxConfig()->rcmap
[i
]] = rcChannelLetters
[i
];
3139 cliPrintf("%s\r\n", out
);
3142 static char *checkCommand(char *cmdLine
, const char *command
)
3144 if(!strncasecmp(cmdLine
, command
, strlen(command
)) // command names match
3145 && (isspace((unsigned)cmdLine
[strlen(command
)]) || cmdLine
[strlen(command
)] == 0)) {
3146 return cmdLine
+ strlen(command
) + 1;
3152 static void cliRebootEx(bool bootLoader
)
3154 cliPrint("\r\nRebooting");
3155 bufWriterFlush(cliWriter
);
3156 waitForSerialPortToFinishTransmitting(cliPort
);
3159 systemResetToBootloader();
3165 static void cliReboot(void)
3170 static void cliBootloader(char *cmdLine
)
3174 cliPrintHashLine("restarting in bootloader mode");
3178 static void cliExit(char *cmdline
)
3182 cliPrintHashLine("leaving CLI mode, unsaved changes lost");
3183 bufWriterFlush(cliWriter
);
3188 // incase a motor was left running during motortest, clear it here
3189 mixerResetDisarmedMotors();
3196 static void cliGpsPassthrough(char *cmdline
)
3200 gpsEnablePassthrough(cliPort
);
3204 #if defined(USE_ESCSERIAL) || defined(USE_DSHOT)
3207 #define ALL_ESCS 255
3210 static int parseEscNumber(char *pch
, bool allowAllEscs
) {
3211 int escNumber
= atoi(pch
);
3212 if ((escNumber
>= 0) && (escNumber
< getMotorCount())) {
3213 printf("Programming on ESC %d.\r\n", escNumber
);
3214 } else if (allowAllEscs
&& escNumber
== ALL_ESCS
) {
3215 printf("Programming on all ESCs.\r\n");
3217 printf("Invalid ESC number, range: 0 to %d.\r\n", getMotorCount() - 1);
3227 static void cliDshotProg(char *cmdline
)
3229 if (isEmpty(cmdline
) || motorConfig()->dev
.motorPwmProtocol
< PWM_TYPE_DSHOT150
) {
3230 cliShowParseError();
3236 char *pch
= strtok_r(cmdline
, " ", &saveptr
);
3239 while (pch
!= NULL
) {
3242 escNumber
= parseEscNumber(pch
, true);
3243 if (escNumber
== -1) {
3249 motorControlEnable
= false;
3251 int command
= atoi(pch
);
3252 if (command
>= 0 && command
< DSHOT_MIN_THROTTLE
) {
3253 if (escNumber
== ALL_ESCS
) {
3254 for (unsigned i
= 0; i
< getMotorCount(); i
++) {
3255 pwmWriteDshotCommand(i
, command
);
3258 pwmWriteDshotCommand(escNumber
, command
);
3262 delay(10); // wait for sound output to finish
3265 printf("Command %d written.\r\n", command
);
3267 printf("Invalid command, range 1 to %d.\r\n", DSHOT_MIN_THROTTLE
- 1);
3274 pch
= strtok_r(NULL
, " ", &saveptr
);
3277 motorControlEnable
= true;
3281 #ifdef USE_ESCSERIAL
3282 static void cliEscPassthrough(char *cmdline
)
3284 if (isEmpty(cmdline
)) {
3285 cliShowParseError();
3291 char *pch
= strtok_r(cmdline
, " ", &saveptr
);
3295 while (pch
!= NULL
) {
3298 if(strncasecmp(pch
, "sk", strlen(pch
)) == 0) {
3299 mode
= PROTOCOL_SIMONK
;
3300 } else if(strncasecmp(pch
, "bl", strlen(pch
)) == 0) {
3301 mode
= PROTOCOL_BLHELI
;
3302 } else if(strncasecmp(pch
, "ki", strlen(pch
)) == 0) {
3303 mode
= PROTOCOL_KISS
;
3304 } else if(strncasecmp(pch
, "cc", strlen(pch
)) == 0) {
3305 mode
= PROTOCOL_KISSALL
;
3307 cliShowParseError();
3313 escNumber
= parseEscNumber(pch
, mode
== PROTOCOL_KISS
);
3314 if (escNumber
== -1) {
3320 cliShowParseError();
3328 pch
= strtok_r(NULL
, " ", &saveptr
);
3331 escEnablePassthrough(cliPort
, escNumber
, mode
);
3335 #ifndef USE_QUAD_MIXER_ONLY
3336 static void cliMixer(char *cmdline
)
3340 len
= strlen(cmdline
);
3343 cliPrintf("Mixer: %s\r\n", mixerNames
[mixerConfig()->mixerMode
- 1]);
3345 } else if (strncasecmp(cmdline
, "list", len
) == 0) {
3346 cliPrint("Available:");
3347 for (uint32_t i
= 0; ; i
++) {
3348 if (mixerNames
[i
] == NULL
)
3350 cliPrintf(" %s", mixerNames
[i
]);
3356 for (uint32_t i
= 0; ; i
++) {
3357 if (mixerNames
[i
] == NULL
) {
3358 cliPrint("Invalid name\r\n");
3361 if (strncasecmp(cmdline
, mixerNames
[i
], len
) == 0) {
3362 mixerConfigMutable()->mixerMode
= i
+ 1;
3371 static void cliMotor(char *cmdline
)
3373 int motor_index
= 0;
3374 int motor_value
= 0;
3379 if (isEmpty(cmdline
)) {
3380 cliShowParseError();
3384 pch
= strtok_r(cmdline
, " ", &saveptr
);
3385 while (pch
!= NULL
) {
3388 motor_index
= atoi(pch
);
3391 motor_value
= atoi(pch
);
3395 pch
= strtok_r(NULL
, " ", &saveptr
);
3398 if (motor_index
< 0 || motor_index
>= MAX_SUPPORTED_MOTORS
) {
3399 cliShowArgumentRangeError("index", 0, MAX_SUPPORTED_MOTORS
- 1);
3404 if (motor_value
< PWM_RANGE_MIN
|| motor_value
> PWM_RANGE_MAX
) {
3405 cliShowArgumentRangeError("value", 1000, 2000);
3407 motor_disarmed
[motor_index
] = convertExternalToMotor(motor_value
);
3409 cliPrintf("motor %d: %d\r\n", motor_index
, convertMotorToExternal(motor_disarmed
[motor_index
]));
3416 static void cliPlaySound(char *cmdline
)
3420 static int lastSoundIdx
= -1;
3422 if (isEmpty(cmdline
)) {
3423 i
= lastSoundIdx
+ 1; //next sound index
3424 if ((name
=beeperNameForTableIndex(i
)) == NULL
) {
3425 while (true) { //no name for index; try next one
3426 if (++i
>= beeperTableEntryCount())
3427 i
= 0; //if end then wrap around to first entry
3428 if ((name
=beeperNameForTableIndex(i
)) != NULL
)
3429 break; //if name OK then play sound below
3430 if (i
== lastSoundIdx
+ 1) { //prevent infinite loop
3431 cliPrintf("Error playing sound\r\n");
3436 } else { //index value was given
3438 if ((name
=beeperNameForTableIndex(i
)) == NULL
) {
3439 cliPrintf("No sound for index %d\r\n", i
);
3445 cliPrintf("Playing sound %d: %s\r\n", i
, name
);
3446 beeper(beeperModeForTableIndex(i
));
3450 static void cliProfile(char *cmdline
)
3452 if (isEmpty(cmdline
)) {
3453 cliPrintf("profile %d\r\n", getCurrentPidProfileIndex());
3456 const int i
= atoi(cmdline
);
3457 if (i
>= 0 && i
< MAX_PROFILE_COUNT
) {
3458 systemConfigMutable()->pidProfileIndex
= i
;
3464 static void cliRateProfile(char *cmdline
)
3466 if (isEmpty(cmdline
)) {
3467 cliPrintf("rateprofile %d\r\n", getCurrentControlRateProfileIndex());
3470 const int i
= atoi(cmdline
);
3471 if (i
>= 0 && i
< CONTROL_RATE_PROFILE_COUNT
) {
3472 changeControlRateProfile(i
);
3478 static void cliDumpPidProfile(uint8_t pidProfileIndex
, uint8_t dumpMask
)
3480 if (pidProfileIndex
>= MAX_PROFILE_COUNT
) {
3484 changePidProfile(pidProfileIndex
);
3485 cliPrintHashLine("profile");
3488 dumpAllValues(PROFILE_VALUE
, dumpMask
);
3491 static void cliDumpRateProfile(uint8_t rateProfileIndex
, uint8_t dumpMask
)
3493 if (rateProfileIndex
>= CONTROL_RATE_PROFILE_COUNT
) {
3497 changeControlRateProfile(rateProfileIndex
);
3498 cliPrintHashLine("rateprofile");
3501 dumpAllValues(PROFILE_RATE_VALUE
, dumpMask
);
3504 static void cliSave(char *cmdline
)
3508 cliPrintHashLine("saving");
3513 static void cliDefaults(char *cmdline
)
3517 cliPrintHashLine("resetting to defaults");
3522 static void cliGet(char *cmdline
)
3524 const clivalue_t
*val
;
3525 int matchedCommands
= 0;
3527 for (uint32_t i
= 0; i
< ARRAYLEN(valueTable
); i
++) {
3528 if (strstr(valueTable
[i
].name
, cmdline
)) {
3529 val
= &valueTable
[i
];
3530 cliPrintf("%s = ", valueTable
[i
].name
);
3531 cliPrintVar(val
, 0);
3533 cliPrintVarRange(val
);
3541 if (matchedCommands
) {
3545 cliPrint("Invalid name\r\n");
3548 static void cliSet(char *cmdline
)
3551 const clivalue_t
*val
;
3554 len
= strlen(cmdline
);
3556 if (len
== 0 || (len
== 1 && cmdline
[0] == '*')) {
3557 cliPrint("Current settings: \r\n");
3558 for (uint32_t i
= 0; i
< ARRAYLEN(valueTable
); i
++) {
3559 val
= &valueTable
[i
];
3560 cliPrintf("%s = ", valueTable
[i
].name
);
3561 cliPrintVar(val
, len
); // when len is 1 (when * is passed as argument), it will print min/max values as well, for gui
3564 } else if ((eqptr
= strstr(cmdline
, "=")) != NULL
) {
3567 char *lastNonSpaceCharacter
= eqptr
;
3568 while (*(lastNonSpaceCharacter
- 1) == ' ') {
3569 lastNonSpaceCharacter
--;
3571 uint8_t variableNameLength
= lastNonSpaceCharacter
- cmdline
;
3573 // skip the '=' and any ' ' characters
3575 while (*(eqptr
) == ' ') {
3579 for (uint32_t i
= 0; i
< ARRAYLEN(valueTable
); i
++) {
3580 val
= &valueTable
[i
];
3581 // ensure exact match when setting to prevent setting variables with shorter names
3582 if (strncasecmp(cmdline
, valueTable
[i
].name
, strlen(valueTable
[i
].name
)) == 0 && variableNameLength
== strlen(valueTable
[i
].name
)) {
3584 bool changeValue
= false;
3585 cliVar_t value
= { .uint16
= 0 };
3586 switch (valueTable
[i
].type
& VALUE_MODE_MASK
) {
3588 value
.uint16
= atoi(eqptr
);
3590 if (value
.uint16
>= valueTable
[i
].config
.minmax
.min
&& value
.uint16
<= valueTable
[i
].config
.minmax
.max
) {
3596 const lookupTableEntry_t
*tableEntry
= &lookupTables
[valueTable
[i
].config
.lookup
.tableIndex
];
3597 bool matched
= false;
3598 for (uint32_t tableValueIndex
= 0; tableValueIndex
< tableEntry
->valueCount
&& !matched
; tableValueIndex
++) {
3599 matched
= strcasecmp(tableEntry
->values
[tableValueIndex
], eqptr
) == 0;
3602 value
.uint16
= tableValueIndex
;
3611 cliSetVar(val
, value
);
3613 cliPrintf("%s set to ", valueTable
[i
].name
);
3614 cliPrintVar(val
, 0);
3616 cliPrint("Invalid value\r\n");
3617 cliPrintVarRange(val
);
3623 cliPrint("Invalid name\r\n");
3625 // no equals, check for matching variables.
3630 static void cliStatus(char *cmdline
)
3634 cliPrintf("System Uptime: %d seconds\r\n", millis() / 1000);
3635 cliPrintf("Voltage: %d * 0.1V (%dS battery - %s)\r\n", getBatteryVoltage(), getBatteryCellCount(), getBatteryStateString());
3637 cliPrintf("CPU Clock=%dMHz", (SystemCoreClock
/ 1000000));
3639 #if defined(USE_SENSOR_NAMES)
3640 const uint32_t detectedSensorsMask
= sensorsMask();
3641 for (uint32_t i
= 0; ; i
++) {
3642 if (sensorTypeNames
[i
] == NULL
) {
3645 const uint32_t mask
= (1 << i
);
3646 if ((detectedSensorsMask
& mask
) && (mask
& SENSOR_NAMES_MASK
)) {
3647 const uint8_t sensorHardwareIndex
= detectedSensors
[i
];
3648 const char *sensorHardware
= sensorHardwareNames
[i
][sensorHardwareIndex
];
3649 cliPrintf(", %s=%s", sensorTypeNames
[i
], sensorHardware
);
3650 if (mask
== SENSOR_ACC
&& acc
.dev
.revisionCode
) {
3651 cliPrintf(".%c", acc
.dev
.revisionCode
);
3655 #endif /* USE_SENSOR_NAMES */
3663 const uint16_t i2cErrorCounter
= i2cGetErrorCounter();
3665 const uint16_t i2cErrorCounter
= 0;
3669 cliPrintf("Stack used: %d, ", stackUsedSize());
3671 cliPrintf("Stack size: %d, Stack address: 0x%x\r\n", stackTotalSize(), stackHighMem());
3673 cliPrintf("I2C Errors: %d, config size: %d, max available config: %d\r\n", i2cErrorCounter
, getEEPROMConfigSize(), &__config_end
- &__config_start
);
3675 const int gyroRate
= getTaskDeltaTime(TASK_GYROPID
) == 0 ? 0 : (int)(1000000.0f
/ ((float)getTaskDeltaTime(TASK_GYROPID
)));
3676 const int rxRate
= getTaskDeltaTime(TASK_RX
) == 0 ? 0 : (int)(1000000.0f
/ ((float)getTaskDeltaTime(TASK_RX
)));
3677 const int systemRate
= getTaskDeltaTime(TASK_SYSTEM
) == 0 ? 0 : (int)(1000000.0f
/ ((float)getTaskDeltaTime(TASK_SYSTEM
)));
3678 cliPrintf("CPU:%d%%, cycle time: %d, GYRO rate: %d, RX rate: %d, System rate: %d\r\n",
3679 constrain(averageSystemLoadPercent
, 0, 100), getTaskDeltaTime(TASK_GYROPID
), gyroRate
, rxRate
, systemRate
);
3683 #ifndef SKIP_TASK_STATISTICS
3684 static void cliTasks(char *cmdline
)
3688 int averageLoadSum
= 0;
3691 if (systemConfig()->task_statistics
) {
3692 cliPrintf("Task list rate/hz max/us avg/us maxload avgload total/ms\r\n");
3694 cliPrintf("Task list\r\n");
3697 for (cfTaskId_e taskId
= 0; taskId
< TASK_COUNT
; taskId
++) {
3698 cfTaskInfo_t taskInfo
;
3699 getTaskInfo(taskId
, &taskInfo
);
3700 if (taskInfo
.isEnabled
) {
3702 int subTaskFrequency
;
3703 if (taskId
== TASK_GYROPID
) {
3704 subTaskFrequency
= taskInfo
.latestDeltaTime
== 0 ? 0 : (int)(1000000.0f
/ ((float)taskInfo
.latestDeltaTime
));
3705 taskFrequency
= subTaskFrequency
/ pidConfig()->pid_process_denom
;
3706 if (pidConfig()->pid_process_denom
> 1) {
3707 cliPrintf("%02d - (%15s) ", taskId
, taskInfo
.taskName
);
3709 taskFrequency
= subTaskFrequency
;
3710 cliPrintf("%02d - (%11s/%3s) ", taskId
, taskInfo
.subTaskName
, taskInfo
.taskName
);
3713 taskFrequency
= taskInfo
.latestDeltaTime
== 0 ? 0 : (int)(1000000.0f
/ ((float)taskInfo
.latestDeltaTime
));
3714 cliPrintf("%02d - (%15s) ", taskId
, taskInfo
.taskName
);
3716 const int maxLoad
= taskInfo
.maxExecutionTime
== 0 ? 0 :(taskInfo
.maxExecutionTime
* taskFrequency
+ 5000) / 1000;
3717 const int averageLoad
= taskInfo
.averageExecutionTime
== 0 ? 0 : (taskInfo
.averageExecutionTime
* taskFrequency
+ 5000) / 1000;
3718 if (taskId
!= TASK_SERIAL
) {
3719 maxLoadSum
+= maxLoad
;
3720 averageLoadSum
+= averageLoad
;
3722 if (systemConfig()->task_statistics
) {
3723 cliPrintf("%6d %7d %7d %4d.%1d%% %4d.%1d%% %9d\r\n",
3724 taskFrequency
, taskInfo
.maxExecutionTime
, taskInfo
.averageExecutionTime
,
3725 maxLoad
/10, maxLoad
%10, averageLoad
/10, averageLoad
%10, taskInfo
.totalExecutionTime
/ 1000);
3727 cliPrintf("%6d\r\n", taskFrequency
);
3729 if (taskId
== TASK_GYROPID
&& pidConfig()->pid_process_denom
> 1) {
3730 cliPrintf(" - (%15s) %6d\r\n", taskInfo
.subTaskName
, subTaskFrequency
);
3734 if (systemConfig()->task_statistics
) {
3735 cfCheckFuncInfo_t checkFuncInfo
;
3736 getCheckFuncInfo(&checkFuncInfo
);
3737 cliPrintf("RX Check Function %17d %7d %25d\r\n", checkFuncInfo
.maxExecutionTime
, checkFuncInfo
.averageExecutionTime
, checkFuncInfo
.totalExecutionTime
/ 1000);
3738 cliPrintf("Total (excluding SERIAL) %23d.%1d%% %4d.%1d%%\r\n", maxLoadSum
/10, maxLoadSum
%10, averageLoadSum
/10, averageLoadSum
%10);
3743 static void cliVersion(char *cmdline
)
3747 cliPrintf("# %s / %s %s %s / %s (%s)\r\n",
3757 #if defined(USE_RESOURCE_MGMT)
3759 #define MAX_RESOURCE_INDEX(x) ((x) == 0 ? 1 : (x))
3762 const uint8_t owner
;
3765 const uint8_t maxIndex
;
3766 } cliResourceValue_t
;
3768 const cliResourceValue_t resourceTable
[] = {
3770 { OWNER_BEEPER
, PG_BEEPER_DEV_CONFIG
, offsetof(beeperDevConfig_t
, ioTag
), 0 },
3772 { OWNER_MOTOR
, PG_MOTOR_CONFIG
, offsetof(motorConfig_t
, dev
.ioTags
[0]), MAX_SUPPORTED_MOTORS
},
3774 { OWNER_SERVO
, PG_SERVO_CONFIG
, offsetof(servoConfig_t
, dev
.ioTags
[0]), MAX_SUPPORTED_SERVOS
},
3776 #if defined(USE_PWM) || defined(USE_PPM)
3777 { OWNER_PPMINPUT
, PG_PPM_CONFIG
, offsetof(ppmConfig_t
, ioTag
), 0 },
3778 { OWNER_PWMINPUT
, PG_PWM_CONFIG
, offsetof(pwmConfig_t
, ioTags
[0]), PWM_INPUT_PORT_COUNT
},
3781 { OWNER_SONAR_TRIGGER
, PG_SONAR_CONFIG
, offsetof(sonarConfig_t
, triggerTag
), 0 },
3782 { OWNER_SONAR_ECHO
, PG_SONAR_CONFIG
, offsetof(sonarConfig_t
, echoTag
), 0 },
3785 { OWNER_LED_STRIP
, PG_LED_STRIP_CONFIG
, offsetof(ledStripConfig_t
, ioTag
), 0 },
3787 { OWNER_SERIAL_TX
, PG_SERIAL_PIN_CONFIG
, offsetof(serialPinConfig_t
, ioTagTx
[0]), SERIAL_PORT_MAX_INDEX
},
3788 { OWNER_SERIAL_RX
, PG_SERIAL_PIN_CONFIG
, offsetof(serialPinConfig_t
, ioTagRx
[0]), SERIAL_PORT_MAX_INDEX
},
3791 static ioTag_t
*getIoTag(const cliResourceValue_t value
, uint8_t index
)
3793 const pgRegistry_t
* rec
= pgFind(value
.pgn
);
3794 return CONST_CAST(ioTag_t
*, rec
->address
+ value
.offset
+ index
);
3797 static void printResource(uint8_t dumpMask
)
3799 for (unsigned int i
= 0; i
< ARRAYLEN(resourceTable
); i
++) {
3800 const char* owner
= ownerNames
[resourceTable
[i
].owner
];
3801 const void *currentConfig
;
3802 const void *defaultConfig
;
3803 if (dumpMask
& DO_DIFF
|| dumpMask
& SHOW_DEFAULTS
) {
3804 const cliCurrentAndDefaultConfig_t
*config
= getCurrentAndDefaultConfigs(resourceTable
[i
].pgn
);
3805 currentConfig
= config
->currentConfig
;
3806 defaultConfig
= config
->defaultConfig
;
3807 } else { // Not guaranteed to have initialised default configs in this case
3808 currentConfig
= pgFind(resourceTable
[i
].pgn
)->address
;
3809 defaultConfig
= currentConfig
;
3812 for (int index
= 0; index
< MAX_RESOURCE_INDEX(resourceTable
[i
].maxIndex
); index
++) {
3813 const ioTag_t ioTag
= *((const ioTag_t
*)currentConfig
+ resourceTable
[i
].offset
+ index
);
3814 const ioTag_t ioTagDefault
= *((const ioTag_t
*)defaultConfig
+ resourceTable
[i
].offset
+ index
);
3816 bool equalsDefault
= ioTag
== ioTagDefault
;
3817 const char *format
= "resource %s %d %c%02d\r\n";
3818 const char *formatUnassigned
= "resource %s %d NONE\r\n";
3819 if (!ioTagDefault
) {
3820 cliDefaultPrintf(dumpMask
, equalsDefault
, formatUnassigned
, owner
, RESOURCE_INDEX(index
));
3822 cliDefaultPrintf(dumpMask
, equalsDefault
, format
, owner
, RESOURCE_INDEX(index
), IO_GPIOPortIdxByTag(ioTagDefault
) + 'A', IO_GPIOPinIdxByTag(ioTagDefault
));
3825 if (!(dumpMask
& HIDE_UNUSED
)) {
3826 cliDumpPrintf(dumpMask
, equalsDefault
, formatUnassigned
, owner
, RESOURCE_INDEX(index
));
3829 cliDumpPrintf(dumpMask
, equalsDefault
, format
, owner
, RESOURCE_INDEX(index
), IO_GPIOPortIdxByTag(ioTag
) + 'A', IO_GPIOPinIdxByTag(ioTag
));
3835 static void printResourceOwner(uint8_t owner
, uint8_t index
)
3837 cliPrintf("%s", ownerNames
[resourceTable
[owner
].owner
]);
3839 if (resourceTable
[owner
].maxIndex
> 0) {
3840 cliPrintf(" %d", RESOURCE_INDEX(index
));
3844 static void resourceCheck(uint8_t resourceIndex
, uint8_t index
, ioTag_t newTag
)
3850 const char * format
= "\r\nNOTE: %c%02d already assigned to ";
3851 for (int r
= 0; r
< (int)ARRAYLEN(resourceTable
); r
++) {
3852 for (int i
= 0; i
< MAX_RESOURCE_INDEX(resourceTable
[r
].maxIndex
); i
++) {
3853 ioTag_t
*tag
= getIoTag(resourceTable
[r
], i
);
3854 if (*tag
== newTag
) {
3855 bool cleared
= false;
3856 if (r
== resourceIndex
) {
3864 cliPrintf(format
, DEFIO_TAG_GPIOID(newTag
) + 'A', DEFIO_TAG_PIN(newTag
));
3866 printResourceOwner(r
, i
);
3870 printResourceOwner(r
, i
);
3871 cliPrintf(" disabled");
3880 static void cliResource(char *cmdline
)
3882 int len
= strlen(cmdline
);
3885 printResource(DUMP_MASTER
| HIDE_UNUSED
);
3888 } else if (strncasecmp(cmdline
, "list", len
) == 0) {
3890 cliPrintf("IO\r\n");
3892 cliPrintf("Currently active IO resource assignments:\r\n(reboot to update)\r\n");
3895 for (int i
= 0; i
< DEFIO_IO_USED_COUNT
; i
++) {
3897 owner
= ownerNames
[ioRecs
[i
].owner
];
3899 cliPrintf("%c%02d: %s ", IO_GPIOPortIdx(ioRecs
+ i
) + 'A', IO_GPIOPinIdx(ioRecs
+ i
), owner
);
3900 if (ioRecs
[i
].index
> 0) {
3901 cliPrintf("%d", ioRecs
[i
].index
);
3906 cliPrintf("\r\n\r\n");
3908 cliPrintf("DMA:\r\n");
3910 cliPrintf("Currently active DMA:\r\n");
3913 for (int i
= 0; i
< DMA_MAX_DESCRIPTORS
; i
++) {
3915 owner
= ownerNames
[dmaGetOwner(i
)];
3917 cliPrintf(DMA_OUTPUT_STRING
, i
/ DMA_MOD_VALUE
+ 1, (i
% DMA_MOD_VALUE
) + DMA_MOD_OFFSET
);
3918 uint8_t resourceIndex
= dmaGetResourceIndex(i
);
3919 if (resourceIndex
> 0) {
3920 cliPrintf(" %s %d\r\n", owner
, resourceIndex
);
3922 cliPrintf(" %s\r\n", owner
);
3927 cliPrintf("\r\nUse: 'resource' to see how to change resources.\r\n");
3933 uint8_t resourceIndex
= 0;
3938 pch
= strtok_r(cmdline
, " ", &saveptr
);
3939 for (resourceIndex
= 0; ; resourceIndex
++) {
3940 if (resourceIndex
>= ARRAYLEN(resourceTable
)) {
3941 cliPrint("Invalid\r\n");
3945 if (strncasecmp(pch
, ownerNames
[resourceTable
[resourceIndex
].owner
], len
) == 0) {
3950 pch
= strtok_r(NULL
, " ", &saveptr
);
3953 if (resourceTable
[resourceIndex
].maxIndex
> 0 || index
> 0) {
3954 if (index
<= 0 || index
> MAX_RESOURCE_INDEX(resourceTable
[resourceIndex
].maxIndex
)) {
3955 cliShowArgumentRangeError("index", 1, MAX_RESOURCE_INDEX(resourceTable
[resourceIndex
].maxIndex
));
3960 pch
= strtok_r(NULL
, " ", &saveptr
);
3963 ioTag_t
*tag
= getIoTag(resourceTable
[resourceIndex
], index
);
3966 if (strlen(pch
) > 0) {
3967 if (strcasecmp(pch
, "NONE") == 0) {
3970 cliPrintf("Freed\r\n");
3972 cliPrintf("Resource is freed\r\n");
3976 uint8_t port
= (*pch
) - 'A';
3978 port
= (*pch
) - 'a';
3985 ioRec_t
*rec
= IO_Rec(IOGetByTag(DEFIO_TAG_MAKE(port
, pin
)));
3987 resourceCheck(resourceIndex
, index
, DEFIO_TAG_MAKE(port
, pin
));
3989 cliPrintf(" %c%02d set\r\n", port
+ 'A', pin
);
3991 cliPrintf("\r\nResource is set to %c%02d!\r\n", port
+ 'A', pin
);
3993 *tag
= DEFIO_TAG_MAKE(port
, pin
);
3995 cliShowParseError();
4003 cliShowParseError();
4005 #endif /* USE_RESOURCE_MGMT */
4007 static void backupConfigs(void)
4009 // make copies of configs to do differencing
4011 // currentConfig is the copy
4012 const cliCurrentAndDefaultConfig_t
*cliCurrentAndDefaultConfig
= getCurrentAndDefaultConfigs(pgN(reg
));
4013 if (cliCurrentAndDefaultConfig
->currentConfig
) {
4014 if (pgIsProfile(reg
)) {
4015 //memcpy((uint8_t *)cliCurrentAndDefaultConfig->currentConfig, reg->address, reg->size * MAX_PROFILE_COUNT);
4017 memcpy((uint8_t *)cliCurrentAndDefaultConfig
->currentConfig
, reg
->address
, reg
->size
);
4019 #ifdef SERIAL_CLI_DEBUG
4021 cliPrintf("BACKUP %d SET UP INCORRECTLY\r\n", pgN(reg
));
4027 static void restoreConfigs(void)
4030 // currentConfig is the copy
4031 const cliCurrentAndDefaultConfig_t
*cliCurrentAndDefaultConfig
= getCurrentAndDefaultConfigs(pgN(reg
));
4032 if (cliCurrentAndDefaultConfig
->currentConfig
) {
4033 if (pgIsProfile(reg
)) {
4034 //memcpy(reg->address, (uint8_t *)cliCurrentAndDefaultConfig->currentConfig, reg->size * MAX_PROFILE_COUNT);
4036 memcpy(reg
->address
, (uint8_t *)cliCurrentAndDefaultConfig
->currentConfig
, reg
->size
);
4038 #ifdef SERIAL_CLI_DEBUG
4040 cliPrintf("RESTORE %d SET UP INCORRECTLY\r\n", pgN(reg
));
4046 static void printConfig(char *cmdline
, bool doDiff
)
4048 uint8_t dumpMask
= DUMP_MASTER
;
4050 if ((options
= checkCommand(cmdline
, "master"))) {
4051 dumpMask
= DUMP_MASTER
; // only
4052 } else if ((options
= checkCommand(cmdline
, "profile"))) {
4053 dumpMask
= DUMP_PROFILE
; // only
4054 } else if ((options
= checkCommand(cmdline
, "rates"))) {
4055 dumpMask
= DUMP_RATES
; // only
4056 } else if ((options
= checkCommand(cmdline
, "all"))) {
4057 dumpMask
= DUMP_ALL
; // all profiles and rates
4063 dumpMask
= dumpMask
| DO_DIFF
;
4067 // reset all configs to defaults to do differencing
4070 #if defined(TARGET_CONFIG)
4071 targetConfiguration();
4073 if (checkCommand(options
, "showdefaults")) {
4074 dumpMask
= dumpMask
| SHOW_DEFAULTS
; // add default values as comments for changed values
4077 if ((dumpMask
& DUMP_MASTER
) || (dumpMask
& DUMP_ALL
)) {
4078 cliPrintHashLine("version");
4081 if ((dumpMask
& (DUMP_ALL
| DO_DIFF
)) == (DUMP_ALL
| DO_DIFF
)) {
4082 cliPrintHashLine("reset configuration to default settings");
4083 cliPrint("defaults\r\n");
4086 cliPrintHashLine("name");
4087 printName(dumpMask
, &systemConfigCopy
);
4089 #ifdef USE_RESOURCE_MGMT
4090 cliPrintHashLine("resources");
4091 printResource(dumpMask
);
4094 #ifndef USE_QUAD_MIXER_ONLY
4095 cliPrintHashLine("mixer");
4096 const bool equalsDefault
= mixerConfigCopy
.mixerMode
== mixerConfig()->mixerMode
;
4097 const char *formatMixer
= "mixer %s\r\n";
4098 cliDefaultPrintf(dumpMask
, equalsDefault
, formatMixer
, mixerNames
[mixerConfig()->mixerMode
- 1]);
4099 cliDumpPrintf(dumpMask
, equalsDefault
, formatMixer
, mixerNames
[mixerConfigCopy
.mixerMode
- 1]);
4101 cliDumpPrintf(dumpMask
, customMotorMixer(0)->throttle
== 0.0f
, "\r\nmmix reset\r\n\r\n");
4103 printMotorMix(dumpMask
, customMotorMixerCopy
, customMotorMixer(0));
4106 cliPrintHashLine("servo");
4107 printServo(dumpMask
, servoParamsCopy
, servoParams(0));
4109 cliPrintHashLine("servo mix");
4110 // print custom servo mixer if exists
4111 cliDumpPrintf(dumpMask
, customServoMixers(0)->rate
== 0, "smix reset\r\n\r\n");
4112 printServoMix(dumpMask
, customServoMixersCopy
, customServoMixers(0));
4116 cliPrintHashLine("feature");
4117 printFeature(dumpMask
, &featureConfigCopy
, featureConfig());
4120 cliPrintHashLine("beeper");
4121 printBeeper(dumpMask
, &beeperConfigCopy
, beeperConfig());
4124 cliPrintHashLine("map");
4125 printMap(dumpMask
, &rxConfigCopy
, rxConfig());
4127 cliPrintHashLine("serial");
4128 printSerial(dumpMask
, &serialConfigCopy
, serialConfig());
4131 cliPrintHashLine("led");
4132 printLed(dumpMask
, ledStripConfigCopy
.ledConfigs
, ledStripConfig()->ledConfigs
);
4134 cliPrintHashLine("color");
4135 printColor(dumpMask
, ledStripConfigCopy
.colors
, ledStripConfig()->colors
);
4137 cliPrintHashLine("mode_color");
4138 printModeColor(dumpMask
, &ledStripConfigCopy
, ledStripConfig());
4141 cliPrintHashLine("aux");
4142 printAux(dumpMask
, modeActivationConditionsCopy
, modeActivationConditions(0));
4144 cliPrintHashLine("adjrange");
4145 printAdjustmentRange(dumpMask
, adjustmentRangesCopy
, adjustmentRanges(0));
4147 cliPrintHashLine("rxrange");
4148 printRxRange(dumpMask
, rxChannelRangeConfigsCopy
, rxChannelRangeConfigs(0));
4151 cliPrintHashLine("vtx");
4152 printVtx(dumpMask
, &vtxConfigCopy
, vtxConfig());
4155 cliPrintHashLine("rxfail");
4156 printRxFailsafe(dumpMask
, rxFailsafeChannelConfigsCopy
, rxFailsafeChannelConfigs(0));
4158 cliPrintHashLine("master");
4159 dumpAllValues(MASTER_VALUE
, dumpMask
);
4161 if (dumpMask
& DUMP_ALL
) {
4162 const uint8_t pidProfileIndexSave
= systemConfigCopy
.pidProfileIndex
;
4163 for (uint32_t pidProfileIndex
= 0; pidProfileIndex
< MAX_PROFILE_COUNT
; pidProfileIndex
++) {
4164 cliDumpPidProfile(pidProfileIndex
, dumpMask
);
4166 changePidProfile(pidProfileIndexSave
);
4167 cliPrintHashLine("restore original profile selection");
4170 const uint8_t controlRateProfileIndexSave
= systemConfigCopy
.activeRateProfile
;
4171 for (uint32_t rateIndex
= 0; rateIndex
< CONTROL_RATE_PROFILE_COUNT
; rateIndex
++) {
4172 cliDumpRateProfile(rateIndex
, dumpMask
);
4174 changeControlRateProfile(controlRateProfileIndexSave
);
4175 cliPrintHashLine("restore original rateprofile selection");
4178 cliPrintHashLine("save configuration");
4181 cliDumpPidProfile(systemConfigCopy
.pidProfileIndex
, dumpMask
);
4183 cliDumpRateProfile(systemConfigCopy
.activeRateProfile
, dumpMask
);
4187 if (dumpMask
& DUMP_PROFILE
) {
4188 cliDumpPidProfile(systemConfigCopy
.pidProfileIndex
, dumpMask
);
4191 if (dumpMask
& DUMP_RATES
) {
4192 cliDumpRateProfile(systemConfigCopy
.activeRateProfile
, dumpMask
);
4194 // restore configs from copies
4198 static void cliDump(char *cmdline
)
4200 printConfig(cmdline
, false);
4203 static void cliDiff(char *cmdline
)
4205 printConfig(cmdline
, true);
4211 const char *description
;
4214 void (*func
)(char *cmdline
);
4218 #define CLI_COMMAND_DEF(name, description, args, method) \
4226 #define CLI_COMMAND_DEF(name, description, args, method) \
4233 static void cliHelp(char *cmdline
);
4235 // should be sorted a..z for bsearch()
4236 const clicmd_t cmdTable
[] = {
4237 CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL
, cliAdjustmentRange
),
4238 CLI_COMMAND_DEF("aux", "configure modes", NULL
, cliAux
),
4240 CLI_COMMAND_DEF("beeper", "turn on/off beeper", "list\r\n"
4241 "\t<+|->[name]", cliBeeper
),
4244 CLI_COMMAND_DEF("color", "configure colors", NULL
, cliColor
),
4246 CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL
, cliDefaults
),
4247 CLI_COMMAND_DEF("bl", "reboot into bootloader", NULL
, cliBootloader
),
4248 CLI_COMMAND_DEF("diff", "list configuration changes from default",
4249 "[master|profile|rates|all] {showdefaults}", cliDiff
),
4251 CLI_COMMAND_DEF("dshotprog", "program DShot ESC(s)", "<index> <command>+", cliDshotProg
),
4253 CLI_COMMAND_DEF("dump", "dump configuration",
4254 "[master|profile|rates|all] {showdefaults}", cliDump
),
4255 #ifdef USE_ESCSERIAL
4256 CLI_COMMAND_DEF("escprog", "passthrough esc to serial", "<mode [sk/bl/ki/cc]> <index>", cliEscPassthrough
),
4258 CLI_COMMAND_DEF("exit", NULL
, NULL
, cliExit
),
4259 CLI_COMMAND_DEF("feature", "configure features",
4261 "\t<+|->[name]", cliFeature
),
4263 CLI_COMMAND_DEF("flash_erase", "erase flash chip", NULL
, cliFlashErase
),
4264 CLI_COMMAND_DEF("flash_info", "show flash chip info", NULL
, cliFlashInfo
),
4265 #ifdef USE_FLASH_TOOLS
4266 CLI_COMMAND_DEF("flash_read", NULL
, "<length> <address>", cliFlashRead
),
4267 CLI_COMMAND_DEF("flash_write", NULL
, "<address> <message>", cliFlashWrite
),
4270 CLI_COMMAND_DEF("get", "get variable value", "[name]", cliGet
),
4272 CLI_COMMAND_DEF("gpspassthrough", "passthrough gps to serial", NULL
, cliGpsPassthrough
),
4274 CLI_COMMAND_DEF("help", NULL
, NULL
, cliHelp
),
4276 CLI_COMMAND_DEF("led", "configure leds", NULL
, cliLed
),
4278 CLI_COMMAND_DEF("map", "configure rc channel order", "[<map>]", cliMap
),
4279 #ifndef USE_QUAD_MIXER_ONLY
4280 CLI_COMMAND_DEF("mixer", "configure mixer", "list\r\n\t<name>", cliMixer
),
4282 CLI_COMMAND_DEF("mmix", "custom motor mixer", NULL
, cliMotorMix
),
4284 CLI_COMMAND_DEF("mode_color", "configure mode and special colors", NULL
, cliModeColor
),
4286 CLI_COMMAND_DEF("motor", "get/set motor", "<index> [<value>]", cliMotor
),
4287 CLI_COMMAND_DEF("name", "name of craft", NULL
, cliName
),
4289 CLI_COMMAND_DEF("play_sound", NULL
, "[<index>]", cliPlaySound
),
4291 CLI_COMMAND_DEF("profile", "change profile", "[<index>]", cliProfile
),
4292 CLI_COMMAND_DEF("rateprofile", "change rate profile", "[<index>]", cliRateProfile
),
4293 #if defined(USE_RESOURCE_MGMT)
4294 CLI_COMMAND_DEF("resource", "show/set resources", NULL
, cliResource
),
4296 CLI_COMMAND_DEF("rxfail", "show/set rx failsafe settings", NULL
, cliRxFailsafe
),
4297 CLI_COMMAND_DEF("rxrange", "configure rx channel ranges", NULL
, cliRxRange
),
4298 CLI_COMMAND_DEF("save", "save and reboot", NULL
, cliSave
),
4300 CLI_COMMAND_DEF("sd_info", "sdcard info", NULL
, cliSdInfo
),
4302 CLI_COMMAND_DEF("serial", "configure serial ports", NULL
, cliSerial
),
4303 #ifndef SKIP_SERIAL_PASSTHROUGH
4304 CLI_COMMAND_DEF("serialpassthrough", "passthrough serial data to port", "<id> [baud] [mode] : passthrough to serial", cliSerialPassthrough
),
4307 CLI_COMMAND_DEF("servo", "configure servos", NULL
, cliServo
),
4309 CLI_COMMAND_DEF("set", "change setting", "[<name>=<value>]", cliSet
),
4311 CLI_COMMAND_DEF("smix", "servo mixer", "<rule> <servo> <source> <rate> <speed> <min> <max> <box>\r\n"
4313 "\tload <mixer>\r\n"
4314 "\treverse <servo> <source> r|n", cliServoMix
),
4316 CLI_COMMAND_DEF("status", "show status", NULL
, cliStatus
),
4317 #ifndef SKIP_TASK_STATISTICS
4318 CLI_COMMAND_DEF("tasks", "show task stats", NULL
, cliTasks
),
4320 CLI_COMMAND_DEF("version", "show version", NULL
, cliVersion
),
4322 CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL
, cliVtx
),
4325 static void cliHelp(char *cmdline
)
4329 for (uint32_t i
= 0; i
< ARRAYLEN(cmdTable
); i
++) {
4330 cliPrint(cmdTable
[i
].name
);
4332 if (cmdTable
[i
].description
) {
4333 cliPrintf(" - %s", cmdTable
[i
].description
);
4335 if (cmdTable
[i
].args
) {
4336 cliPrintf("\r\n\t%s", cmdTable
[i
].args
);
4343 void cliProcess(void)
4349 // Be a little bit tricky. Flush the last inputs buffer, if any.
4350 bufWriterFlush(cliWriter
);
4352 while (serialRxBytesWaiting(cliPort
)) {
4353 uint8_t c
= serialRead(cliPort
);
4354 if (c
== '\t' || c
== '?') {
4355 // do tab completion
4356 const clicmd_t
*cmd
, *pstart
= NULL
, *pend
= NULL
;
4357 uint32_t i
= bufferIndex
;
4358 for (cmd
= cmdTable
; cmd
< cmdTable
+ ARRAYLEN(cmdTable
); cmd
++) {
4359 if (bufferIndex
&& (strncasecmp(cliBuffer
, cmd
->name
, bufferIndex
) != 0))
4365 if (pstart
) { /* Buffer matches one or more commands */
4366 for (; ; bufferIndex
++) {
4367 if (pstart
->name
[bufferIndex
] != pend
->name
[bufferIndex
])
4369 if (!pstart
->name
[bufferIndex
] && bufferIndex
< sizeof(cliBuffer
) - 2) {
4370 /* Unambiguous -- append a space */
4371 cliBuffer
[bufferIndex
++] = ' ';
4372 cliBuffer
[bufferIndex
] = '\0';
4375 cliBuffer
[bufferIndex
] = pstart
->name
[bufferIndex
];
4378 if (!bufferIndex
|| pstart
!= pend
) {
4379 /* Print list of ambiguous matches */
4380 cliPrint("\r\033[K");
4381 for (cmd
= pstart
; cmd
<= pend
; cmd
++) {
4382 cliPrint(cmd
->name
);
4386 i
= 0; /* Redraw prompt */
4388 for (; i
< bufferIndex
; i
++)
4389 cliWrite(cliBuffer
[i
]);
4390 } else if (!bufferIndex
&& c
== 4) { // CTRL-D
4393 } else if (c
== 12) { // NewPage / CTRL-L
4395 cliPrint("\033[2J\033[1;1H");
4397 } else if (bufferIndex
&& (c
== '\n' || c
== '\r')) {
4401 // Strip comment starting with # from line
4402 char *p
= cliBuffer
;
4405 bufferIndex
= (uint32_t)(p
- cliBuffer
);
4408 // Strip trailing whitespace
4409 while (bufferIndex
> 0 && cliBuffer
[bufferIndex
- 1] == ' ') {
4413 // Process non-empty lines
4414 if (bufferIndex
> 0) {
4415 cliBuffer
[bufferIndex
] = 0; // null terminate
4417 const clicmd_t
*cmd
;
4419 for (cmd
= cmdTable
; cmd
< cmdTable
+ ARRAYLEN(cmdTable
); cmd
++) {
4420 if ((options
= checkCommand(cliBuffer
, cmd
->name
))) {
4424 if(cmd
< cmdTable
+ ARRAYLEN(cmdTable
))
4427 cliPrint("Unknown command, try 'help'");
4431 memset(cliBuffer
, 0, sizeof(cliBuffer
));
4433 // 'exit' will reset this flag, so we don't need to print prompt again
4438 } else if (c
== 127) {
4441 cliBuffer
[--bufferIndex
] = 0;
4442 cliPrint("\010 \010");
4444 } else if (bufferIndex
< sizeof(cliBuffer
) && c
>= 32 && c
<= 126) {
4445 if (!bufferIndex
&& c
== ' ')
4446 continue; // Ignore leading spaces
4447 cliBuffer
[bufferIndex
++] = c
;
4453 void cliEnter(serialPort_t
*serialPort
)
4456 cliPort
= serialPort
;
4457 setPrintfSerialPort(cliPort
);
4458 cliWriter
= bufWriterInit(cliWriteBuffer
, sizeof(cliWriteBuffer
), (bufWrite_t
)serialWriteBufShim
, serialPort
);
4460 schedulerSetCalulateTaskStatistics(systemConfig()->task_statistics
);
4463 cliPrint("\r\nEntering CLI Mode, type 'exit' to return, or 'help'\r\n");
4465 cliPrint("\r\nCLI\r\n");
4469 ENABLE_ARMING_FLAG(PREVENT_ARMING
);
4472 void cliInit(const serialConfig_t
*serialConfig
)
4474 UNUSED(serialConfig
);
4475 BUILD_BUG_ON(LOOKUP_TABLE_COUNT
!= ARRAYLEN(lookupTables
));