Skip to content

Instantly share code, notes, and snippets.

@bwhitman
Created January 30, 2017 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwhitman/6046e02c77938e8b01e93fbb5ecc68f2 to your computer and use it in GitHub Desktop.
Save bwhitman/6046e02c77938e8b01e93fbb5ecc68f2 to your computer and use it in GitHub Desktop.
# Read length data from a register, return the data
def read_register(register, length):
# To read a register you send reg & 0x80, and then read it back
# If you have blocking off the read will return none if it's too soon after
send_data = [0, register, 0x80, length, 0, 0, 0]
what = _dev.write(send_data)
ret = _dev.read(len(send_data) + length)
return ret[4:4+length] # Data comes in at the 4th byte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment