diff --git a/CMakeLists.txt b/CMakeLists.txt index b49f5af..07d6ca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ FetchContent_MakeAvailable(Boost) FetchContent_Declare( isobus GIT_REPOSITORY https://github.com/Open-Agriculture/AgIsoStack-plus-plus.git - GIT_TAG c0e1ebb06a2ad9d5bf86c98b3d028ab8fa350130 + GIT_TAG 1d081d9a9df61e256015efda3683d15c8fa3d580 DOWNLOAD_EXTRACT_TIMESTAMP TRUE) FetchContent_MakeAvailable(isobus) diff --git a/include/app.hpp b/include/app.hpp index 6ee3ca7..8bc4ce5 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -92,7 +92,6 @@ class Application std::unique_ptr vtUpdateHelper; std::vector vtObjectPool; bool vtClientStarted = false; - bool canHardwareStarted = false; ///< CANHardwareInterface::start() succeeded, so stop() has a thread to stop bool vtConfigSynced = false; bool vtWasConnected = false; bool vtConnectionWarningLogged = false; diff --git a/src/app.cpp b/src/app.cpp index ed61f32..0d2586c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -195,10 +195,10 @@ bool Application::setup_can_hardware() isobus::CANHardwareInterface::set_number_of_can_channels(1); isobus::CANHardwareInterface::assign_can_channel_frame_handler(0, canDriver); - canHardwareStarted = isobus::CANHardwareInterface::start(); - if ((!canHardwareStarted) || (!canDriver->get_is_valid())) + if ((!isobus::CANHardwareInterface::start()) || (!canDriver->get_is_valid())) { - log() << "Failed to start CAN hardware interface." << std::endl; + const std::string reason = canDriver->get_last_error(); + log() << "Failed to start CAN hardware interface." << (reason.empty() ? "" : " " + reason) << std::endl; return false; } @@ -1448,7 +1448,9 @@ void Application::stop() { tcServer->terminate(); } - if (canHardwareStarted) + // start() also starts the update thread when the driver fails to open, so check is_running() + // rather than whether start() succeeded. + if (isobus::CANHardwareInterface::is_running()) { isobus::CANHardwareInterface::stop(); }