federico3 / trovastelle

An arrow that points at interesting objects in the sky, inspired by the art installation at the JPL mall.
2 stars 0 forks source link

Intermittent i2c error in trovastelle2 #51

Closed federico3 closed 1 year ago

federico3 commented 1 year ago

Often, trovastelle2 will give this error:

➜ python trovastelle.py
Traceback (most recent call last):
  File "/home/pi/trovastelle/src/celestial_compass/trovastelle.py", line 438, in <module>
    asyncio.run(ts.run(),debug=_debug)
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/pi/trovastelle/src/celestial_compass/trovastelle.py", line 399, in run
    await cc_task
  File "/home/pi/trovastelle/src/celestial_compass/compass.py", line 168, in run
    await main_task
  File "/home/pi/trovastelle/src/celestial_compass/compass.py", line 233, in _run_main
    self.display_controller.display_observable_data(
  File "/home/pi/trovastelle/src/celestial_compass/display_manager.py", line 241, in display_observable_data
    self._display_text_in_box(
  File "/home/pi/.local/lib/python3.9/site-packages/luma/core/render.py", line 43, in __exit__
    self.device.display(self.image)
  File "/home/pi/.local/lib/python3.9/site-packages/luma/oled/device/__init__.py", line 225, in display
    self.data(list(buf))
  File "/home/pi/.local/lib/python3.9/site-packages/luma/core/device.py", line 55, in data
    self._serial_interface.data(data)
  File "/home/pi/.local/lib/python3.9/site-packages/luma/core/interface/serial.py", line 125, in data
    write(list(data[i:i + block_size]))
  File "/home/pi/.local/lib/python3.9/site-packages/luma/core/interface/serial.py", line 134, in _write_large_block
    self._bus.i2c_rdwr(self._i2c_msg_write(self._addr, [self._data_mode] + data))
  File "/home/pi/.local/lib/python3.9/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
    ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 121] Remote I/O error

Looks like this is an i2c error. It may have to do with the clock not being properly stretched, or just some issue with how the display is wired (remember that terrible soldering job?), or just noise. When this happens, the whole application crashes and does not restart.