AP_HAL_SITL: deprecate and warn on legacy --uartX option use

This commit is contained in:
Thomas Watson 2023-12-12 11:24:53 -06:00 committed by Andrew Tridgell
parent cc5b095d59
commit 14180b5b93
2 changed files with 61 additions and 30 deletions

View File

@ -21,16 +21,16 @@ _ap_bin() {
'--gimbal[enable simulated MAVLink gimbal]' \ '--gimbal[enable simulated MAVLink gimbal]' \
'--autotest-dir[set directory for additional files]:DIR:' \ '--autotest-dir[set directory for additional files]:DIR:' \
'--defaults[set path to defaults file]:PATH:' \ '--defaults[set path to defaults file]:PATH:' \
'--uartA[set device string for SERIAL0]:DEVICE:' \ '--uartA[(deprecated) set device string for SERIAL0]:DEVICE:' \
'--uartC[set device string for SERIAL1]:DEVICE:' \ '--uartC[(deprecated) set device string for SERIAL1]:DEVICE:' \
'--uartD[set device string for SERIAL2]:DEVICE:' \ '--uartD[(deprecated) set device string for SERIAL2]:DEVICE:' \
'--uartB[set device string for SERIAL3]:DEVICE:' \ '--uartB[(deprecated) set device string for SERIAL3]:DEVICE:' \
'--uartE[set device string for SERIAL4]:DEVICE:' \ '--uartE[(deprecated) set device string for SERIAL4]:DEVICE:' \
'--uartF[set device string for SERIAL5]:DEVICE:' \ '--uartF[(deprecated) set device string for SERIAL5]:DEVICE:' \
'--uartG[set device string for SERIAL6]:DEVICE:' \ '--uartG[(deprecated) set device string for SERIAL6]:DEVICE:' \
'--uartH[set device string for SERIAL7]:DEVICE:' \ '--uartH[(deprecated) set device string for SERIAL7]:DEVICE:' \
'--uartI[set device string for SERIAL8]:DEVICE:' \ '--uartI[(deprecated) set device string for SERIAL8]:DEVICE:' \
'--uartJ[set device string for SERIAL9]:DEVICE:' \ '--uartJ[(deprecated) set device string for SERIAL9]:DEVICE:' \
'--serial0[set device string for SERIAL0]:DEVICE:' \ '--serial0[set device string for SERIAL0]:DEVICE:' \
'--serial1[set device string for SERIAL1]:DEVICE:' \ '--serial1[set device string for SERIAL1]:DEVICE:' \
'--serial2[set device string for SERIAL2]:DEVICE:' \ '--serial2[set device string for SERIAL2]:DEVICE:' \

View File

@ -92,16 +92,16 @@ void SITL_State::_usage(void)
"\t--gimbal enable simulated MAVLink gimbal\n" "\t--gimbal enable simulated MAVLink gimbal\n"
"\t--autotest-dir DIR set directory for additional files\n" "\t--autotest-dir DIR set directory for additional files\n"
"\t--defaults path set path to defaults file\n" "\t--defaults path set path to defaults file\n"
"\t--uartA device set device string for SERIAL0\n" "\t--uartA device (deprecated) 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 (deprecated) set device string for SERIAL1\n" // ordering captures the historical use of uartB as SERIAL3
"\t--uartC device set device string for SERIAL1\n" "\t--uartD device (deprecated) set device string for SERIAL2\n"
"\t--uartD device set device string for SERIAL2\n" "\t--uartB device (deprecated) set device string for SERIAL3\n"
"\t--uartE device set device string for SERIAL4\n" "\t--uartE device (deprecated) set device string for SERIAL4\n"
"\t--uartF device set device string for SERIAL5\n" "\t--uartF device (deprecated) set device string for SERIAL5\n"
"\t--uartG device set device string for SERIAL6\n" "\t--uartG device (deprecated) set device string for SERIAL6\n"
"\t--uartH device set device string for SERIAL7\n" "\t--uartH device (deprecated) set device string for SERIAL7\n"
"\t--uartI device set device string for SERIAL8\n" "\t--uartI device (deprecated) set device string for SERIAL8\n"
"\t--uartJ device set device string for SERIAL9\n" "\t--uartJ device (deprecated) set device string for SERIAL9\n"
"\t--serial0 device set device string for SERIAL0\n" "\t--serial0 device set device string for SERIAL0\n"
"\t--serial1 device set device string for SERIAL1\n" "\t--serial1 device set device string for SERIAL1\n"
"\t--serial2 device set device string for SERIAL2\n" "\t--serial2 device set device string for SERIAL2\n"
@ -246,6 +246,16 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
CMDLINE_FGVIEW, CMDLINE_FGVIEW,
CMDLINE_AUTOTESTDIR, CMDLINE_AUTOTESTDIR,
CMDLINE_DEFAULTS, 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_SERIAL0, // must be in 0-9 order and numbered consecutively
CMDLINE_SERIAL1, CMDLINE_SERIAL1,
CMDLINE_SERIAL2, CMDLINE_SERIAL2,
@ -295,16 +305,16 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
{"disable-fgview", false, 0, CMDLINE_FGVIEW}, {"disable-fgview", false, 0, CMDLINE_FGVIEW},
{"autotest-dir", true, 0, CMDLINE_AUTOTESTDIR}, {"autotest-dir", true, 0, CMDLINE_AUTOTESTDIR},
{"defaults", true, 0, CMDLINE_DEFAULTS}, {"defaults", true, 0, CMDLINE_DEFAULTS},
{"uartA", true, 0, CMDLINE_SERIAL0}, {"uartA", true, 0, CMDLINE_UARTA},
{"uartB", true, 0, CMDLINE_SERIAL3}, // ordering captures the historical use of uartB as SERIAL3 {"uartB", true, 0, CMDLINE_UARTB},
{"uartC", true, 0, CMDLINE_SERIAL1}, {"uartC", true, 0, CMDLINE_UARTC},
{"uartD", true, 0, CMDLINE_SERIAL2}, {"uartD", true, 0, CMDLINE_UARTD},
{"uartE", true, 0, CMDLINE_SERIAL4}, {"uartE", true, 0, CMDLINE_UARTE},
{"uartF", true, 0, CMDLINE_SERIAL5}, {"uartF", true, 0, CMDLINE_UARTF},
{"uartG", true, 0, CMDLINE_SERIAL6}, {"uartG", true, 0, CMDLINE_UARTG},
{"uartH", true, 0, CMDLINE_SERIAL7}, {"uartH", true, 0, CMDLINE_UARTH},
{"uartI", true, 0, CMDLINE_SERIAL8}, {"uartI", true, 0, CMDLINE_UARTI},
{"uartJ", true, 0, CMDLINE_SERIAL9}, {"uartJ", true, 0, CMDLINE_UARTJ},
{"serial0", true, 0, CMDLINE_SERIAL0}, {"serial0", true, 0, CMDLINE_SERIAL0},
{"serial1", true, 0, CMDLINE_SERIAL1}, {"serial1", true, 0, CMDLINE_SERIAL1},
{"serial2", true, 0, CMDLINE_SERIAL2}, {"serial2", true, 0, CMDLINE_SERIAL2},
@ -439,6 +449,27 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
case CMDLINE_DEFAULTS: case CMDLINE_DEFAULTS:
defaults_path = strdup(gopt.optarg); defaults_path = strdup(gopt.optarg);
break; 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_SERIAL0:
case CMDLINE_SERIAL1: case CMDLINE_SERIAL1:
case CMDLINE_SERIAL2: case CMDLINE_SERIAL2: