Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import usb.core
- import usb.util
- #open printer connection
- dev = usb.core.find(idVendor=0x0a5f, idProduct=0x0062)
- assert dev is not None
- endpoint = dev[0][(0,0)][0]
- dev.set_configuration()
- # get an endpoint instance
- cfg = dev.get_active_configuration()
- intf = cfg[(0,0)]
- # find descriptor
- descriptor = usb.util.find_descriptor(intf, custom_match = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
- assert descriptor is not None
- def exec_command(command):
- descriptor.write(command + chr(0x0D) + chr(0x0A))
- bytes = dev.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize)
- response = "".join(map(chr, bytes))
- print(response)
- exec_command(descriptor, '! U1 getvar "device.languages"')
- exec_command(descriptor, '! U1 getvar "device.pnp_option"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement