Skip to content

Commit

Permalink
Drivers using I2C: Do not close the port in case of error or stopping
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hor63 committed May 22, 2024
1 parent 5cddb66 commit c8d6459
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/drivers/AMS5915/AMS5915Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/MPL3115/MPL3115Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/MPU-9150/MPU-9150Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/MS4515/MS4515Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/TE-MEAS-AbsPressure/TE-MEAS-AbsPressureDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit c8d6459

Please sign in to comment.