AP_HAL_SITL: allow disabling CAN interfaces

Also corrects an issue where setting an invalid type could result in
undefined behavior.
This commit is contained in:
Thomas Watson 2024-07-13 11:47:30 -05:00 committed by Andrew Tridgell
parent ca0cd9a7e8
commit 1c54dd9e5d
1 changed files with 4 additions and 0 deletions

View File

@ -224,6 +224,10 @@ bool CANIface::init(const uint32_t bitrate, const OperatingMode mode)
transport = NEW_NOTHROW CAN_SocketCAN();
#endif
break;
case SITL::SIM::CANTransport::None:
default: // if user supplies an invalid value for the parameter
transport = nullptr;
break;
}
if (transport == nullptr) {
return false;