Skip to content

Commit

Permalink
python3: force division result to be integer
Browse files Browse the repository at this point in the history
Contrary to python 2, python 3 division always return float. But an
integer is needed. So explicitely cast to integer.
  • Loading branch information
dimhoff committed Jul 2, 2017
1 parent 3a10e37 commit 1a44eb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mt333x_helpers.py
Expand Up @@ -182,7 +182,7 @@ def read16(self, address, length, byteSwap=False):

self._checked_write("\xa2")
self._checked_write(struct.pack(">L", address))
self._checked_write(struct.pack(">L", length/2))
self._checked_write(struct.pack(">L", int(length/2)))
resp = ""
while len(resp) < length:
c = self._ser.read()
Expand Down Expand Up @@ -216,7 +216,7 @@ def read32(self, address, length, byteSwap=False):

self._checked_write("\xaf")
self._checked_write(struct.pack(">L", address))
self._checked_write(struct.pack(">L", length/4))
self._checked_write(struct.pack(">L", int(length/4)))
resp = ""
while len(resp) < length:
c = self._ser.read()
Expand Down Expand Up @@ -312,7 +312,7 @@ def checksum(self, address, length, byteSwap=False):

self._checked_write("\xa4")
self._checked_write(struct.pack(">L", address))
self._checked_write(struct.pack(">L", length/2))
self._checked_write(struct.pack(">L", int(length/2)))
resp = ""
while len(resp) < 2:
c = self._ser.read()
Expand Down

0 comments on commit 1a44eb5

Please sign in to comment.