Exemplo n.º 1
0
def acquire_device(timeout=10):
    backend = usb.backend.libusb1.get_backend(find_library=lambda x:libusbfinder.libusb1_path())
    #print 'Acquiring device handle',
    start = time.time()
    # Keep retrying for up to timeout seconds if device is not found.
    while time.time() - start < timeout:
        device = usb.core.find(idVendor=0x5AC, idProduct=0x1281, backend=backend)
        if device is not None:
            return device
        sys.stdout.flush()
        time.sleep(0.1)
    print('ERROR: No Apple device in Recovery Mode 0x1281 detected. Exiting.')
    sys.exit(1)
Exemplo n.º 2
0
def acquire_device(timeout=5.0, match=None, fatal=True):
  backend = usb.backend.libusb1.get_backend(find_library=lambda x:libusbfinder.libusb1_path())
  #print 'Acquiring device handle.'
  # Keep retrying for up to timeout seconds if device is not found.
  start = time.time()
  once = False
  while not once or time.time() - start < timeout:
      once = True
      for device in usb.core.find(find_all=True, idVendor=0x5AC, idProduct=0x1227, backend=backend):
          if match is not None and match not in device.serial_number:
              continue
          return device
      time.sleep(0.001)
  if fatal:
      print '> ERROR: No Apple device in DFU Mode 0x1227 detected after %0.2f second timeout. Exiting.' % timeout
      sys.exit(1)
  return None
Exemplo n.º 3
0
import sys, time
import usb # pyusb: use 'pip install pyusb' to install this module
import usb.backend.libusb1
import libusbfinder

MAX_PACKET_SIZE = 0x800

backend = usb.backend.libusb1.get_backend(find_library=lambda x:libusbfinder.libusb1_path())

def acquire_device(retry=True, timeout=5.0, match=None, fatal=True):
    #print 'Acquiring device handle.'
    # Keep retrying for up to timeout seconds if device is not found.
    start = time.time()
    once = False
    while not once or time.time() - start < timeout:
        once = True
        for device in usb.core.find(find_all=True, idVendor=0x5AC, idProduct=0x1227, backend=backend):
            if device is not None:
                if match is not None and match not in device.serial_number:
                    continue
                return device
        if not retry:
            return None
        time.sleep(0.001)
    if fatal:
        print 'ERROR: No Apple device in DFU Mode 0x1227 detected after %0.2f second timeout. Exiting.' % timeout
        sys.exit(1)
    return None

def acquire_all_devices():
    def _is_mobile(device):