I've been using SMBus on RPi for a while.
My program should send a number to the arduino (slave) then read from it. This should be done so many times and in a high frequence : it means every 5 to 10 ms the RPi writes then reads from the arduino.
That is my python side program:
I put a sleep between the write and read instructions because Arduino takes a little time to prepare its data. The problem is that when I run the program, the communication turns well but just for one minute and then I get input/output error [errno = 5] on the write instruction.
Code: Select all
import smbus bus= smbus.SMBus(1) arduinoADDR = 0x12 While True: bus.write_byte(arduinoADDR, 2) time.sleep(0.005) reponse=bus.read_byte(arduinoADDR); time.sleep(0.001)
I noticed that when I increase the duration of the sleep between write and read the communication lasts more but stops finally with the same error.
Does anyone know in general what can cause such error? What are the possible causes for it ?
And finally, is there a way to tell RPi to run again the program when the write is impossible (I mean tell him not to stop the execution but restart it)?