Skip to main content

CLI

The Command Line Interface (CLI)​

INAV has a command line interface (CLI) that can be used to change settings and configure the FC.

Access the CLI.​

The CLI can be accessed via the GUI tool or via a terminal emulator connected to the CLI serial port:

  1. Connect your terminal emulator to the CLI serial port (which, by default, is the same as the MSP serial port)
  2. Use the baudrate specified by msp_baudrate (115200 by default).
  3. Send a # character.

To save your settings type in 'save', saving will reboot the flight controller.

To exit the CLI without saving power off the flight controller or type in 'exit'.

To see a list of other commands type in 'help' and press return.

To dump your configuration (including the current profile), use the 'dump' or 'diff' command.

See the other documentation sections for details of the cli commands and settings that are available.

Backup via CLI​

Disconnect main power, connect to cli via USB/FTDI.

dump using cli

profile 0
dump

dump profiles using cli if you use them

profile 1
dump profile
profile 2
dump profile

copy screen output to a file and save it.

Alternatively, use the diff command to dump only those settings that differ from their default values (those that have been changed).

Restore via CLI.​

Use the cli defaults command first.

When restoring from backup it's a good idea to do a dump of the latest defaults so you know what has changed - if you do this each time a firmware release is created you will be able to see the cli changes between firmware versions. If you blindly restore your backup you would not benefit from these new defaults or may even end up with completely wrong settings in case some parameters changed semantics and/or value ranges.

It may be good idea to restore settings using the diff output rather than complete dump. This way you can have more control on what is restored and the risk of mistakenly restoring bad values if the semantics changes is minimised.

To perform the restore simply paste the saved commands in the Configurator CLI tab and then type save.

After restoring it's always a good idea to dump or diff the settings once again and compare the output with previous one to verify if everything is set as it should be.

Flight Controller opereration while connected to the CLI​

While connected to the CLI, all Logical Switches are temporarily disabled (5.1.0 onwards).

CLI Command Reference​

CommandDescription
adjrangeConfigure adjustment ranges
assert
auxConfigure modes
batchStart or end a batch of commands
battery_profileChange battery profile
beeperShow/set beeper (buzzer) Buzzer docs
bind_rxInitiate binding for SRXL2 or CRSF receivers
blackboxConfigure blackbox fields
bootlogShow boot events
colorConfigure colors
defaultsReset to defaults and reboot
dfuDFU mode on reboot
diffList configuration changes from default
dumpDump configuration
exit
featureList or enable or disable
flash_eraseErase flash chip
flash_infoShow flash chip info
flash_read
flash_write
getGet variable value
gpspassthroughPassthrough gps to serial
gvarConfigure global variables
helpDisplays CLI help and command parameters / options
ledConfigure leds
logicConfigure logic conditions
mapConfigure rc channel order
memoryView memory usage
mmixCustom motor mixer
mode_colorConfigure mode and special colors
motorGet/set motor
mscEnter USB Mass storage mode. See USB MSC documentation for usage information.
osd_layoutGet or set the layout of OSD items
pidConfigurable PID controllers
play_sound<index>, or none for next item
profileChange profile
resourceView currently used resources
rxrangeConfigure rx channel ranges
safehomeDefine safe home locations. See the [safehome documentation] for usage information.
saveSave and reboot
sd_infoSdcard info
serialConfigure serial ports. Serial Ports Docs
serialpassthroughPassthrough serial data to port, with <id> <baud> <mode> <options>, where id is the zero based port index, baud is a standard baud rate, mode is rx, tx, or both (rxtx), and options is a short string like 8N1 or 8E2
servoConfigure servos
setChange setting with name=value or blank or * for list
smixCustom servo mixer
statusShow status. Error codes can be looked up Error Codes
tasksShow task stats
temp_sensorList or configure temperature sensor(s). See [temperature sensors documentation] for more information.
timer_output_modeOverride automatic timer / pwm function allocation. [Additional Information]
versionShow version
wpList or configure waypoints. See the [navigation documentation].

Notes:

  • Available commands depend upon hardware specific and debug build options. Not all commands are available in every FC.
  • The above list shows the output available in the CLI help command. This may also show additional information.

serial​

