From c8d645916abbabfe34c1056654008192accd7f85 Mon Sep 17 00:00:00 2001 From: Kai Horstmann Date: Wed, 22 May 2024 17:13:38 +0200 Subject: [PATCH] Drivers using I2C: Do not close the port in case of error or stopping I2C is a true bus interface which is actually used by multiple sensors concurrently. Therefore an error on one sensor would disrupt operations on other sensors when the shared port is closed by one sensor instance. Signed-off-by: Kai Horstmann --- src/drivers/AMS5915/AMS5915Driver.cpp | 4 ++-- src/drivers/MPL3115/MPL3115Driver.cpp | 4 ++-- src/drivers/MPU-9150/MPU-9150Driver.cpp | 4 ++-- src/drivers/MS4515/MS4515Driver.cpp | 4 ++-- src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drivers/AMS5915/AMS5915Driver.cpp b/src/drivers/AMS5915/AMS5915Driver.cpp index 0760b0d..8c65bd8 100644 --- a/src/drivers/AMS5915/AMS5915Driver.cpp +++ b/src/drivers/AMS5915/AMS5915Driver.cpp @@ -149,12 +149,12 @@ void AMS5915Driver::driverThreadFunction() { ioPort->open(); numRetries = 0; processingMainLoop (); - ioPort->close(); + // ioPort->close(); } catch (std::exception const& e) { numRetries ++; LOG4CXX_ERROR(logger,fmt::format(_("Error in the main loop of driver instance \"{0}\": {1}"), instanceName,e.what())); - ioPort->close(); + // ioPort->close(); std::this_thread::sleep_for(errorTimeout); } diff --git a/src/drivers/MPL3115/MPL3115Driver.cpp b/src/drivers/MPL3115/MPL3115Driver.cpp index 72085c2..ac12f4b 100644 --- a/src/drivers/MPL3115/MPL3115Driver.cpp +++ b/src/drivers/MPL3115/MPL3115Driver.cpp @@ -174,12 +174,12 @@ void MPL3115Driver::driverThreadFunction() { ioPort->open(); numRetries = 0; processingMainLoop (); - ioPort->close(); + // ioPort->close(); } catch (std::exception const& e) { numRetries ++; LOG4CXX_ERROR(logger,fmt::format(_("Error in the main loop of driver instance \"{0}\": {1}"), instanceName,e.what())); - ioPort->close(); + // ioPort->close(); std::this_thread::sleep_for(errorTimeout); } diff --git a/src/drivers/MPU-9150/MPU-9150Driver.cpp b/src/drivers/MPU-9150/MPU-9150Driver.cpp index 07fc547..5fd7a47 100644 --- a/src/drivers/MPU-9150/MPU-9150Driver.cpp +++ b/src/drivers/MPU-9150/MPU-9150Driver.cpp @@ -376,12 +376,12 @@ void MPU9150Driver::driverThreadFunction() { numRetries = 0; setupMPU9150(); processingMainLoop (); - ioPort->close(); + // ioPort->close(); } catch (std::exception const& e) { numRetries ++; LOG4CXX_ERROR(logger,fmt::format(_("Error in the main loop of driver instance \"{0}\": {1}"), instanceName,e.what())); - ioPort->close(); + // ioPort->close(); std::this_thread::sleep_for(errorTimeout); } diff --git a/src/drivers/MS4515/MS4515Driver.cpp b/src/drivers/MS4515/MS4515Driver.cpp index 1214a30..bcd612a 100644 --- a/src/drivers/MS4515/MS4515Driver.cpp +++ b/src/drivers/MS4515/MS4515Driver.cpp @@ -274,12 +274,12 @@ void MS4515Driver::driverThreadFunction() { ioPort->open(); numRetries = 0; processingMainLoop (); - ioPort->close(); + // ioPort->close(); } catch (std::exception const& e) { numRetries ++; LOG4CXX_ERROR(logger,fmt::format(_("Error in the main loop of driver instance \"{0}\": {1}"), instanceName,e.what())); - ioPort->close(); + // ioPort->close(); std::this_thread::sleep_for(errorTimeout); } diff --git a/src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp b/src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp index e4ac556..3ed2c91 100644 --- a/src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp +++ b/src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp @@ -184,7 +184,7 @@ void TE_MEAS_AbsPressureDriver::driverThreadFunction() { numRetries = 0; processingMainLoop (); #if !TE_MEAS_ABS_PRESSURE_TEST_MODE - ioPort->close(); + // ioPort->close(); #endif } catch (TE_MEAS_AbsPressureCRCErrorException const & e1) { @@ -198,7 +198,7 @@ void TE_MEAS_AbsPressureDriver::driverThreadFunction() { LOG4CXX_ERROR(logger,fmt::format(_("Error in the main loop of driver instance \"{0}\": {1}"), instanceName,e.what())); #if !TE_MEAS_ABS_PRESSURE_TEST_MODE - ioPort->close(); + //ioPort->close(); #endif std::this_thread::sleep_for(errorTimeout);