Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mst(self, motor_number):
"""
tmcl_mst(motor_number) --> None
The motor will be instructed to stop.
TMCL-Mnemonic: MST
"""
cn = NUMBER_COMMANDS['MST']
mn = int(motor_number)
if not 0 <= mn <= 2:
raise TMCLError("MST: motor_number not in range(3)")
status, value = self._query((0x01, cn, 0x00, mn, 0x00))
if status != STAT_OK:
raise TMCLError("MST: got status "+STATUSCODES[status])
return None
The motor will be instructed to rotate with a specified velocity
in right direction (increasing the position counter).
TMCL-Mnemonic: ROR ,
"""
cn = NUMBER_COMMANDS['ROR']
mn = int(motor_number)
v = int(velocity)
if not 0 <= mn <= 2:
raise TMCLError("ROR: motor_number not in range(3)")
if not 0 <= v <= 2047:
raise TMCLError("ROR: velocity not in range(2048)")
status, value = self._query((0x01, cn, 0x00, mn, v))
if status != STAT_OK:
raise TMCLError("ROR: got status "+STATUSCODES[status])
return None
"""
cn = NUMBER_COMMANDS['SCO']
mn = int(motor_number)
coord_n = int(coordinate_number)
pos = int(position)
if not 0 <= coord_n <= 20:
raise TMCLError("SCO: coordinate_number not in range(21)")
if not -2**23 <= pos <= 2**23:
raise TMCLError("SCO: position not in range(-2**23,2**23)")
if not 0 <= mn <= 2:
raise TMCLError("SCO: motor_number not in range(3)")
elif not (mn == 0xFF and pos == 0):
raise TMCLError("SCO: special function needs pos == 0")
status, value = self._query((0x01, cn, coord_n, mn, pos))
if status != STAT_OK:
raise TMCLError("SCO: got status "+STATUSCODES[status])
return None
for the axis. With this parameter they can be read out. In
standalone mode the requested value is also transferred to the
accumulator register for further processing purposes (such as
conditioned jumps). In direct mode the value read is only
output in the value field of the reply (without affecting the
accumulator).
TMCL-Mnemonic: GAP ,
"""
cn = NUMBER_COMMANDS['GAP']
mn = int(motor_number)
pn = int(parameter_number)
if not 0 <= mn <= 2:
raise TMCLError("GAP: motor_number not in range(3)")
if pn not in AXIS_PARAMETER.keys():
raise TMCLError(prefix+"parameter number not valid")
status, value = self._query((0x01, cn, pn, mn, 0x0000))
if status != STAT_OK:
raise TMCLError("GAP: got status " + STATUSCODES[status]
+ ", while querying "+str(pn))
return value
* Moving the motor to a (previously stored) coordinate
(refer to SCO for details).
TMCL-Mnemonic: MVP , ,
"""
cn = NUMBER_COMMANDS['MVP']
mn = int(motor_number)
t = str(cmdtype)
v = int(value)
if not 0 <= mn <= 2:
raise TMCLError("MVP: motor_number not in range(3)")
if t not in CMD_MVP_TYPES.keys():
raise TMCLError("MVP: type not in ['ABS', 'REL', 'COORD']")
if t == 'ABS' and not -2**23 <= v <= 2**23:
raise TMCLError("MVP: ABS: value not in range(-2**23,2**23)")
# pass 'REL' because we dont know the current pos here
if t == 'COORD' and not 0 <= v <= 20:
raise TMCLError("MVP: COORD: value not in range(21)")
t = CMD_MVP_TYPES[t] % (1<<8)
status, value = self._query((0x01, cn, t, mn, v))
if status != STAT_OK:
raise TMCLError("MVP: got status "+STATUSCODES[status])
return None
accumulator. Depending on the global parameter 84, the
coordinates are only stored in RAM or also stored in the EEPROM
and copied back on startup (with the default setting the
coordinates are stored in RAM, only).
Please note that the coordinate number 0 is always stored in
RAM, only.
TMCL-Mnemonic: GCO ,
"""
cn = NUMBER_COMMANDS['GCO']
mn = int(motor_number)
coord_n = int(coordinate_number)
if not 0 <= coord_n <= 20:
raise TMCLError("GCO: coordinate_number not in range(21)")
if not (0 <= mn <= 2 or mn == 0xFF):
raise TMCLError("GCO: motor_number not in range(3)")
elif not (mn == 0xFF and pos == 0):
raise TMCLError("GCO: special function needs pos == 0")
status, value = self._query((0x01, cn, coord_n, mn, pos))
if status != STAT_OK:
raise TMCLError("GCO: got status "+STATUSCODES[status])
return value
def decodeReplyCommand(cmd_string):
byte_array = bytearray(cmd_string)
if len(byte_array) != 9:
raise TMCLError("Commandstring shorter than 9 bytes")
if byte_array[8] != sum(byte_array[:8]) % (1<<8):
raise TMCLError("Checksum error in command %s" % cmd_string)
ret = {}
ret['reply-address'] = byte_array[0]
ret['module-address'] = byte_array[1]
ret['status'] = byte_array[2]
ret['command-number'] = byte_array[3]
ret['value'] = sum(b << (3-i)*8 for i,b in enumerate(byte_array[4:8]))
ret['checksum'] = byte_array[8]
return ret
number for future products. Currently, bank 0 and bank 1 are
used for global parameters. Bank 2 is used for user variables
and bank 3 is used for interrupt configuration. Internal
function: the parameter is read out of the correct position
in the appropriate device. The parameter format is converted
adding leading zeros (or ones for negative values).
TMCL-Mnemonic: GGP ,
"""
cn = NUMBER_COMMANDS['GGP']
bn = int(bank_number)
pn = int(parameter_number)
if not 0 <= bn <= 3:
raise TMCLError("GGP: bank_number not in range(4)")
if not (bn, pn) in GLOBAL_PARAMETER.keys():
raise TMCLError("GGP: parameter number not valid")
status, value = self._query((0x01, cn, pn, bn, 0x0000))
if status != STAT_OK:
raise TMCLError("GGP: got status "+STATUSCODES[status])
return value
the actual status of the reference search can be checked.
if cmdtype in ['START', 'STOP']:
return 0
if cmdtype == 'STATUS':
return 0 if "ref-search is active" else "other values"
TMCL-Mnemonic: RFS ,
"""
cn = NUMBER_COMMANDS['RFS']
mn = int(motor_number)
t = str(cmdtype)
if not 0 <= mn <= 2:
raise TMCLError("RFS: motor_number not in range(3)")
if t not in CMD_RFS_TYPES.keys():
raise TMCLError("RFS: type not in ['START', 'STOP', 'STATUS']")
t = CMD_RFS_TYPES[t] % (1<<8)
status, value = self._query((0x01, cn, t, mn, 0x0000))
if status != STAT_OK:
raise TMCLError("RFS: got status "+STATUSCODES[status])
return value if t == CMD_RFS_TYPES['STATUS'] else 0
RAM only.
TMCL-Mnemonic: SCO , ,
"""
cn = NUMBER_COMMANDS['SCO']
mn = int(motor_number)
coord_n = int(coordinate_number)
pos = int(position)
if not 0 <= coord_n <= 20:
raise TMCLError("SCO: coordinate_number not in range(21)")
if not -2**23 <= pos <= 2**23:
raise TMCLError("SCO: position not in range(-2**23,2**23)")
if not 0 <= mn <= 2:
raise TMCLError("SCO: motor_number not in range(3)")
elif not (mn == 0xFF and pos == 0):
raise TMCLError("SCO: special function needs pos == 0")
status, value = self._query((0x01, cn, coord_n, mn, pos))
if status != STAT_OK:
raise TMCLError("SCO: got status "+STATUSCODES[status])
return None