freemyipod r912 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r911‎ | r912 | r913 >
Date:00:06, 27 April 2014
Author:user890104
Status:new
Tags:
Comment:
libemcore: Accept one more USB PID (0xE001)
Modified paths:
  • /emcore/trunk/tools/libemcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/libemcore.py
@@ -1004,6 +1004,7 @@
10051005 self.logger.debug("Initializing Lib object\n")
10061006 self.idVendor = 0xFFFF
10071007 self.idProduct = 0xE000
 1008+ self.idProductMask = 0xFFFE
10081009
10091010 self.headersize = 0x10
10101011
@@ -1010,7 +1011,7 @@
10111012 self.connect()
10121013
10131014 def connect(self):
1014 - self.dev = Dev(self.idVendor, self.idProduct, self.logger)
 1015+ self.dev = Dev(self.idVendor, self.idProduct, self.idProductMask, self.logger)
10151016 self.connected = True
10161017
10171018 def monitorcommand(self, cmd, rcvdatatypes=None, rcvstruct=None):
@@ -1051,13 +1052,15 @@
10521053
10531054
10541055 class Dev(object):
1055 - def __init__(self, idVendor, idProduct, logger):
 1056+ def __init__(self, idVendor, idProduct, idProductMask, logger):
10561057 self.idVendor = idVendor
10571058 self.idProduct = idProduct
 1059+ self.idProductMask = idProductMask
10581060
10591061 self.logger = logger
10601062 self.logger.debug("Initializing Dev object\n")
10611063
 1064+ self.dev = None
10621065 self.interface = None
10631066 self.claimed = False
10641067 self.timeout = 1000
@@ -1083,7 +1086,11 @@
10841087
10851088 def connect(self):
10861089 self.logger.debug("Looking for emCORE device\n")
1087 - self.dev = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
 1090+ devs = usb.core.find(find_all=True, idVendor=self.idVendor)
 1091+ for dev in devs:
 1092+ if dev.idProduct & self.idProductMask == self.idProduct:
 1093+ self.dev = dev
 1094+ break
10881095 if self.dev is None:
10891096 raise DeviceNotFoundError()
10901097 self.logger.debug("Device found!\n")