Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Failed to open i2c port for write - after some time

1896 Views - Created 10/07/2018

10/07/2018

Posted by:
JAaslyng

JAaslyng Avatar

I am using a ExpanderPi port for a control application that runs continuously and control the climate in a greenhouse. The IO Ports is setup for different output. I am using C++.

When I start my application, everything works as expected, but after approximately 30 hours it stops working. I have tried to debug the application and have found that it actually gives this error message “Failed to open i2c port for write”. The io_write_pin is used in a try-catch block and the program continue, but the ports seems not to be working any longer. After the first error the error continuous so that the application doesn’t work any longer..

Do you have any ideas of why it stops working after running more than a day?

Is it possible to reset the io-ports when the error occur?

Jesper

10/07/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello Jesper

The “Failed to open i2c port for write” error normally occurs when the I2C port is blocked by another process. Do you have any other I2C devices on the Raspberry Pi which are being used at the same time as the Expander Pi?

10/07/2018

Posted by:
JAaslyng

JAaslyng Avatar

Yes. I am using a BMP180 sensor, so that might be the problem. But it is very stage that it works for hours and then it stops working. What happens if it is blocked once, will it then need to be reset or should it just work again afterwards?

Jesper

10/07/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

It may be worth checking the code for your BMP180 sensor to make sure it is closing any I2C connections after each time it reads from the sensor. What could be happening is the code is opening a new instance of the I2C connection and not closing it so the number of connections would keep increasing over time. After a while, the Raspberry Pi would run out of space for new connections and it would refuse to open any new ones which would cause the error you are getting. Once the I2C port is blocked you will probably need to reset the Pi for it to start working again.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.