UMRT Arm Firmware Library
|
Python MWE for controlling stepper motors over the communication link. More...
Functions | |
def | CommunicationMaster.pack_32 (integer) |
Pack a 32-bit integer into a little-endian bytearray. More... | |
def | CommunicationMaster.pack_16 (integer) |
Pack a 16-bit integer into a little-endian bytearray. More... | |
def | CommunicationMaster.firmatify (pack) |
Encode a packed bytearray to the 7-bit packets Firmata uses. More... | |
def | CommunicationMaster.defirmatify (data) |
Decode Firmata 7-bit packets into a bytearray of 8-bit packets. More... | |
def | CommunicationMaster.decode_32 (data, offset=0, signed=True) |
Decode a portion of a packed bytearray to a 32-bit integer. More... | |
def | CommunicationMaster.decode_16 (data, offset=0, signed=True) |
Decode a portion of a packed bytearray to a 16-bit integer. More... | |
def | CommunicationMaster.decode_8 (data, offset=0, signed=True) |
Decode a portion of a packed bytearray to an 8-bit integer. More... | |
def | CommunicationMaster.on_echo_text (*data) |
Print text data to the console. More... | |
def | CommunicationMaster.on_echo_int32 (*data) |
Print a 32-bit integer to the console. More... | |
def | CommunicationMaster.on_echo_int16 (*data) |
Print a 16-bit integer to the console. More... | |
def | CommunicationMaster.on_echo_raw (*data) |
Print a raw Firmata message to the console. More... | |
def | CommunicationMaster.on_set_speed (*data) |
Extract and print the info returned by a SET_SPEED command. More... | |
def | CommunicationMaster.on_get_speed (*data) |
Extract and print the info returned by a GET_SPEED command. More... | |
def | CommunicationMaster.on_send_step (*data) |
Extract and print the info returned by a SEND_STEP command. More... | |
def | CommunicationMaster.on_seek_position (*data) |
Extract and print the info returned by a SEEK_POSITION command. More... | |
def | CommunicationMaster.on_get_position (*data) |
Extract and print the info returned by a GET_POSITION command. More... | |
Python MWE for controlling stepper motors over the communication link.
When run, the testing sequence described at Arduino Communication Test Script is executed.
def CommunicationMaster.decode_16 | ( | data, | |
offset = 0 , |
|||
signed = True |
|||
) |
Decode a portion of a packed bytearray to a 16-bit integer.
:param data: a bytearray to unpack from :param offset: the index in data which the integer begins at :param signed: true
if the integer is signed :return: the integer represented by data[offset:offset+2]
def CommunicationMaster.decode_32 | ( | data, | |
offset = 0 , |
|||
signed = True |
|||
) |
Decode a portion of a packed bytearray to a 32-bit integer.
:param data: a bytearray to unpack from :param offset: the index in data which the integer begins at :param signed: true
if the integer is signed :return: the integer represented by data[offset:offset+4]
def CommunicationMaster.decode_8 | ( | data, | |
offset = 0 , |
|||
signed = True |
|||
) |
Decode a portion of a packed bytearray to an 8-bit integer.
:param data: a bytearray to unpack from :param offset: the index in data which the integer begins at :param signed: true
if the integer is signed :return: the integer represented by data[offset:offset+1]
def CommunicationMaster.defirmatify | ( | data | ) |
Decode Firmata 7-bit packets into a bytearray of 8-bit packets.
See firmatify for an explanation of what Firmata does to packets.
:param data: a list of packets to decode, must have even length :return: the reconstructed bytearray
def CommunicationMaster.firmatify | ( | pack | ) |
Encode a packed bytearray to the 7-bit packets Firmata uses.
Must be called on the pack provided to send_sysex. Useful for checking a == decode_32(firmatify(pack_32(a)))
.
E.g. for [0xEF, 0xBE, 0xAD, 0xDE]
:
:param pack: a bytearray :return: the bytearray split into 7-bit segments
def CommunicationMaster.on_echo_int16 | ( | * | data | ) |
Print a 16-bit integer to the console.
:param data: a Firmata-encoded 16-bit integer
def CommunicationMaster.on_echo_int32 | ( | * | data | ) |
Print a 32-bit integer to the console.
:param data: a Firmata-encoded 32-bit integer
def CommunicationMaster.on_echo_raw | ( | * | data | ) |
Print a raw Firmata message to the console.
:param data: some Firmata-encoded data
def CommunicationMaster.on_echo_text | ( | * | data | ) |
Print text data to the console.
:param data: a Firmata text packet
def CommunicationMaster.on_get_position | ( | * | data | ) |
Extract and print the info returned by a GET_POSITION command.
:param data: a Firmata message from a GET_POSITION command response
def CommunicationMaster.on_get_speed | ( | * | data | ) |
Extract and print the info returned by a GET_SPEED command.
:param data: a Firmata message from a GET_SPEED command response
def CommunicationMaster.on_seek_position | ( | * | data | ) |
Extract and print the info returned by a SEEK_POSITION command.
:param data: a Firmata message from a SEEK_POSITION command response
def CommunicationMaster.on_send_step | ( | * | data | ) |
Extract and print the info returned by a SEND_STEP command.
:param data: a Firmata message from a SEND_STEP command response
def CommunicationMaster.on_set_speed | ( | * | data | ) |
Extract and print the info returned by a SET_SPEED command.
:param data: a Firmata message from a SET_SPEED command response
def CommunicationMaster.pack_16 | ( | integer | ) |
Pack a 16-bit integer into a little-endian bytearray.
E.g. for 0xBEEF
:
:param integer: a number to pack :return: the packed representation
def CommunicationMaster.pack_32 | ( | integer | ) |
Pack a 32-bit integer into a little-endian bytearray.
E.g. for 0xDEAD_BEEF
:
:param integer: a number to pack :return: the packed representation