From 4f1c43862e2a6620a8c5f31fc0c628492fffa6c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Mar 2021 12:05:07 +1100 Subject: [PATCH] HAL_SITL: support arrays of CAN interfaces allows for multi-bus in AP_Periph --- libraries/AP_HAL_SITL/CANSocketIface.cpp | 2 ++ libraries/AP_HAL_SITL/CANSocketIface.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libraries/AP_HAL_SITL/CANSocketIface.cpp b/libraries/AP_HAL_SITL/CANSocketIface.cpp index 03ca3d2a66..8a48a5aa94 100644 --- a/libraries/AP_HAL_SITL/CANSocketIface.cpp +++ b/libraries/AP_HAL_SITL/CANSocketIface.cpp @@ -53,6 +53,8 @@ using namespace HALSITL; CANIface::CANSocketEventSource CANIface::evt_can_socket[HAL_NUM_CAN_IFACES]; +uint8_t CANIface::next_interface; + static can_frame makeSocketCanFrame(const AP_HAL::CANFrame& uavcan_frame) { can_frame sockcan_frame { uavcan_frame.id& AP_HAL::CANFrame::MaskExtID, uavcan_frame.dlc, { } }; diff --git a/libraries/AP_HAL_SITL/CANSocketIface.h b/libraries/AP_HAL_SITL/CANSocketIface.h index 34916523b1..bb7cc8201f 100644 --- a/libraries/AP_HAL_SITL/CANSocketIface.h +++ b/libraries/AP_HAL_SITL/CANSocketIface.h @@ -62,6 +62,9 @@ public: , _max_frames_in_socket_tx_queue(2) { } + static uint8_t next_interface; + CANIface() : CANIface(next_interface++) {} + ~CANIface() { } // Initialise CAN Peripheral