About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

Failed to open i2c port for write - after some time

650 Views - Created 10/07/2018

10/07/2018

Posted by:
JAaslyng

Last edited: 10/07/2018

Users 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

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hello Jesper

The “Failed to open i2c port for write” error normally occurs when the I2C port is being 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?

AB Electronics UK Tech Support

10/07/2018

Posted by:
JAaslyng

Users 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

Users Avatar

Location:
United Kingdom

Users Twitter  Users 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.

AB Electronics UK Tech Support

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.