Better error messages for I2C errors.
authorBenjamin Braatz <bb@bbraatz.eu>
Tue, 29 Mar 2022 12:58:22 +0000 (14:58 +0200)
committerBenjamin Braatz <bb@bbraatz.eu>
Tue, 29 Mar 2022 12:58:22 +0000 (14:58 +0200)
controlpi_plugins/pcf8574.py

index 257d92aa566dcbf6513d6302e5e98ff19f363c54..d5dd6aaa91d39f22134cb19e22e18383631f7788 100644 (file)
@@ -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):