The syntax of the serial command is serial <id> <function_value> <msp-baudrate> <gps-baudrate> <telemetry-baudate> <peripheral-baudrate>.

A shorter form is also supported to enable and disable a single function using serial <id> +n and serial <id> -n, where n is the a serial function identifier. The following values are available:

FunctionBit IdentifierNumeric value
MSP01
GPS12
TELEMETRY_FRSKY24
TELEMETRY_HOTT38
TELEMETRY_LTM416
TELEMETRY_SMARTPORT532
RX_SERIAL664
BLACKBOX7128
TELEMETRY_MAVLINK8256
TELEMETRY_IBUS9512
RCDEVICE101024
VTX_SMARTAUDIO112048
VTX_TRAMP124096
UAV_INTERCONNECT138192
OPTICAL_FLOW1416384
LOG1532768
RANGEFINDER1665536
VTX_FFPV17131072
ESCSERIAL18262144
TELEMETRY_SIM19524288
FRSKY_OSD201048576
DJI_HD_OSD212097152
SERVO_SERIAL224194304
TELEMETRY_SMARTPORT_MASTER238388608
UNUSED2416777216
MSP_DISPLAYPORT2533554432
GIMBAL_SERIAL2667108864
HEADTRACKER_SERIAL27134217728

Thus, to enable MSP and LTM on a port, one would use the function value of 17 (1 < 0)+(1<4), aka 1+16, aka 17.

serial 0 17 57600 57600 57600 57600

but to remove LTM using the +/- shorthand, use the bit Id (4, TELEMETRY_LTM):

serial 0 -4

serial can also be used without any argument to print the current configuration of all the serial ports.

timer_output_mode​

Since INAV 7, the firmware can dynamically allocate servo and motor outputs. This removes the need for bespoke targets for special cases (e.g. MATEKF405 and MATEKF405_SERVOS6).

Syntax​

timer_output_mode [timer [function]]

where:

  • Without parameters, lists the current timers and modes
  • With just a timer lists the mode for that timer
  • With both timer and function, sets the function for that timers

Note:

  • timer identifies the timer index (from 0); thus is one less than the corresponding TIMn definition in a target's target.c.
  • The function is one of AUTO (the default), MOTORS or SERVOS.

Motors are allocated first, hence having a servo before a motor may require use of timer_output_mode.

Example​

The original MATEKF405 target defined a multi-rotor (MR) servo on output S1. The later MATEKF405_SERVOS6 target defined (for MR) S1 as a motor and S6 as a servo. This was more logical, but annoying for anyone who had a legacy MATEKF405 tricopter with the servo on S1.

Solution​

There is now a single MATEKF405 target. The target.c sets the relevant outputs as:

DEF_TIM(TIM3, CH1, PC6,  TIM_USE_OUTPUT_AUTO, 0, 0), // S1
DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 1), // S2 UP(2,1)
DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 1), // S3 UP(2,1)
DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 UP(2,1)
DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_MOTOR | TIM_USE_LED, 0, 0), // S5 UP(1,7)
DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 UP(2,5)
DEF_TIM(TIM4, CH3, PB8, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 D(1,7)!S5 UP(2,6)

Using the "motors first" allocation, the servo would end up on S6, which in the legacy "tricopter servo on S1" case is not desired.

Forcing the S1 output (TIM3) to servo is achieved by:

timer_output_mode 2 SERVOS

with resulting resource output:

C06: SERVO4 OUT
C07: MOTOR1 OUT
C08: MOTOR2 OUT
C09: MOTOR3 OUT

Note that the timer index in the timer_output_mode line is one less than the mnemonic in target.c, timer of 2 for TIM3.

Note that the usual caveat that one should not share a timer with both a motor and a servo still apply.

Flash chip management​

For targets that have a flash data chip, typically used for blackbox logs, the following additional comamnds are provided.

CommandEffect
flash_eraseErases the flash chip
flash_infoDisplays flash chip information (used, free etc.)
flash_read <length> <address>Reads length bytes from address
flash_write <address> <data>Writes data to address

CLI Variable Reference​

TODO: The properly formatted CLI Variables page is in progress.

For now, the CLI variables can be accessed from the firmware dev repo here.