Skip to content

Commit 9e1aed0

Browse files
Merge pull request #10 from codedstructure/fix-bitbang-port-byte
fix #6 - bitbang `port` values should be truncated to 8 bits
2 parents 183b94e + 96d78a9 commit 9e1aed0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pylibftdi/bitbang.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ def port(self):
158158

159159
@port.setter
160160
def port(self, value):
161+
# restrict to a single byte
162+
value &= 0xFF
161163
self._latch = value
162164
if self.sync:
163165
self.flush_output()
164-
return super().write(chr(value))
166+
# note to_bytes() gets these as default args in Python3.11+
167+
return super().write(value.to_bytes(1, "big"))

0 commit comments

Comments
 (0)