Skip to content

Commit

Permalink
AP_HAL_SITL: deprecate and warn on legacy --uartX option use
Browse files Browse the repository at this point in the history
  • Loading branch information
tpwrules committed Dec 13, 2023
1 parent bb5193c commit d78aa8b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 30 deletions.
20 changes: 10 additions & 10 deletions Tools/completion/zsh/_ap_bin
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ _ap_bin() {
'--gimbal[enable simulated MAVLink gimbal]' \
'--autotest-dir[set directory for additional files]:DIR:' \
'--defaults[set path to defaults file]:PATH:' \
'--uartA[set device string for SERIAL0]:DEVICE:' \
'--uartC[set device string for SERIAL1]:DEVICE:' \
'--uartD[set device string for SERIAL2]:DEVICE:' \
'--uartB[set device string for SERIAL3]:DEVICE:' \
'--uartE[set device string for SERIAL4]:DEVICE:' \
'--uartF[set device string for SERIAL5]:DEVICE:' \
'--uartG[set device string for SERIAL6]:DEVICE:' \
'--uartH[set device string for SERIAL7]:DEVICE:' \
'--uartI[set device string for SERIAL8]:DEVICE:' \
'--uartJ[set device string for SERIAL9]:DEVICE:' \
'--uartA[(deprecated) set device string for SERIAL0]:DEVICE:' \
'--uartC[(deprecated) set device string for SERIAL1]:DEVICE:' \
'--uartD[(deprecated) set device string for SERIAL2]:DEVICE:' \
'--uartB[(deprecated) set device string for SERIAL3]:DEVICE:' \
'--uartE[(deprecated) set device string for SERIAL4]:DEVICE:' \
'--uartF[(deprecated) set device string for SERIAL5]:DEVICE:' \
'--uartG[(deprecated) set device string for SERIAL6]:DEVICE:' \
'--uartH[(deprecated) set device string for SERIAL7]:DEVICE:' \
'--uartI[(deprecated) set device string for SERIAL8]:DEVICE:' \
'--uartJ[(deprecated) set device string for SERIAL9]:DEVICE:' \
'--serial0[set device string for SERIAL0]:DEVICE:' \
'--serial1[set device string for SERIAL1]:DEVICE:' \
'--serial2[set device string for SERIAL2]:DEVICE:' \
Expand Down
71 changes: 51 additions & 20 deletions libraries/AP_HAL_SITL/SITL_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ void SITL_State::_usage(void)
"\t--gimbal enable simulated MAVLink gimbal\n"
"\t--autotest-dir DIR set directory for additional files\n"
"\t--defaults path set path to defaults file\n"
"\t--uartA device set device string for SERIAL0\n"
"\t--uartB device set device string for SERIAL3\n" // ordering captures the historical use of uartB as SERIAL3
"\t--uartC device set device string for SERIAL1\n"
"\t--uartD device set device string for SERIAL2\n"
"\t--uartE device set device string for SERIAL4\n"
"\t--uartF device set device string for SERIAL5\n"
"\t--uartG device set device string for SERIAL6\n"
"\t--uartH device set device string for SERIAL7\n"
"\t--uartI device set device string for SERIAL8\n"
"\t--uartJ device set device string for SERIAL9\n"
"\t--uartA device (deprecated) set device string for SERIAL0\n"
"\t--uartC device (deprecated) set device string for SERIAL1\n" // ordering captures the historical use of uartB as SERIAL3
"\t--uartD device (deprecated) set device string for SERIAL2\n"
"\t--uartB device (deprecated) set device string for SERIAL3\n"
"\t--uartE device (deprecated) set device string for SERIAL4\n"
"\t--uartF device (deprecated) set device string for SERIAL5\n"
"\t--uartG device (deprecated) set device string for SERIAL6\n"
"\t--uartH device (deprecated) set device string for SERIAL7\n"
"\t--uartI device (deprecated) set device string for SERIAL8\n"
"\t--uartJ device (deprecated) set device string for SERIAL9\n"
"\t--serial0 device set device string for SERIAL0\n"
"\t--serial1 device set device string for SERIAL1\n"
"\t--serial2 device set device string for SERIAL2\n"
Expand Down Expand Up @@ -246,6 +246,16 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
CMDLINE_FGVIEW,
CMDLINE_AUTOTESTDIR,
CMDLINE_DEFAULTS,
CMDLINE_UARTA, // must be in A-J order and numbered consecutively
CMDLINE_UARTB,
CMDLINE_UARTC,
CMDLINE_UARTD,
CMDLINE_UARTE,
CMDLINE_UARTF,
CMDLINE_UARTG,
CMDLINE_UARTH,
CMDLINE_UARTI,
CMDLINE_UARTJ,
CMDLINE_SERIAL0, // must be in 0-9 order and numbered consecutively
CMDLINE_SERIAL1,
CMDLINE_SERIAL2,
Expand Down Expand Up @@ -295,16 +305,16 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
{"disable-fgview", false, 0, CMDLINE_FGVIEW},
{"autotest-dir", true, 0, CMDLINE_AUTOTESTDIR},
{"defaults", true, 0, CMDLINE_DEFAULTS},
{"uartA", true, 0, CMDLINE_SERIAL0},
{"uartB", true, 0, CMDLINE_SERIAL3}, // ordering captures the historical use of uartB as SERIAL3
{"uartC", true, 0, CMDLINE_SERIAL1},
{"uartD", true, 0, CMDLINE_SERIAL2},
{"uartE", true, 0, CMDLINE_SERIAL4},
{"uartF", true, 0, CMDLINE_SERIAL5},
{"uartG", true, 0, CMDLINE_SERIAL6},
{"uartH", true, 0, CMDLINE_SERIAL7},
{"uartI", true, 0, CMDLINE_SERIAL8},
{"uartJ", true, 0, CMDLINE_SERIAL9},
{"uartA", true, 0, CMDLINE_UARTA},
{"uartB", true, 0, CMDLINE_UARTB},
{"uartC", true, 0, CMDLINE_UARTC},
{"uartD", true, 0, CMDLINE_UARTD},
{"uartE", true, 0, CMDLINE_UARTE},
{"uartF", true, 0, CMDLINE_UARTF},
{"uartG", true, 0, CMDLINE_UARTG},
{"uartH", true, 0, CMDLINE_UARTH},
{"uartI", true, 0, CMDLINE_UARTI},
{"uartJ", true, 0, CMDLINE_UARTJ},
{"serial0", true, 0, CMDLINE_SERIAL0},
{"serial1", true, 0, CMDLINE_SERIAL1},
{"serial2", true, 0, CMDLINE_SERIAL2},
Expand Down Expand Up @@ -439,6 +449,27 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
case CMDLINE_DEFAULTS:
defaults_path = strdup(gopt.optarg);
break;
case CMDLINE_UARTA:
case CMDLINE_UARTB:
case CMDLINE_UARTC:
case CMDLINE_UARTD:
case CMDLINE_UARTE:
case CMDLINE_UARTF:
case CMDLINE_UARTG:
case CMDLINE_UARTH:
case CMDLINE_UARTI:
case CMDLINE_UARTJ: {
int uart_idx = opt - CMDLINE_UARTA;
// ordering captures the historical use of uartB as SERIAL3
static const uint8_t mapping[] = { 0, 3, 1, 2, 4, 5, 6, 7, 8, 9 };
int serial_idx = mapping[uart_idx];
char uart_letter = (char)(uart_idx)+'A';
printf("WARNING: deprecated option --uart%c will be removed in a "
"future release. Use --serial%d instead.\n",
uart_letter, serial_idx);
_serial_path[serial_idx] = gopt.optarg;
break;
}
case CMDLINE_SERIAL0:
case CMDLINE_SERIAL1:
case CMDLINE_SERIAL2:
Expand Down

0 comments on commit d78aa8b

Please sign in to comment.