Created
April 28, 2013 06:36
-
-
Save ryaninhust/5476115 to your computer and use it in GitHub Desktop.
Charging Ipad on linux, python script
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
#!/usr/bin/python | |
import usb.core | |
import usb.util | |
import usb.backend.libusb10 | |
import sys, getopt | |
opts = getopt.getopt(sys.argv[1:],'',['off']) | |
off = 'off' in opts[1] | |
VENDOR_APPLE = 0x05ac | |
PRODUCT_IPAD1 = 0x129a | |
PRODUCT_IPAD2 = 0x129f | |
# find our device | |
dev = usb.core.find(idVendor=VENDOR_APPLE, idProduct=PRODUCT_IPAD1) | |
if not dev: | |
dev = usb.core.find(idVendor=VENDOR_APPLE, idProduct=PRODUCT_IPAD2) | |
if dev is None: | |
raise ValueError('Device not found') | |
usb.util.claim_interface(dev, 0) | |
dev.ctrl_transfer(usb.util.CTRL_TYPE_VENDOR|usb.util.CTRL_OUT, 0x40, 0x6400, 0x6400 if not off else 0, None, 2000) | |
usb.util.release_interface(dev, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment