diff --git a/src/pylibftdi/bitbang.py b/src/pylibftdi/bitbang.py index 98b260f..65cabbd 100644 --- a/src/pylibftdi/bitbang.py +++ b/src/pylibftdi/bitbang.py @@ -158,7 +158,10 @@ def port(self): @port.setter def port(self, value): + # restrict to a single byte + value &= 0xFF self._latch = value if self.sync: self.flush_output() - return super().write(chr(value)) + # note to_bytes() gets these as default args in Python3.11+ + return super().write(value.to_bytes(1, "big"))