mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
HAL_SITL: allow override of serial devices in SITL periph
This commit is contained in:
parent
fca6f2cba2
commit
6e952bae17
@ -24,12 +24,35 @@ extern const AP_HAL::HAL& hal;
|
||||
|
||||
using namespace HALSITL;
|
||||
|
||||
enum long_options {
|
||||
CMDLINE_SERIAL0=1,
|
||||
CMDLINE_SERIAL1,
|
||||
CMDLINE_SERIAL2,
|
||||
CMDLINE_SERIAL3,
|
||||
CMDLINE_SERIAL4,
|
||||
CMDLINE_SERIAL5,
|
||||
CMDLINE_SERIAL6,
|
||||
CMDLINE_SERIAL7,
|
||||
CMDLINE_SERIAL8,
|
||||
CMDLINE_SERIAL9,
|
||||
};
|
||||
|
||||
void SITL_State::init(int argc, char * const argv[]) {
|
||||
int opt;
|
||||
const struct GetOptLong::option options[] = {
|
||||
{"help", false, 0, 'h'},
|
||||
{"instance", true, 0, 'I'},
|
||||
{"maintenance", false, 0, 'M'},
|
||||
{"serial0", true, 0, CMDLINE_SERIAL0},
|
||||
{"serial1", true, 0, CMDLINE_SERIAL1},
|
||||
{"serial2", true, 0, CMDLINE_SERIAL2},
|
||||
{"serial3", true, 0, CMDLINE_SERIAL3},
|
||||
{"serial4", true, 0, CMDLINE_SERIAL4},
|
||||
{"serial5", true, 0, CMDLINE_SERIAL5},
|
||||
{"serial6", true, 0, CMDLINE_SERIAL6},
|
||||
{"serial7", true, 0, CMDLINE_SERIAL7},
|
||||
{"serial8", true, 0, CMDLINE_SERIAL8},
|
||||
{"serial9", true, 0, CMDLINE_SERIAL9},
|
||||
{0, false, 0, 0}
|
||||
};
|
||||
|
||||
@ -41,19 +64,44 @@ void SITL_State::init(int argc, char * const argv[]) {
|
||||
|
||||
while((opt = gopt.getoption()) != -1) {
|
||||
switch (opt) {
|
||||
case 'I':
|
||||
_instance = atoi(gopt.optarg);
|
||||
break;
|
||||
case 'M':
|
||||
printf("Running in Maintenance Mode\n");
|
||||
_maintenance = true;
|
||||
break;
|
||||
default:
|
||||
printf("Options:\n"
|
||||
"\t--help|-h display this help information\n"
|
||||
"\t--instance|-I N set instance of SITL Periph\n"
|
||||
"\t--maintenance|-M run in maintenance mode\n");
|
||||
exit(1);
|
||||
case 'I':
|
||||
_instance = atoi(gopt.optarg);
|
||||
break;
|
||||
case 'M':
|
||||
printf("Running in Maintenance Mode\n");
|
||||
_maintenance = true;
|
||||
break;
|
||||
case CMDLINE_SERIAL0:
|
||||
case CMDLINE_SERIAL1:
|
||||
case CMDLINE_SERIAL2:
|
||||
case CMDLINE_SERIAL3:
|
||||
case CMDLINE_SERIAL4:
|
||||
case CMDLINE_SERIAL5:
|
||||
case CMDLINE_SERIAL6:
|
||||
case CMDLINE_SERIAL7:
|
||||
case CMDLINE_SERIAL8:
|
||||
case CMDLINE_SERIAL9: {
|
||||
static const uint8_t mapping[] = { 0, 2, 3, 1, 4, 5, 6, 7, 8, 9 };
|
||||
_uart_path[mapping[opt - CMDLINE_SERIAL0]] = gopt.optarg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("Options:\n"
|
||||
"\t--help|-h display this help information\n"
|
||||
"\t--instance|-I N set instance of SITL Periph\n"
|
||||
"\t--maintenance|-M run in maintenance mode\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"
|
||||
"\t--serial3 device set device string for SERIAL3\n"
|
||||
"\t--serial4 device set device string for SERIAL4\n"
|
||||
"\t--serial5 device set device string for SERIAL5\n"
|
||||
"\t--serial6 device set device string for SERIAL6\n"
|
||||
"\t--serial7 device set device string for SERIAL7\n"
|
||||
"\t--serial8 device set device string for SERIAL8\n"
|
||||
"\t--serial9 device set device string for SERIAL9\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user