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:46:01 -05:00 committed by Andrew Tridgell
parent 501d0d8759
commit ca0cd9a7e8
2 changed files with 5 additions and 4 deletions

View File

@ -133,7 +133,7 @@ const AP_Param::GroupInfo SIM::var_info[] = {
// @Param: CAN_TYPE1
// @DisplayName: transport type for first CAN interface
// @Description: transport type for first CAN interface
// @Values: 0:MulticastUDP,1:SocketCAN
// @Values: 0:None,1:MulticastUDP,2:SocketCAN
// @User: Advanced
AP_GROUPINFO("CAN_TYPE1", 30, SIM, can_transport[0], uint8_t(CANTransport::MulticastUDP)),
#endif
@ -142,7 +142,7 @@ const AP_Param::GroupInfo SIM::var_info[] = {
// @Param: CAN_TYPE2
// @DisplayName: transport type for second CAN interface
// @Description: transport type for second CAN interface
// @Values: 0:MulticastUDP,1:SocketCAN
// @Values: 0:None,1:MulticastUDP,2:SocketCAN
// @User: Advanced
AP_GROUPINFO("CAN_TYPE2", 31, SIM, can_transport[1], uint8_t(CANTransport::MulticastUDP)),
#endif

View File

@ -229,8 +229,9 @@ public:
#if HAL_NUM_CAN_IFACES
enum class CANTransport : uint8_t {
MulticastUDP = 0,
SocketCAN = 1
None = 0,
MulticastUDP = 1,
SocketCAN = 2,
};
AP_Enum<CANTransport> can_transport[HAL_NUM_CAN_IFACES];
#endif