From 159d2c9ff86afbcc73b95f62201372c598622882 Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Tue, 29 Mar 2022 14:58:22 +0200 Subject: [PATCH] Better error messages for I2C errors. --- controlpi_plugins/pcf8574.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controlpi_plugins/pcf8574.py b/controlpi_plugins/pcf8574.py index 257d92a..d5dd6aa 100644 --- a/controlpi_plugins/pcf8574.py +++ b/controlpi_plugins/pcf8574.py @@ -25,12 +25,12 @@ class OutputCard(BasePlugin): try: self._handle = pi.i2c_open(1, self.conf['address']) except pigpio.error as e: - print(e) + print(f"OutputCard at '{self.conf['address']}': {e}") return try: byte = pi.i2c_read_byte(self._handle) except pigpio.error as e: - print(e) + print(f"OutputCard at '{self.conf['address']}': {e}") byte = 0 self._pins2states: Dict[int, bool] = {} self._pins2clients: Dict[int, List[str]] = {} @@ -87,7 +87,7 @@ class OutputCard(BasePlugin): pi.i2c_write_byte(self._handle, byte) byte = pi.i2c_read_byte(self._handle) except pigpio.error as e: - print(e) + print(f"OutputCard at '{self.conf['address']}': {e}") return # Send changed events for all changed clients: for pin in range(0, 8): @@ -127,12 +127,12 @@ class InputCard(BasePlugin): try: self._handle = pi.i2c_open(1, self.conf['address']) except pigpio.error as e: - print(e) + print(f"InputCard at '{self.conf['address']}': {e}") return try: byte = pi.i2c_read_byte(self._handle) except pigpio.error as e: - print(e) + print(f"InputCard at '{self.conf['address']}': {e}") byte = 0 self._pins2states: Dict[int, bool] = {} self._pins2clients: Dict[int, List[str]] = {} @@ -177,7 +177,7 @@ class InputCard(BasePlugin): try: byte = pi.i2c_read_byte(self._handle) except pigpio.error as e: - print(e) + print(f"InputCard at '{self.conf['address']}': {e}") return # Send changed events for all changed clients: for pin in range(0, 8): -- 2.34.1