Created
June 7, 2020 22:03
-
-
Save billatq/2171c5c7b44f14867f2e80ae05ab1833 to your computer and use it in GitHub Desktop.
Super simple driver for Royal LetterMaster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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