From ebfd69362bfbaa2a924f50a38e0ccb77c78f5a0f Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Tue, 5 Aug 2025 08:32:54 +0200 Subject: [PATCH 01/14] Adding automatic tests and fixing setting value --- src/main/CanVendorAnagate.cpp | 2 +- test/python/test_anagate.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/CanVendorAnagate.cpp b/src/main/CanVendorAnagate.cpp index a28c0410..631d00a6 100644 --- a/src/main/CanVendorAnagate.cpp +++ b/src/main/CanVendorAnagate.cpp @@ -106,7 +106,7 @@ CanReturnCode CanVendorAnagate::vendor_open() noexcept { } if (args().config.high_speed.has_value()) { - args().config.high_speed.value(); + high_speed = args().config.high_speed.value(); } // Set the modified configuration diff --git a/test/python/test_anagate.py b/test/python/test_anagate.py index f669e2a7..fb295c6f 100644 --- a/test/python/test_anagate.py +++ b/test/python/test_anagate.py @@ -209,9 +209,6 @@ def test_anagate_diagnostics(): ) -@pytest.mark.skip( - reason="Disable this test until Anagate release a new firmware version that reports error on sending 30.01.2025" -) def test_anagate_bus_off_recovery(): received_frames_dev1 = [] myDevice1 = CanDevice.create( @@ -222,6 +219,7 @@ def test_anagate_bus_off_recovery(): received_frames_dev2 = [] canDeviceConfig = CanDeviceConfiguration() + canDeviceConfig.sent_acknowledgement = True canDeviceConfig.host = DEVICE_TWO.host canDeviceConfig.bus_number = DEVICE_TWO.bus_number canDeviceConfig.high_speed = DEVICE_ONE.high_speed @@ -234,11 +232,13 @@ def test_anagate_bus_off_recovery(): myDevice2.open() # Send a few frames to trigger bus off - send_error_count = 0 - for _ in range(100_000): + send_error = False + for i in range(100_000): return_code = myDevice2.send(CanFrame(123, ["H", "e", "l", "l", "o"])) if return_code != CanReturnCode.success: - send_error_count += 1 - sleep(1) + assert i == 0 + assert return_code == CanReturnCode.not_ack + send_error = True + break - assert send_error_count > 0 + assert send_error is True From 91acdb05d73c749d7f77dffe549dc15dd8a1b45d Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Thu, 11 Dec 2025 16:47:48 +0100 Subject: [PATCH 02/14] Pre-Commit update --- .pre-commit-config.yaml | 5 +++-- src/include/CanDeviceConfiguration.h | 4 ++-- src/include/CanVendorAnagate.h | 8 ++++---- src/include/CanVendorLoopback.h | 4 ++-- src/include/CanVendorSocketCan.h | 8 ++++---- src/include/CanVendorSocketCanSystec.h | 4 ++-- src/main/CanDerivedStats.cpp | 12 ++++++------ src/main/CanDevice.cpp | 10 +++++----- src/main/CanDeviceConfiguration.cpp | 4 ++-- src/main/CanDiagnostics.cpp | 4 ++-- src/main/CanVendorAnagate.cpp | 16 ++++++++-------- src/main/CanVendorLoopback.cpp | 2 +- src/main/CanVendorSocketCan.cpp | 10 +++++----- src/main/CanVendorSocketCanSystec.cpp | 8 ++++---- src/python/CanModule.cpp | 15 +++++++-------- test/cpp/CanFrame_test.cpp | 2 +- test/python/test_anagate.py | 2 ++ 17 files changed, 60 insertions(+), 58 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15796675..2bda1010 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: args: ["--filter=-legal/copyright"] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: check-added-large-files @@ -29,9 +29,10 @@ repos: - id: mixed-line-ending - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 25.12.0 hooks: - id: black + language_version: python3.13 - repo: local hooks: diff --git a/src/include/CanDeviceConfiguration.h b/src/include/CanDeviceConfiguration.h index da67d886..85cbd2a3 100644 --- a/src/include/CanDeviceConfiguration.h +++ b/src/include/CanDeviceConfiguration.h @@ -97,7 +97,7 @@ struct CanDeviceConfiguration { std::string to_string() const noexcept; }; -std::ostream &operator<<(std::ostream &os, - const CanDeviceConfiguration &config) noexcept; +std::ostream& operator<<(std::ostream& os, + const CanDeviceConfiguration& config) noexcept; #endif // SRC_INCLUDE_CANDEVICECONFIGURATION_H_ diff --git a/src/include/CanVendorAnagate.h b/src/include/CanVendorAnagate.h index 31c01349..d04f56e9 100644 --- a/src/include/CanVendorAnagate.h +++ b/src/include/CanVendorAnagate.h @@ -17,22 +17,22 @@ * information. */ struct CanVendorAnagate : CanDevice { - friend void anagate_receive(AnaInt32 nIdentifier, const char *pcBuffer, + friend void anagate_receive(AnaInt32 nIdentifier, const char* pcBuffer, AnaInt32 nBufferLen, AnaInt32 nFlags, AnaInt32 hHandle) noexcept; - explicit CanVendorAnagate(const CanDeviceArguments &configuration); + explicit CanVendorAnagate(const CanDeviceArguments& configuration); inline ~CanVendorAnagate() override { vendor_close(); } private: CanReturnCode vendor_open() noexcept override; CanReturnCode vendor_close() noexcept override; - CanReturnCode vendor_send(const CanFrame &frame) noexcept override; + CanReturnCode vendor_send(const CanFrame& frame) noexcept override; CanDiagnostics vendor_diagnostics() noexcept override; void print_anagate_error(AnaUInt32 r) noexcept; static std::mutex m_handles_lock; - static std::map m_handles; + static std::map m_handles; AnaInt32 m_handle{0}; }; diff --git a/src/include/CanVendorLoopback.h b/src/include/CanVendorLoopback.h index 76cb1f1d..28439bae 100644 --- a/src/include/CanVendorLoopback.h +++ b/src/include/CanVendorLoopback.h @@ -20,7 +20,7 @@ struct CanVendorLoopback : CanDevice { * which contains configuration parameters for the CAN device. */ inline explicit CanVendorLoopback( - const CanDeviceArguments &configuration) noexcept + const CanDeviceArguments& configuration) noexcept : CanDevice("loopback", configuration) {} private: @@ -34,7 +34,7 @@ struct CanVendorLoopback : CanDevice { inline CanReturnCode vendor_close() noexcept override { return CanReturnCode::success; } - CanReturnCode vendor_send(const CanFrame &frame) noexcept override; + CanReturnCode vendor_send(const CanFrame& frame) noexcept override; inline CanDiagnostics vendor_diagnostics() noexcept override { return CanDiagnostics{}; } diff --git a/src/include/CanVendorSocketCan.h b/src/include/CanVendorSocketCan.h index 029fb75f..591a0f82 100644 --- a/src/include/CanVendorSocketCan.h +++ b/src/include/CanVendorSocketCan.h @@ -22,19 +22,19 @@ * methods to open, close, and send CAN frames using the SocketCAN interface. */ struct CanVendorSocketCan : CanDevice { - explicit CanVendorSocketCan(const CanDeviceArguments &args); + explicit CanVendorSocketCan(const CanDeviceArguments& args); ~CanVendorSocketCan() { vendor_close(); } private: CanReturnCode vendor_open() noexcept override; CanReturnCode vendor_close() noexcept override; - CanReturnCode vendor_send(const CanFrame &frame) noexcept override; + CanReturnCode vendor_send(const CanFrame& frame) noexcept override; CanDiagnostics vendor_diagnostics() noexcept override; int subscriber() noexcept; - static const CanFrame translate(const struct can_frame &message) noexcept; - static struct can_frame translate(const CanFrame &frame) noexcept; + static const CanFrame translate(const struct can_frame& message) noexcept; + static struct can_frame translate(const CanFrame& frame) noexcept; int m_socket_fd{-1}; // File descriptor for the SocketCAN device int m_epoll_fd{-1}; // File descriptor for the epoll instance diff --git a/src/include/CanVendorSocketCanSystec.h b/src/include/CanVendorSocketCanSystec.h index 4b0b3c58..396fd94a 100644 --- a/src/include/CanVendorSocketCanSystec.h +++ b/src/include/CanVendorSocketCanSystec.h @@ -18,13 +18,13 @@ * SocketCan due to a kernel-panic bug on Systec linux module. */ struct CanVendorSocketCanSystec : CanDevice { - explicit CanVendorSocketCanSystec(const CanDeviceArguments &args); + explicit CanVendorSocketCanSystec(const CanDeviceArguments& args); ~CanVendorSocketCanSystec() { vendor_close(); } private: CanReturnCode vendor_open() noexcept override; CanReturnCode vendor_close() noexcept override; - CanReturnCode vendor_send(const CanFrame &frame) noexcept override; + CanReturnCode vendor_send(const CanFrame& frame) noexcept override; CanDiagnostics vendor_diagnostics() noexcept override; std::unique_ptr m_can_vendor_socketcan; diff --git a/src/main/CanDerivedStats.cpp b/src/main/CanDerivedStats.cpp index 11e3ca02..1a67ffa6 100644 --- a/src/main/CanDerivedStats.cpp +++ b/src/main/CanDerivedStats.cpp @@ -15,7 +15,7 @@ * the current Rx and Tx values and will be updated with * the calculated rolling average rates. */ -void CanDerivedStats::update(CanDiagnostics &diagnostics) noexcept { +void CanDerivedStats::update(CanDiagnostics& diagnostics) noexcept { if (!m_init) { if (!diagnostics.rx.has_value() || !diagnostics.tx.has_value()) { m_enabled = false; @@ -48,9 +48,9 @@ void CanDerivedStats::update(CanDiagnostics &diagnostics) noexcept { .count(); if (time_diff > 0) { - const auto update_rate = [&](std::deque &window, - std::optional &value, - uint32_t &last_value, int64_t time_diff) { + const auto update_rate = [&](std::deque& window, + std::optional& value, + uint32_t& last_value, int64_t time_diff) { float rate = static_cast(value.value() - last_value) / time_diff; window.push_front(rate); if (window.size() > window_size) { @@ -64,8 +64,8 @@ void CanDerivedStats::update(CanDiagnostics &diagnostics) noexcept { m_last_update = current_time; - const auto update_per_second = [&](const std::deque &window, - std::optional &per_second) { + const auto update_per_second = [&](const std::deque& window, + std::optional& per_second) { if (!window.empty()) { per_second = std::accumulate(window.begin(), window.end(), 0.0) / window.size(); diff --git a/src/main/CanDevice.cpp b/src/main/CanDevice.cpp index 51f64f0d..204b70ea 100644 --- a/src/main/CanDevice.cpp +++ b/src/main/CanDevice.cpp @@ -72,7 +72,7 @@ CanReturnCode CanDevice::close() noexcept { * @param frame The CAN frame to be sent. It must be a valid frame. * @return int Returns 0 on success, or a non-zero error code on failure. */ -CanReturnCode CanDevice::send(const CanFrame &frame) noexcept { +CanReturnCode CanDevice::send(const CanFrame& frame) noexcept { LOG(Log::DBG, CanLogIt::h()) << "Sending CAN frame: " << frame; CanReturnCode result = vendor_send(frame); @@ -100,10 +100,10 @@ CanReturnCode CanDevice::send(const CanFrame &frame) noexcept { * success or a non-zero error code on failure for the corresponding frame. */ std::vector CanDevice::send( - const std::vector &frames) noexcept { + const std::vector& frames) noexcept { std::vector result(frames.size()); std::transform(frames.begin(), frames.end(), result.begin(), - [this](const CanFrame &frame) { return send(frame); }); + [this](const CanFrame& frame) { return send(frame); }); return result; } @@ -144,7 +144,7 @@ CanDiagnostics CanDevice::diagnostics() noexcept { * provided. */ std::unique_ptr CanDevice::create( - std::string_view vendor, const CanDeviceArguments &configuration) { + std::string_view vendor, const CanDeviceArguments& configuration) { LOG(Log::INF, CanLogIt::h()) << "Creating CAN device for vendor: " << vendor; LOG(Log::INF, CanLogIt::h()) << "Configuration: " << configuration.config; @@ -174,7 +174,7 @@ std::unique_ptr CanDevice::create( return nullptr; } -std::ostream &operator<<(std::ostream &os, CanReturnCode code) { +std::ostream& operator<<(std::ostream& os, CanReturnCode code) { switch (code) { case CanReturnCode::success: return os << "SUCCESS"; diff --git a/src/main/CanDeviceConfiguration.cpp b/src/main/CanDeviceConfiguration.cpp index 9556deb1..c3678bf7 100644 --- a/src/main/CanDeviceConfiguration.cpp +++ b/src/main/CanDeviceConfiguration.cpp @@ -87,7 +87,7 @@ std::string CanDeviceConfiguration::to_string() const noexcept { * @return The output stream (os) with the CanDeviceConfiguration object's * string representation inserted. */ -std::ostream &operator<<(std::ostream &os, - const CanDeviceConfiguration &config) noexcept { +std::ostream& operator<<(std::ostream& os, + const CanDeviceConfiguration& config) noexcept { return os << config.to_string(); } diff --git a/src/main/CanDiagnostics.cpp b/src/main/CanDiagnostics.cpp index fd5f1aa0..97b52ae4 100644 --- a/src/main/CanDiagnostics.cpp +++ b/src/main/CanDiagnostics.cpp @@ -87,7 +87,7 @@ std::string CanDiagnostics::to_string() const noexcept { * @return The output stream (os) after the diagnostic information has been * printed. */ -std::ostream &operator<<(std::ostream &os, - const CanDiagnostics &diag) noexcept { +std::ostream& operator<<(std::ostream& os, + const CanDiagnostics& diag) noexcept { return os << diag.to_string(); } diff --git a/src/main/CanVendorAnagate.cpp b/src/main/CanVendorAnagate.cpp index a28c0410..fada2933 100644 --- a/src/main/CanVendorAnagate.cpp +++ b/src/main/CanVendorAnagate.cpp @@ -13,7 +13,7 @@ #include "CanLogIt.h" std::mutex CanVendorAnagate::m_handles_lock; -std::map CanVendorAnagate::m_handles; +std::map CanVendorAnagate::m_handles; /** * @brief Callback function to handle incoming CAN frames from the AnaGate DLL. @@ -31,7 +31,7 @@ std::map CanVendorAnagate::m_handles; * @param hHandle The handle of the CAN device associated with the received CAN * frame. */ -void anagate_receive(AnaInt32 nIdentifier, const char *pcBuffer, +void anagate_receive(AnaInt32 nIdentifier, const char* pcBuffer, AnaInt32 nBufferLen, AnaInt32 nFlags, AnaInt32 hHandle) noexcept { uint32_t flags{0}; @@ -60,7 +60,7 @@ void anagate_receive(AnaInt32 nIdentifier, const char *pcBuffer, * @param arguments A constant reference to the CanDeviceArguments object, * which contains configuration parameters for the CAN device. */ -CanVendorAnagate::CanVendorAnagate(const CanDeviceArguments &args) +CanVendorAnagate::CanVendorAnagate(const CanDeviceArguments& args) : CanDevice("anagate", args) { if (!args.config.bus_number.has_value() || !args.config.host.has_value()) { throw std::invalid_argument("Missing required configuration parameters"); @@ -114,7 +114,7 @@ CanReturnCode CanVendorAnagate::vendor_open() noexcept { high_speed, enable_timestamp); CANSetCallback(m_handle, reinterpret_cast(anagate_receive)); - } catch (const std::exception &e) { + } catch (const std::exception& e) { LOG(Log::ERR, CanLogIt::h()) << "Exception caught in vendor_open: " << e.what(); return CanReturnCode::internal_api_error; @@ -164,7 +164,7 @@ CanReturnCode CanVendorAnagate::vendor_open() noexcept { * indicates success, while a non-zero value indicates an error. The specific * meaning of the error code can be obtained by calling CANGetLastError. */ -CanReturnCode CanVendorAnagate::vendor_send(const CanFrame &frame) noexcept { +CanReturnCode CanVendorAnagate::vendor_send(const CanFrame& frame) noexcept { if (m_handle == 0) { LOG(Log::ERR, CanLogIt::h()) << "Cannot send frame: Device not open"; return CanReturnCode::disconnected; @@ -182,7 +182,7 @@ CanReturnCode CanVendorAnagate::vendor_send(const CanFrame &frame) noexcept { frame.length(), anagate_flags) : CANWrite(m_handle, frame.id(), frame.message().data(), frame.length(), anagate_flags); - } catch (const std::exception &e) { + } catch (const std::exception& e) { LOG(Log::ERR, CanLogIt::h()) << "Exception caught in vendor_send: " << e.what(); return CanReturnCode::internal_api_error; @@ -230,7 +230,7 @@ CanReturnCode CanVendorAnagate::vendor_send(const CanFrame &frame) noexcept { CanDiagnostics CanVendorAnagate::vendor_diagnostics() noexcept { auto anagate_convert_timestamp = [](AnaInt64 timestamp) { std::time_t time = static_cast(timestamp); - std::tm *local_time = std::localtime(&time); + std::tm* local_time = std::localtime(&time); std::ostringstream timestamp_stream; timestamp_stream << std::put_time(local_time, "%Y-%m-%d %H:%M:%S"); return timestamp_stream.str(); @@ -344,7 +344,7 @@ CanDiagnostics CanVendorAnagate::vendor_diagnostics() noexcept { diagnostics.handle = m_handle; return diagnostics; - } catch (const std::exception &e) { + } catch (const std::exception& e) { LOG(Log::ERR, CanLogIt::h()) << "Exception caught in vendor_diagnostics: " << e.what(); return diagnostics; diff --git a/src/main/CanVendorLoopback.cpp b/src/main/CanVendorLoopback.cpp index 5924d2b4..397d0312 100644 --- a/src/main/CanVendorLoopback.cpp +++ b/src/main/CanVendorLoopback.cpp @@ -9,7 +9,7 @@ * @param frame The CAN frame to be sent. * @return Always returns 0 indicating success. */ -CanReturnCode CanVendorLoopback::vendor_send(const CanFrame &frame) noexcept { +CanReturnCode CanVendorLoopback::vendor_send(const CanFrame& frame) noexcept { received(frame); return CanReturnCode::success; } diff --git a/src/main/CanVendorSocketCan.cpp b/src/main/CanVendorSocketCan.cpp index 355c46cf..8889a780 100644 --- a/src/main/CanVendorSocketCan.cpp +++ b/src/main/CanVendorSocketCan.cpp @@ -29,7 +29,7 @@ constexpr auto LIBSOCKETCAN_SUCCESS = 0; * @param args A constant reference to the CanDeviceArguments object, * which contains the arguments for the CAN device. */ -CanVendorSocketCan::CanVendorSocketCan(const CanDeviceArguments &args) +CanVendorSocketCan::CanVendorSocketCan(const CanDeviceArguments& args) : CanDevice("socketcan", args) { if (!args.config.bus_name.has_value()) { throw std::invalid_argument("Missing required configuration parameters"); @@ -101,7 +101,7 @@ CanReturnCode CanVendorSocketCan::vendor_open() noexcept { addr.can_family = AF_CAN; addr.can_ifindex = ifr.ifr_ifindex; - if (bind(m_socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (bind(m_socket_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { ::close(m_socket_fd); m_socket_fd = -1; LOG(Log::ERR, CanLogIt::h()) << "Failed to bind socket"; @@ -191,7 +191,7 @@ CanReturnCode CanVendorSocketCan::vendor_close() noexcept { * @return int Returns 0 on success, or -1 if the entire frame could not be * sent. */ -CanReturnCode CanVendorSocketCan::vendor_send(const CanFrame &frame) noexcept { +CanReturnCode CanVendorSocketCan::vendor_send(const CanFrame& frame) noexcept { // Translate CanFrame to struct can_frame struct can_frame canFrame = translate(frame); @@ -307,7 +307,7 @@ CanDiagnostics CanVendorSocketCan::vendor_diagnostics() noexcept { * * @return struct can_frame The translated CAN frame. */ -struct can_frame CanVendorSocketCan::translate(const CanFrame &frame) noexcept { +struct can_frame CanVendorSocketCan::translate(const CanFrame& frame) noexcept { struct can_frame canFrame; canFrame.can_id = frame.id(); canFrame.len = frame.length(); @@ -343,7 +343,7 @@ struct can_frame CanVendorSocketCan::translate(const CanFrame &frame) noexcept { * @return CanFrame The translated CanFrame object. */ const CanFrame CanVendorSocketCan::translate( - const struct can_frame &canFrame) noexcept { + const struct can_frame& canFrame) noexcept { const auto id = canFrame.can_id & CAN_EFF_MASK; const auto length = static_cast(canFrame.len); const auto rtr = (canFrame.can_id & CAN_RTR_FLAG); diff --git a/src/main/CanVendorSocketCanSystec.cpp b/src/main/CanVendorSocketCanSystec.cpp index 4cf46e23..0fb23704 100644 --- a/src/main/CanVendorSocketCanSystec.cpp +++ b/src/main/CanVendorSocketCanSystec.cpp @@ -23,10 +23,10 @@ * callback function. */ CanVendorSocketCanSystec::CanVendorSocketCanSystec( - const CanDeviceArguments &args) + const CanDeviceArguments& args) : CanDevice("socketcan_systec", args) { - const std::function filter_busoff_callback = - [this](const CanFrame &frame) { + const std::function filter_busoff_callback = + [this](const CanFrame& frame) { if (frame.is_error() && (frame.id() & CAN_ERR_BUSERROR)) { LOG(Log::WRN, CanLogIt::h()) << "Bus off detected, restarting..."; m_can_vendor_socketcan->close(); @@ -99,7 +99,7 @@ CanReturnCode CanVendorSocketCanSystec::vendor_close() noexcept { * is returned. */ CanReturnCode CanVendorSocketCanSystec::vendor_send( - const CanFrame &frame) noexcept { + const CanFrame& frame) noexcept { if (m_can_vendor_socketcan) return m_can_vendor_socketcan->send(frame); return CanReturnCode::internal_api_error; } diff --git a/src/python/CanModule.cpp b/src/python/CanModule.cpp index f1132dbd..e26b9261 100644 --- a/src/python/CanModule.cpp +++ b/src/python/CanModule.cpp @@ -18,11 +18,10 @@ PYBIND11_MODULE(canmodule, m) { .def(py::init(), py::arg("id"), py::arg("requested_length")) .def(py::init(), py::arg("id")) - .def(py::init &>(), py::arg("id"), + .def(py::init&>(), py::arg("id"), py::arg("message")) - .def( - py::init &, const uint32_t>(), - py::arg("id"), py::arg("message"), py::arg("flags")) + .def(py::init&, const uint32_t>(), + py::arg("id"), py::arg("message"), py::arg("flags")) .def("id", &CanFrame::id) .def("message", &CanFrame::message) .def("flags", &CanFrame::flags) @@ -62,15 +61,15 @@ PYBIND11_MODULE(canmodule, m) { .def("open", &CanDevice::open) .def("close", &CanDevice::close) .def("diagnostics", &CanDevice::diagnostics) - .def("send", py::overload_cast(&CanDevice::send)) + .def("send", py::overload_cast(&CanDevice::send)) .def("send", - py::overload_cast &>(&CanDevice::send)) + py::overload_cast&>(&CanDevice::send)) .def("args", &CanDevice::args) .def_static("create", &CanDevice::create); py::class_(m, "CanDeviceArguments") - .def(py::init &>(), + .def(py::init&>(), py::arg("config"), py::arg("receiver") = nullptr) .def_readonly("config", &CanDeviceArguments::config); diff --git a/test/cpp/CanFrame_test.cpp b/test/cpp/CanFrame_test.cpp index f81f1d2d..d0362b1f 100644 --- a/test/cpp/CanFrame_test.cpp +++ b/test/cpp/CanFrame_test.cpp @@ -165,7 +165,7 @@ TEST_F(CanFrameTest, TestNotEqual) { ASSERT_NE(frame1, frame2); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/python/test_anagate.py b/test/python/test_anagate.py index f669e2a7..078e0b10 100644 --- a/test/python/test_anagate.py +++ b/test/python/test_anagate.py @@ -181,6 +181,8 @@ def test_anagate_diagnostics(): stats1 = myDevice1.diagnostics() stats2 = myDevice2.diagnostics() + assert len(stats1.connected_clients_ports) > 1 + assert stats1.tx_per_second is None assert stats2.rx_per_second is None From 3107378795b66ab0ef39bd15fec95a3d33428d8a Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Thu, 11 Dec 2025 17:20:55 +0100 Subject: [PATCH 03/14] libsocketcan auto-downloaded and configured --- CMakeLists.txt | 46 +++++++++++++++++++++++----------------- cmake/libsocketcan.cmake | 34 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 cmake/libsocketcan.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 89ac817d..bf8de3e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,10 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -include_directories(src/include - ${PROJECT_BINARY_DIR}/src/include/) +include_directories( + src/include + ${PROJECT_BINARY_DIR}/src/include/ +) include(cmake/version.cmake) @@ -23,16 +25,17 @@ set(SOURCES include(cmake/env.cmake) - set(VENDOR_SOURCES src/main/CanVendorAnagate.cpp ) if (UNIX) + include(cmake/libsocketcan.cmake) + include_directories(${LIBSOCKETCAN_INCLUDE_DIR}) list(APPEND VENDOR_SOURCES - src/main/CanVendorSocketCan.cpp - src/main/CanVendorSocketCanSystec.cpp - ) + src/main/CanVendorSocketCan.cpp + src/main/CanVendorSocketCanSystec.cpp + ) endif() if (NOT DEFINED CAN_MODULE_MAIN_ONLY) @@ -44,31 +47,36 @@ endif() include(cmake/anagate.cmake) + add_library(CanModuleMain ${SOURCES} ${VENDOR_SOURCES}) -target_include_directories(CanModuleMain PUBLIC ${LOGIT_INCLUDE} ${anagate_SOURCE_DIR}/) + +target_include_directories(CanModuleMain PUBLIC + ${LOGIT_INCLUDE} + ${anagate_SOURCE_DIR}/ +) + if (UNIX) target_link_libraries(CanModuleMain PUBLIC - ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libCANDLLStaticRelease64.a - ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateStaticRelease.a - ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateExtStaticRelease.a - socketcan) + ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libCANDLLStaticRelease64.a + ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateStaticRelease.a + ${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateExtStaticRelease.a + libsocketcan + ) else() target_link_libraries(CanModuleMain PUBLIC - ${anagate_SOURCE_DIR}/Win64/AnaGateCanDll64.lib) - file(COPY "${anagate_SOURCE_DIR}/Win64/AnaGateCan64.dll" DESTINATION "${CMAKE_BINARY_DIR}/Release") + ${anagate_SOURCE_DIR}/Win64/AnaGateCanDll64.lib + ) + file(COPY "${anagate_SOURCE_DIR}/Win64/AnaGateCan64.dll" + DESTINATION "${CMAKE_BINARY_DIR}/Release") endif() -# Treat warnings as errors if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") -target_compile_options(CanModuleMain PRIVATE -Wall -Wextra -Werror) + target_compile_options(CanModuleMain PRIVATE -Wall -Wextra -Werror) elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") -# target_compile_options(CanModuleMain PRIVATE /W4 /WX) -# I need to disable that feature due to a macro redefinition -# in the header of Anagate software + # Disabled because of AnaGate macro redefinition issues endif() if (NOT DEFINED CAN_MODULE_MAIN_ONLY) - # Build Python Support and Google Unit Tests include(cmake/pybind11.cmake) include(cmake/gtest.cmake) endif() diff --git a/cmake/libsocketcan.cmake b/cmake/libsocketcan.cmake new file mode 100644 index 00000000..11024b4d --- /dev/null +++ b/cmake/libsocketcan.cmake @@ -0,0 +1,34 @@ +FetchContent_Declare( + libsocketcan + GIT_REPOSITORY https://github.com/linux-can/libsocketcan.git + GIT_TAG v0.0.12 + DOWNLOAD_EXTRACT_TIMESTAMP True +) + +FetchContent_MakeAvailable(libsocketcan) + +set(LIBSOCKETCAN_INCLUDE_DIR ${libsocketcan_SOURCE_DIR}/include) + +set(LIBSOCKETCAN_LIB ${libsocketcan_SOURCE_DIR}/src/.libs/libsocketcan.a) + +add_custom_command( + OUTPUT ${LIBSOCKETCAN_LIB} + WORKING_DIRECTORY ${libsocketcan_SOURCE_DIR} + COMMAND bash autogen.sh + COMMAND bash configure --enable-static --disable-shared CFLAGS=-fPIC CXXFLAGS=-fPIC + COMMAND make + DEPENDS ${libsocketcan_SOURCE_DIR} +) + +add_library(libsocketcan STATIC IMPORTED GLOBAL) + +set_target_properties(libsocketcan PROPERTIES + IMPORTED_LOCATION ${LIBSOCKETCAN_LIB} + INTERFACE_INCLUDE_DIRECTORIES ${LIBSOCKETCAN_INCLUDE_DIR} +) + +add_custom_target(libsocketcan_build ALL + DEPENDS ${LIBSOCKETCAN_LIB} +) + +add_dependencies(libsocketcan libsocketcan_build) From efbd98c962fcee310be8f20012fcf00070ef3424 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Thu, 11 Dec 2025 17:24:31 +0100 Subject: [PATCH 04/14] Update gitlab and remove obsolete --- .gitlab-ci.yml | 5 +---- ci/docker/alma9/Dockerfile | 19 ------------------- ci/docker/alma9/trigger | 2 -- ci/docker/w2022/Dockerfile | 5 ----- ci/docker/w2022/install.ps1 | 24 ------------------------ ci/docker/w2022/trigger | 2 -- ci/gitlab/docker.yml | 25 ------------------------- ci/gitlab/normal.yml | 8 ++++---- 8 files changed, 5 insertions(+), 85 deletions(-) delete mode 100644 ci/docker/alma9/Dockerfile delete mode 100644 ci/docker/alma9/trigger delete mode 100644 ci/docker/w2022/Dockerfile delete mode 100644 ci/docker/w2022/install.ps1 delete mode 100644 ci/docker/w2022/trigger delete mode 100644 ci/gitlab/docker.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75436275..2b4df4c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: gitlab-registry.cern.ch/linuxsupport/alma9-base:latest +image: gitlab-registry.cern.ch/linuxsupport/alma10-base:latest stages: - unstagged @@ -11,9 +11,6 @@ include: rules: - if: $CI_PIPELINE_SOURCE == "api" # Source Github-Gitlab bridge - if: $PIPELINE == "normal" - - local: ci/gitlab/docker.yml - rules: - - if: $DOCKER_GENERATION == "true" # Empty job, as gitlab-ci requires at least one job empty: diff --git a/ci/docker/alma9/Dockerfile b/ci/docker/alma9/Dockerfile deleted file mode 100644 index 26a97d23..00000000 --- a/ci/docker/alma9/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM gitlab-registry.cern.ch/linuxsupport/alma9-base:latest - -ADD trigger /trigger -RUN dnf install -y epel-release &&\ - dnf update -y &&\ - dnf install -y cmake ninja-build g++ cppcheck nano git git-lfs python \ - python-pip python-devel doxygen libsocketcan-devel &&\ - dnf clean all -RUN pip install pre-commit clang-format pytest pybind11 - -RUN echo Triggered at: $(cat /trigger) >> /ISSUE &&\ - echo "*******************" >> /ISSUE &&\ - g++ --version &> /ISSUE &&\ - echo "*******************" >> /ISSUE &&\ - echo Ninja Version: $(ninja-build --version) >> /ISSUE &&\ - echo "*******************" >> /ISSUE &&\ - cmake --version &> /ISSUE &&\ - echo "*******************" >> /ISSUE &&\ - uname -a &> /ISSUE diff --git a/ci/docker/alma9/trigger b/ci/docker/alma9/trigger deleted file mode 100644 index 914e8251..00000000 --- a/ci/docker/alma9/trigger +++ /dev/null @@ -1,2 +0,0 @@ -Mon Aug 12 03:03:27 PM CEST 2024 -disabled diff --git a/ci/docker/w2022/Dockerfile b/ci/docker/w2022/Dockerfile deleted file mode 100644 index ff549583..00000000 --- a/ci/docker/w2022/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM registry.cern.ch/mcr.microsoft.com/windows/server:ltsc2022 - -COPY ./* ./ - -RUN powershell .\install.ps1 diff --git a/ci/docker/w2022/install.ps1 b/ci/docker/w2022/install.ps1 deleted file mode 100644 index 61b89cdc..00000000 --- a/ci/docker/w2022/install.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -$ErrorActionPreference = "Stop" - -# Install chocolatey -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - -# Miscelaneous dependencies -choco install -y --no-progress powershell-core python git git-lfs.install nano - -# Install CMake and Ninja -choco install -y --no-progress cmake --installargs 'ADD_CMAKE_TO_PATH=System' -choco install -y --no-progress ninja - -# Visual Studio 2019 Build Tools -choco install -y --no-progress visualstudio2022buildtools -choco install -y --no-progress visualstudio2022-workload-vctools - -# Pip dependencies -Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 -refreshenv - -python -m pip install pybind11 pytest - -# Clean up -choco cache remove diff --git a/ci/docker/w2022/trigger b/ci/docker/w2022/trigger deleted file mode 100644 index aa578b52..00000000 --- a/ci/docker/w2022/trigger +++ /dev/null @@ -1,2 +0,0 @@ -Mon Aug 12 03:03:13 PM CEST 2024 -disabled diff --git a/ci/gitlab/docker.yml b/ci/gitlab/docker.yml deleted file mode 100644 index 4e9b99e5..00000000 --- a/ci/gitlab/docker.yml +++ /dev/null @@ -1,25 +0,0 @@ -Docker Image Alma 9: - stage: unstagged - image: - name: gcr.io/kaniko-project/executor:v1.23.2-debug - entrypoint: [""] - script: - - /kaniko/executor - --context "${CI_PROJECT_DIR}"/ci/docker/alma9/ - --dockerfile "${CI_PROJECT_DIR}"/ci/docker/alma9/Dockerfile - --destination "${CI_REGISTRY_IMAGE}/alma9-build:${CI_COMMIT_SHORT_SHA}" - --destination "${CI_REGISTRY_IMAGE}/alma9-build:latest" - before_script: - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - -Docker Image Windows 2022: - stage: unstagged - tags: - - powershell-win2022 - script: - - cd ci/docker/w2022/ - - docker login -u $env:CI_REGISTRY_USER -p $env:CI_REGISTRY_PASSWORD $env:CI_REGISTRY - - docker build --no-cache -t $env:CI_REGISTRY_IMAGE/win2022-build:$env:CI_COMMIT_SHORT_SHA . - - docker tag $env:CI_REGISTRY_IMAGE/win2022-build:$env:CI_COMMIT_SHORT_SHA $env:CI_REGISTRY_IMAGE/win2022-build:latest - - docker push $env:CI_REGISTRY_IMAGE/win2022-build:$env:CI_COMMIT_SHORT_SHA - - docker push $env:CI_REGISTRY_IMAGE/win2022-build:latest diff --git a/ci/gitlab/normal.yml b/ci/gitlab/normal.yml index 6bf6aaa7..867ca3ea 100644 --- a/ci/gitlab/normal.yml +++ b/ci/gitlab/normal.yml @@ -13,7 +13,7 @@ Compile on Windows: Compile on Linux: stage: unstagged - image: $CI_REGISTRY_IMAGE/alma9-build:latest + image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build script: - cmake -B build - cmake --build build --config Release @@ -34,7 +34,7 @@ Google Tests on Windows: Google Tests on Linux: stage: unstagged - image: $CI_REGISTRY_IMAGE/alma9-build:latest + image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build needs: - Compile on Linux script: @@ -62,14 +62,14 @@ Pytest on Linux: Run Sanity Checks: stage: unstagged - image: $CI_REGISTRY_IMAGE/alma9-build:latest + image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build script: - pip install pre-commit - pre-commit run --all-files Update Documentation Website: stage: unstagged - image: $CI_REGISTRY_IMAGE/alma9-build:latest + image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build script: - | curl -X POST \ From 5752a661a5bc527d4562117b45bb52f13d94e347 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Thu, 11 Dec 2025 17:31:11 +0100 Subject: [PATCH 05/14] Fix path image --- ci/gitlab/normal.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/gitlab/normal.yml b/ci/gitlab/normal.yml index 867ca3ea..c040aa10 100644 --- a/ci/gitlab/normal.yml +++ b/ci/gitlab/normal.yml @@ -1,3 +1,6 @@ +variables: + ALMA_LATEST_IMAGE: "gitlab-registry.cern.ch/quasar-team/images/alma-10-build:latest" + Compile on Windows: stage: unstagged image: $CI_REGISTRY_IMAGE/win2022-build:latest @@ -13,7 +16,7 @@ Compile on Windows: Compile on Linux: stage: unstagged - image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build + script: - cmake -B build - cmake --build build --config Release @@ -34,7 +37,7 @@ Google Tests on Windows: Google Tests on Linux: stage: unstagged - image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build + image: $ALMA_LATEST_IMAGE needs: - Compile on Linux script: @@ -62,14 +65,14 @@ Pytest on Linux: Run Sanity Checks: stage: unstagged - image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build + image: $ALMA_LATEST_IMAGE script: - pip install pre-commit - pre-commit run --all-files Update Documentation Website: stage: unstagged - image: gitlab-registry.cern.ch/quasar-team/images/alma-10-build + image: $ALMA_LATEST_IMAGE script: - | curl -X POST \ From f3e3bc424313b862f60b1e8b8c706cf7a5d72a85 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 12 Dec 2025 10:54:26 +0100 Subject: [PATCH 06/14] Missing image: --- ci/gitlab/normal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/gitlab/normal.yml b/ci/gitlab/normal.yml index c040aa10..0bce38ce 100644 --- a/ci/gitlab/normal.yml +++ b/ci/gitlab/normal.yml @@ -16,7 +16,7 @@ Compile on Windows: Compile on Linux: stage: unstagged - + image: $ALMA_LATEST_IMAGE script: - cmake -B build - cmake --build build --config Release From c8695b8e4aba8b865322c9a2e82e00fd75281916 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 12 Dec 2025 14:19:03 +0100 Subject: [PATCH 07/14] Add cstdint --- src/include/CanFrame.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/CanFrame.h b/src/include/CanFrame.h index 39e7ae02..7cc5fc50 100644 --- a/src/include/CanFrame.h +++ b/src/include/CanFrame.h @@ -1,6 +1,7 @@ #ifndef SRC_INCLUDE_CANFRAME_H_ #define SRC_INCLUDE_CANFRAME_H_ +#include #include #include #include From bb068b141b26b108ab702d7505678ffc500ec5ec Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 12 Dec 2025 14:24:55 +0100 Subject: [PATCH 08/14] Add cstdint --- src/include/CanDerivedStats.h | 1 + src/include/CanDeviceConfiguration.h | 1 + src/include/CanDiagnostics.h | 1 + src/include/CanVendorAnagate.h | 1 + 4 files changed, 4 insertions(+) diff --git a/src/include/CanDerivedStats.h b/src/include/CanDerivedStats.h index 130b427c..b9e7aeef 100644 --- a/src/include/CanDerivedStats.h +++ b/src/include/CanDerivedStats.h @@ -2,6 +2,7 @@ #define SRC_INCLUDE_CANDERIVEDSTATS_H_ #include +#include #include #include diff --git a/src/include/CanDeviceConfiguration.h b/src/include/CanDeviceConfiguration.h index 85cbd2a3..93731a99 100644 --- a/src/include/CanDeviceConfiguration.h +++ b/src/include/CanDeviceConfiguration.h @@ -1,6 +1,7 @@ #ifndef SRC_INCLUDE_CANDEVICECONFIGURATION_H_ #define SRC_INCLUDE_CANDEVICECONFIGURATION_H_ +#include #include #include #include diff --git a/src/include/CanDiagnostics.h b/src/include/CanDiagnostics.h index a0b38613..a0218620 100644 --- a/src/include/CanDiagnostics.h +++ b/src/include/CanDiagnostics.h @@ -1,6 +1,7 @@ #ifndef SRC_INCLUDE_CANDIAGNOSTICS_H_ #define SRC_INCLUDE_CANDIAGNOSTICS_H_ +#include #include #include #include diff --git a/src/include/CanVendorAnagate.h b/src/include/CanVendorAnagate.h index d04f56e9..efdd93b5 100644 --- a/src/include/CanVendorAnagate.h +++ b/src/include/CanVendorAnagate.h @@ -1,6 +1,7 @@ #ifndef SRC_INCLUDE_CANVENDORANAGATE_H_ #define SRC_INCLUDE_CANVENDORANAGATE_H_ +#include #include #include //NOLINT From 80ebaa133d72ced6ec121be7de1234d56f3139d0 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 12 Dec 2025 15:45:42 +0100 Subject: [PATCH 09/14] Alma 10 with Python 3.12, no need to force python version --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2bda1010..15007a66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,6 @@ repos: rev: 25.12.0 hooks: - id: black - language_version: python3.13 - repo: local hooks: From 0d9b446fb568d0726b9753f8a5fd1ba6cf7a5181 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 19 Dec 2025 11:37:09 +0100 Subject: [PATCH 10/14] Fix test --- .gitignore | 1 + test/python/test_anagate.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b9c8c135..0dd9ca78 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__/ .env /public *.cpython* +.github/*.md \ No newline at end of file diff --git a/test/python/test_anagate.py b/test/python/test_anagate.py index 078e0b10..13737b20 100644 --- a/test/python/test_anagate.py +++ b/test/python/test_anagate.py @@ -181,7 +181,7 @@ def test_anagate_diagnostics(): stats1 = myDevice1.diagnostics() stats2 = myDevice2.diagnostics() - assert len(stats1.connected_clients_ports) > 1 + assert len(stats1.connected_clients_ports) >= 1 assert stats1.tx_per_second is None assert stats2.rx_per_second is None From 1490c45ee20b5ab89f4b636fb328bc15fa502fe3 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 19 Dec 2025 13:35:21 +0100 Subject: [PATCH 11/14] Execute modprobe --- test/python/test_socketcan.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/python/test_socketcan.py b/test/python/test_socketcan.py index b6b747c9..19f2571e 100644 --- a/test/python/test_socketcan.py +++ b/test/python/test_socketcan.py @@ -2,6 +2,7 @@ import pytest from common import * import os +import subprocess pytestmark = pytest.mark.skipif( sys.platform.startswith("win"), @@ -14,6 +15,7 @@ # If we are inside the pipeline, we have admin rights to create virtual CAN interfaces # and therefore can bring up/down the device, useful for testing the callback on error functionality if "CI" in os.environ: + subprocess.run(["modprobe", "vcan"], check=False) DEVICE_ONE.vcan = True DEVICE_ONE.bitrate = 500000 # We need a bitrate to trigger configuration of the device, although because it is a vcan, it will be ignored From 09c7739ea37b4bccf78f6cda4fe7fc9cb891e6fd Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 19 Dec 2025 13:35:32 +0100 Subject: [PATCH 12/14] Precommit --- .gitignore | 2 +- .pre-commit-config.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0dd9ca78..0defee68 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ __pycache__/ .env /public *.cpython* -.github/*.md \ No newline at end of file +.github/*.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15007a66..925cfa8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: - id: clang-format args: ["-style=Google"] - id: cppcheck + args: ["--check-level=exhaustive"] - id: cpplint args: ["--filter=-legal/copyright"] From 77df1ed2c9cb306be66a76c412735dd0b920a686 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 19 Dec 2025 13:43:17 +0100 Subject: [PATCH 13/14] No Windows modprobe --- test/python/test_socketcan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/python/test_socketcan.py b/test/python/test_socketcan.py index 19f2571e..0efa5059 100644 --- a/test/python/test_socketcan.py +++ b/test/python/test_socketcan.py @@ -14,7 +14,7 @@ # If we are inside the pipeline, we have admin rights to create virtual CAN interfaces # and therefore can bring up/down the device, useful for testing the callback on error functionality -if "CI" in os.environ: +if "CI" in os.environ and not sys.platform.startswith("win"): subprocess.run(["modprobe", "vcan"], check=False) DEVICE_ONE.vcan = True DEVICE_ONE.bitrate = 500000 # We need a bitrate to trigger configuration of the device, although because it is a vcan, it will be ignored From 69e38e1906d9cb400edf63c22baf3e42c2c58887 Mon Sep 17 00:00:00 2001 From: Luis Miguens Fernandez Date: Fri, 19 Dec 2025 14:53:55 +0100 Subject: [PATCH 14/14] Undo not needed --- test/python/test_socketcan.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/python/test_socketcan.py b/test/python/test_socketcan.py index 0efa5059..7c581ef2 100644 --- a/test/python/test_socketcan.py +++ b/test/python/test_socketcan.py @@ -14,8 +14,7 @@ # If we are inside the pipeline, we have admin rights to create virtual CAN interfaces # and therefore can bring up/down the device, useful for testing the callback on error functionality -if "CI" in os.environ and not sys.platform.startswith("win"): - subprocess.run(["modprobe", "vcan"], check=False) +if "CI" in os.environ: DEVICE_ONE.vcan = True DEVICE_ONE.bitrate = 500000 # We need a bitrate to trigger configuration of the device, although because it is a vcan, it will be ignored