Closed p1r473 closed 9 months ago
I can confirm this behavior.
When I try to do an OTA update, I do get the same error:
pi@raspberrypi:~/bin/upsplus $ python3 OTA_firmware_upgrade.py
Traceback (most recent call last):
File "/home/pi/bin/upsplus/OTA_firmware_upgrade.py", line 23, in <module>
aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))
File "/home/pi/.local/lib/python3.9/site-packages/smbus2/smbus2.py", line 433, in read_byte_data
ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error
However, other commands work:
raspberrypi:~/bin $ python3 upsPlus.py
------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 4.936 V
Raspberry Pi Current Current Consumption: 1012.447 mA
Raspberry Pi Current Power Consumption: 5076.535 mW
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 4.200 V
Battery Current (Charging) Rate: 778.049 mA
Current Battery Power Supplement: 3278.049 mW
Successfully set the protection voltage to: 3700 mV
------------------------------------------------------------
Currently charging via Micro USB Port.
I have not seen this error once I closed the bus when I finished with it. That is, adding:
bus.close()
to the end of the python script (or where it exited) addressed the issue for me.
To do the firmware update, are you putting the UPS into firmware update mode? That error indicates it is not in the mode.
I was able to work out the issue with my installation. Summary, I had run out of file handles.
The library ina219.py opens a handle to the i2c bus, but the API does not provide a way to close the handle. You have to exit your python application, which releases the handle. If you use any of the python scripts provided here, you must exit after each call.
I was continually calling the library through a systemctl service
to provide information to grafana (via influxdb) to log status. I would run out of handles, and run into this 'Remote I/O error'.
I changed it to a cron job and haven't see the issue happen again.
Hmm, I was speaking of your post while doing python3 OTA_firmware_upgrade.py
That requires putting the UPS in firmware update mode first was my only point. That is not run via cron.
For me, I had run out of file handles when I tried to use python3 OTA_firmware_upgrade.py
Only fix that worked for me was putting it in a loop that attempts the operation 3 times, because sometimes it just fails.
Usually, the application works for me. However some times, I get the following error: