I thought I had beaten the fatal I2C error 121 when multiple processes access the distance sensor, by instantiating the distance sensor to use “RPI_1” the hardware I2C in all programs:
egpg.ds = egpg.init_distance_sensor(port='RPI_1')
(The IMU must use software I2C but only one process accesses the IMU and only when the wheel encoders report motion has started or stopped, to minimize use of the much less reliable software I2C.)
In testing my Easy PiCamera Sensor with a “Braitenberg Vehicle with Obstacle Inhibition” program, I am again seeing the dreaded fatal I2C Errno 121 after a minute or two of 10 times per second distance sensor checks. Even a warm boot (sudo reboot) does not clear the error, only a total shutdown (sudo shutdown -h followed by a GoPiGo3 power-button press) and cold boot (GoPiGo3 power-button press from off state) can fix this issue.
I did try calling the imu.reconfig_bus() method, but it does not revive the I2C bus from the Errno 121 state.
I2C Error during Braitenberg Vehicle 10 per second access
2020-12-16 09:11:41 light - left: 25.8 right: 33.2 dist: 300
2020-12-16 09:11:41 Stimulus - left: 18.3 right: 40.7 gain: 3.0
2020-12-16 09:11:42 light - left: 25.5 right: 33.0 dist: 300
2020-12-16 09:11:42 Stimulus - left: 18.1 right: 40.4 gain: 3.0
2020-12-16 09:11:42 light - left: 25.5 right: 33.0 dist: 300
2020-12-16 09:11:42 Stimulus - left: 18.1 right: 40.4 gain: 3.0
2020-12-16 09:11:42 light - left: 25.5 right: 33.0 dist: 300
2020-12-16 09:11:42 Stimulus - left: 18.1 right: 40.4 gain: 3.0
2020-12-16 09:11:43 light - left: 25.5 right: 33.0 dist: 300
2020-12-16 09:11:43 Stimulus - left: 18.1 right: 40.4 gain: 3.0
[Errno 121] I2C transfer: Remote I/O error
2020-12-16 09:11:43 Obstruction at 0 centimeters
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
2020-12-16 09:11:45 Obstruction at 0 centimeters
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
2020-12-16 09:11:47 Obstruction at 0 centimeters
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
[Errno 121] I2C transfer: Remote I/O error
Reconfigure I2C bus failed to fix
pi@Carl:~/Carl/systests/I2C $ ./reconfigI2Cbus.py
Reconfiguring I2C bus using EasyIMUSensor().reconfig_bus()
on GoPiGo3 port AD1
pi@Carl:~/Carl/systests/I2C $ cd ../DistanceSensor/
pi@Carl:~/Carl/systests/DistanceSensor $ ./readDistSensor.py
Traceback (most recent call last):
File "./readDistSensor.py", line 21, in <module>
ds = EasyDistanceSensor(use_mutex=True)
File "build/bdist.linux-armv7l/egg/di_sensors/easy_distance_sensor.py", line 56, in __init__
File "build/bdist.linux-armv7l/egg/di_sensors/distance_sensor.py", line 28, in __init__
File "build/bdist.linux-armv7l/egg/di_sensors/VL53L0X.py", line 126, in __init__
File "build/bdist.linux-armv7l/egg/di_i2c.py", line 220, in write_reg_8
File "build/bdist.linux-armv7l/egg/di_i2c.py", line 185, in transfer
File "build/bdist.linux-armv7l/egg/di_i2c.py", line 469, in transfer
IOError: [Errno 5] Input/output error
pi@Carl:~/Carl $ ./logMaintenance.py "Braitenburg2B.py reading dist sensor killed I2C bus"
'** Braitenburg2B.py reading dist sensor killed I2C bus **' added to life.log
To Do:
I am going to try again later with the IMU not running to see if the issue still appears. I suspect this will eliminate the problem.