diff --git a/libraries/AP_HAL_SITL/SITL_State_common.cpp b/libraries/AP_HAL_SITL/SITL_State_common.cpp index 54a530bc44..47a625d4d7 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.cpp +++ b/libraries/AP_HAL_SITL/SITL_State_common.cpp @@ -304,13 +304,9 @@ SITL::SerialDevice *SITL_State_Common::create_serial_sim(const char *name, const return ais; #endif } else if (strncmp(name, "gps", 3) == 0) { - const char *p = strchr(name, ':'); - if (p == nullptr) { - AP_HAL::panic("Need a GPS number (e.g. sim:gps:1)"); - } - uint8_t x = atoi(p+1); + uint8_t x = atoi(arg); if (x <= 0 || x > ARRAY_SIZE(gps)) { - AP_HAL::panic("Bad GPS number %u", x); + AP_HAL::panic("Bad GPS number %u (%s)", x, arg); } gps[x-1] = NEW_NOTHROW SITL::GPS(x-1); return gps[x-1]; diff --git a/libraries/AP_HAL_SITL/SITL_State_common.h b/libraries/AP_HAL_SITL/SITL_State_common.h index 95ef129c1c..472f7dfefa 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.h +++ b/libraries/AP_HAL_SITL/SITL_State_common.h @@ -231,7 +231,7 @@ public: const char *defaults_path = HAL_PARAM_DEFAULTS_PATH; // simulated GPS devices - SITL::GPS *gps[2]; // constrained by # of parameter sets + SITL::GPS *gps[AP_SIM_MAX_GPS_SENSORS]; // constrained by # of parameter sets // Simulated ELRS radio SITL::ELRS *elrs; diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index e809f4a43b..358fb61482 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -77,11 +77,11 @@ void UARTDriver::_begin(uint32_t baud, uint16_t rxSpace, uint16_t txSpace) if (strcmp(path, "GPS1") == 0) { /* gps */ _connected = true; - _sim_serial_device = _sitlState->create_serial_sim("gps:1", "", _portNumber); + _sim_serial_device = _sitlState->create_serial_sim("gps", "1", _portNumber); } else if (strcmp(path, "GPS2") == 0) { /* 2nd gps */ _connected = true; - _sim_serial_device = _sitlState->create_serial_sim("gps:2", "", _portNumber); + _sim_serial_device = _sitlState->create_serial_sim("gps", "2", _portNumber); } else { /* parse type:args:flags string for path. For example: