Setting I2C to retry/execute next line if communication fails

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
harsha95
Posts: 2
Joined: Fri Apr 12, 2019 2:42 pm

Setting I2C to retry/execute next line if communication fails

Post by harsha95 » Fri Apr 12, 2019 3:28 pm

Hello

I am using the pyboard in my project and the I2C communication sometimes fails (times out). This is caused by some physical problems that I will soon fix so I am not looking for a solution for the time out problem.

However, every time this timeout happens, the pyboard throws an ENODEV error in console and stops executing code. How do I program it such that it doesn't stop execution? I want it to just continue executing the next line.

Thank you!


harsha95
Posts: 2
Joined: Fri Apr 12, 2019 2:42 pm

Re: Setting I2C to retry/execute next line if communication fails

Post by harsha95 » Wed Apr 17, 2019 1:44 pm

dhylands wrote:
Fri Apr 12, 2019 6:33 pm
You can use python's try:/except: mechanism.
https://docs.python.org/3/tutorial/errors.html
Perfect. That worked. Thank you!

Post Reply