Skip to content

Instantly share code, notes, and snippets.

@thierer
Created June 20, 2020 09:29
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 thierer/575d3e73d5357676ef453bb9ef0a2dc7 to your computer and use it in GitHub Desktop.
Save thierer/575d3e73d5357676ef453bb9ef0a2dc7 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import usb.core
from usb.util import *
CBM_DEVICE = 8
XUM1541_INIT = 1
XUM1541_SHUTDOWN = 3
dev = usb.core.find(idVendor=0x16d0, idProduct=0x0504)
if dev is None:
raise ValueError('ZoomFloppy not found')
dev.set_configuration(1)
dev.set_interface_altsetting(0, 0)
dev.ctrl_transfer(CTRL_TYPE_CLASS | CTRL_IN, XUM1541_INIT, 0, 0, 8)
dev.write(4 | ENDPOINT_OUT, [0x09, 0x13, 0x02, 0x00]) # TALK
dev.write(4 | ENDPOINT_OUT, [0x40 | CBM_DEVICE, 0x6f])
dev.read(3 | ENDPOINT_IN, 3)
dev.write(4 | ENDPOINT_OUT, [0x08, 0x10, 0x26, 0x00]) # READ STATUS
status = dev.read(3 | ENDPOINT_IN, 38)
dev.write(4 | ENDPOINT_OUT, [0x09, 0x12, 0x01, 0x00]) # UNTALK
dev.write(4 | ENDPOINT_OUT, [0x5f])
dev.read(3 | ENDPOINT_IN, 3)
dev.ctrl_transfer(CTRL_TYPE_CLASS | CTRL_OUT, XUM1541_SHUTDOWN)
print(status.tobytes().decode('ascii'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment