adafruit / adafruit/Adafruit_CircuitPython_MLX90640

OSError: [Errno 5] Input/output error in raspberry pi 4

Open
#33 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
72
Forks
21
PR merge metrics
No merged PRs in 30d

Description

Hi. I try the sample code and modify it for measure process time
When it run 2833 sec after start ,I got the error 'OSError: [Errno 5] Input/output error '
And the second try to got the same error with 594 sec
Do you know how can I fix it?

here is my code:

```
import time
import board
import busio
import adafruit_mlx90640
t0=time.time()
i2c = busio.I2C(board.SCL, board.SDA, frequency=800000)

mlx = adafruit_mlx90640.MLX90640(i2c)
print("MLX addr detected on I2C", [hex(i) for i in mlx.serial_number])

# if using higher refresh rates yields a 'too many retries' exception,
# try decreasing this value to work with certain pi/camera combinations
mlx.refresh_rate = adafruit_mlx90640.RefreshRate.REFRESH_2_HZ

frame = [0] * 768
while True:
try:
mlx.getFrame(frame)
except ValueError:
# these happen, no biggie - retry
continue

for h in range(24):
for w in range(32):
t = frame[h*32 + w]
processtime = time.time()-t0
print(round(frame[0],1))
print('processtime: %d sec'%processtime)

```

and here is the error report:

Traceback (most recent call last):
File "", line 18, in
File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 126, in getFrame
status = self._GetFrameData(mlx90640Frame)
File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 140, in _GetFrameData
self._I2CReadWords(0x8000, statusRegister)
File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 828, in _I2CReadWords
i2c.write_then_readinto(
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 141, in write_then_readinto
self.i2c.writeto_then_readfrom(
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 192, in writeto_then_readfrom
return self._i2c.writeto_then_readfrom(
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 90, in writeto_then_readfrom
readin = self._i2c_bus.read_i2c_block_data(
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 275, in read_i2c_block_data
ioctl(self._device.fileno(), I2C_RDWR, request)
OSError: [Errno 5] Input/output error

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the sample code and the traceback at adafruit_mlx90640.py in getFrame, _GetFrameData, and _I2CReadWords, then follow the busio and Adafruit_PureIO I2C calls shown. Reproduce the intermittent error on a Raspberry Pi 4 and determine a reliable correction for the I/O failure; done means the sample runs without the reported OSError over the described interval.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, raspberry-pi
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.