Skip to content

Commit

Permalink
Fixed problem with long CData strings
Browse files Browse the repository at this point in the history
CData strings longer than 253 bytes were failing to encode
  • Loading branch information
nickpiggott committed Jul 21, 2020
1 parent f61f996 commit d3ddfdc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/spi/binary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,13 @@ def tobytes(self):
bits += tmp
elif datalength >= 254 and datalength <= 1<<16:
tmp = bitarray()
tmp.fromstring('\xfe')
tmp.frombytes'\xfe')
bits += tmp
tmp = encode_number(datalength, 16)
bits += tmp
elif datalength > 1<<16 and datalength <= 1<<24:
tmp = bitarray()
tmp.fromstring('\xff')
tmp.frombytes('\xff')
bits += tmp
tmp = encode_number(datalength, 24)
bits += tmp
Expand Down

0 comments on commit d3ddfdc

Please sign in to comment.