Use Python to solve the problem that iPad cannot be charged on Ubuntu

Source: Internet
Author: User
Today, I found that the ipad always displays NotCharging on Ubuntu. I searched for it and found someone wrote an ipad_charge program: notebook. So I transplanted it with pyusb (apt-getinstallpython-usb :#! /Usr/bin/pythonimport

Today I found that the ipad on Ubuntu will always show Not Charging, searched, found someone wrote an ipad_charge program: https://github.com/mkorenkov/ipad_charge/

After reading the source code, you can send a control command to start and stop charging.

So we transplanted it with pyusb (apt-get install python-usb:

#!/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)

Charging:

Python ipad_charge.py

Stop charging:

Python ipad_charge.py off

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.