Skip to content

Instantly share code, notes, and snippets.

@billatq
Created June 7, 2020 22:03
Show Gist options
  • Save billatq/2171c5c7b44f14867f2e80ae05ab1833 to your computer and use it in GitHub Desktop.
Save billatq/2171c5c7b44f14867f2e80ae05ab1833 to your computer and use it in GitHub Desktop.
Super simple driver for Royal LetterMaster
import sys
import usb.core
import usb.util
import time
def initialize():
# find our device
dev = usb.core.find(idVendor=0x1a86, idProduct=0x7584)
# was it found?
if dev is None:
raise ValueError('Device not found')
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
ep = usb.util.find_descriptor(
intf,
# match the first OUT endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT)
assert ep is not None
return ep
def main():
ep = initialize()
to_print = sys.stdin.read()
count = 0
for c in to_print:
ep.write(c)
count = count + 1
# Give it time to catch up
if (count % 25 == 0):
time.sleep(3)
count = 0
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment