Skip to content

Commit

Permalink
ENH: python 2/3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLP committed Jan 9, 2019
1 parent c42e794 commit 4579460
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions basil/HL/binder_mk53.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _parse_read_response(self, msgbytes):
raise RuntimeWarning('Checksum of read data wrong')
n_words = n_bytes >> 1
words = []
for word in xrange(n_words):
for word in range(n_words):
words.extend(struct.unpack('>H', msgbytes[3 + word * 2:5 + word * 2]))
return words

Expand Down Expand Up @@ -168,8 +168,8 @@ def _decode_float(self, value):
def _calc_crc16(self, msg):
crc = 0xffff
for byte in msg:
crc ^= ord(byte)
for _ in xrange(8): # loop bits
crc ^= byte
for _ in range(8): # loop bits
sbit = crc & 1
crc >>= 1
crc ^= sbit * 0xA001
Expand Down
2 changes: 1 addition & 1 deletion basil/HL/weiss_sb22.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def check_for_errors(self, answer):

def _calc_crc(self, msg):
ASCII = "0123456789ABCDEF"
mod_256 = (-(sum(ord(i) for i in msg) % 256) & 0xFF)
mod_256 = (-(sum(i for i in msg) % 256) & 0xFF)
lword = (mod_256 & 0xF0) >> 4
hword = mod_256 & 0x0F
return ASCII[lword] + ASCII[hword]

0 comments on commit 4579460

Please sign in to comment.