Hello,
I frequently get the following IOError when calling the AStar.read_analog()
method. It works for some time, anywhere from 10s to a few minutes, but eventually occurs if I let the program run long enough. It seems to be somewhat random and independent of the frequency at which I call the method (tested from 20 to 50Hz).
File "/home/pi/git/RasPiBot202/examples/wii_remote_obstacle_avoidance.py", line 59, in <module>
rpb202.readAStar()
File "../robot.py", line 34, in readAStar
self.analog = self.aStar.read_analog()
File "../astarRPB202.py", line 43, in read_analog
return self.read_unpack(12, 12, "HHHHHH")
File "../astarRPB202.py", line 20, in read_unpack
byte_list.append(self.bus.read_byte(20))
IOError: [Errno 5] Input/output error
I’ve been having the issue sporadically since the beginning but it seems more frequent when I use the read_analog()
method of the AStar class in parallel with the read_encoders()
method I added (code in https://github.com/DrGFreeman/RasPiBot202/blob/master/astarRPB202.py).
When not calling the AStar.read_analog()
method, I sometimes get a similar error when calling AStar.read_encoders()
:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "../motioncontroller.py", line 115, in _run
self.odometer.update()
File "../odometer.py", line 47, in update
countLeft, countRight = self.encoders.readCounts()
File "../encoders.py", line 14, in readCounts
countLeft, countRight = self.aStar.read_encoders()
File "../astarRPB202.py", line 46, in read_encoders
return self.read_unpack(25, 4, "hh")
File "../astarRPB202.py", line 20, in read_unpack
byte_list.append(self.bus.read_byte(20))
IOError: [Errno 5] Input/output error
I tried calling the AStar.read8()
method in a python shell and got a similar error after a few seconds:
>>> a = astarRPB202.AStar()
>>> while True:
... a.test_read8()
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "astarRPB202.py", line 52, in test_read8
self.read_unpack(0, 8, 'cccccccc')
File "astarRPB202.py", line 20, in read_unpack
byte_list.append(self.bus.read_byte(20))
IOError: [Errno 5] Input/output error
Finally, I tried running the benchmary.py example in the pololu-rpi-slave-arduino-library and immediately got a similar error though this time the error occurred in the call to self.bus.write_i2c_block_data()
:
pi@raspibot202:~/tmp/pololu-rpi-slave-arduino-library/pi $ python benchmark.py
Traceback (most recent call last):
File "benchmark.py", line 12, in <module>
total_time = timeit.timeit(a_star.test_write8, number=n)
File "/usr/lib/python2.7/timeit.py", line 230, in timeit
return Timer(stmt, setup, timer).timeit(number)
File "/usr/lib/python2.7/timeit.py", line 195, in timeit
timing = self.inner(it, self.timer)
File "/usr/lib/python2.7/timeit.py", line 100, in inner
_func()
File "/home/pi/tmp/pololu-rpi-slave-arduino-library/pi/a_star.py", line 49, in test_write8
self.bus.write_i2c_block_data(20, 0, [0,0,0,0,0,0,0,0])
IOError: [Errno 5] Input/output error
Any idea what could be the cause and how I could improve the situation?
Thanks in advance!
P.S. An example program where I use both the sensors (read_analog) and the encoders is here: https://github.com/DrGFreeman/RasPiBot202/blob/in_work/examples/wii_remote_obstacle_avoidance.py