From 558051272225b5df9fa28ba6f454219f1d93bcdc Mon Sep 17 00:00:00 2001 From: Raghav Sharma <156632806+RaghavSharma7255@users.noreply.github.com> Date: Mon, 10 Feb 2025 17:40:39 -0500 Subject: [PATCH] Fix bus reliability issue in update_fifo method Wrapped the update_fifo method in a try-except block to handle potential I/O errors on the Raspberry Pi's I2C bus. This improves reliability by preventing crashes due to transient communication failures. --- qwiic_keypad.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qwiic_keypad.py b/qwiic_keypad.py index e8d0da3..339d402 100644 --- a/qwiic_keypad.py +++ b/qwiic_keypad.py @@ -217,4 +217,10 @@ def update_fifo(self): @return No return value """ # set bit0, commanding keypad to update fifo - self._i2c.writeByte(self.address, KEYPAD_UPDATE_FIFO, 0x01) + # Wrap in try-catch to fix issues in the bus on Raspberry Pi + # and to ensure its reliability + try: + self._i2c.writeByte(self.address, KEYPAD_UPDATE_FIFO, 0x01) + except IOError: + pass +