Skip to content

Commit

Permalink
TMCL: Cleaned up TMCL_Request initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
trinamic-LH committed Aug 31, 2020
1 parent 24b4898 commit 04d39ee
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions PyTrinamic/TMCL.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ class TMCL_Status (object):

class TMCL_Request(object):
def __init__(self, address, command, commandType, motorBank, value):
self.moduleAddress = address
self.command = command
self.commandType = commandType
self.motorBank = motorBank
self.value = value & 0xFFFFFFFF
self.checksum = 0
checksum_struct = struct.pack(_PACKAGE_STRUCTURE[:-1], address, command, commandType, motorBank, value & 0xFFFFFFFF)
self.moduleAddress = address & 0xFF
self.command = command & 0xFF
self.commandType = commandType & 0xFF
self.motorBank = motorBank & 0xFF
self.value = value & 0xFFFFFFFF
self.checksum = 0

checksum_struct = self.toBuffer()
for s in checksum_struct:
self.checksum += s
self.checksum %= 256
Expand Down

0 comments on commit 04d39ee

Please sign in to comment.