summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2018-07-02 18:44:50 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-07-06 18:48:32 -0700
commit7d26ae49bffcf269df82df7d0fee00e8c3341166 (patch)
tree31bc6a099279595fd0b3d90943a91233cbc85b38 /extra
parent66b400fa25992943f1278426b54f3109fb033407 (diff)
downloadchrome-ec-7d26ae49bffcf269df82df7d0fee00e8c3341166.tar.gz
ec-devutils: update pyusb to 1.0.2
Pyusb interface has changed yet again. Patch calls to get_string and usb.core.find. Modify ordering of detetch kernel driver and avoid rereferencing endpoints. BRANCH=None BUG=b:110907544 TEST=emerge ec-devutils, run powerlog, usb_console, servo_updater CQ-DEPEND=CL:1119632 Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I33df474ce3bb57d2e11c9f384ac013b51d210843 Reviewed-on: https://chromium-review.googlesource.com/1125354 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r--extra/tigertool/ecusb/stm32uart.py1
-rw-r--r--extra/tigertool/ecusb/stm32usb.py25
-rwxr-xr-xextra/usb_power/powerlog.py3
-rwxr-xr-xextra/usb_serial/console.py3
-rwxr-xr-xextra/usb_updater/fw_update.py5
5 files changed, 24 insertions, 13 deletions
diff --git a/extra/tigertool/ecusb/stm32uart.py b/extra/tigertool/ecusb/stm32uart.py
index 459ca8e90f..21fcbd2cc2 100644
--- a/extra/tigertool/ecusb/stm32uart.py
+++ b/extra/tigertool/ecusb/stm32uart.py
@@ -73,6 +73,7 @@ class Suart(object):
if self._tx_thread:
self._tx_thread.join(2)
self._tx_thread = None
+ self._susb.close()
def run_rx_thread(self):
"""Background loop to pass data from USB to pty."""
diff --git a/extra/tigertool/ecusb/stm32usb.py b/extra/tigertool/ecusb/stm32usb.py
index b8ffb2765e..3d3627e8ab 100644
--- a/extra/tigertool/ecusb/stm32usb.py
+++ b/extra/tigertool/ecusb/stm32usb.py
@@ -57,8 +57,10 @@ class Susb(object):
def _find_device(self):
"""Set up the usb endpoint"""
# Find the stm32.
- dev_list = usb.core.find(idVendor=self._vendor, idProduct=self._product,
+ dev_g = usb.core.find(idVendor=self._vendor, idProduct=self._product,
find_all=True)
+ dev_list = list(dev_g)
+
if not dev_list:
raise SusbError('USB device not found')
@@ -66,7 +68,7 @@ class Susb(object):
dev = None
if self._serialname:
for d in dev_list:
- dev_serial = usb.util.get_string(d, 256, d.iSerialNumber)
+ dev_serial = usb.util.get_string(d, d.iSerialNumber)
if dev_serial == self._serialname:
dev = d
break
@@ -79,12 +81,20 @@ class Susb(object):
raise SusbError('USB device %04x:%04x not found' % (
self._vendor, self._product))
+ # Detach raiden.ko if it is loaded. CCD endpoints support either a kernel
+ # module driver that produces a ttyUSB, or direct endpoint access, but
+ # can't do both at the same time.
+ if dev.is_kernel_driver_active(self._interface) is True:
+ dev.detach_kernel_driver(self._interface)
+
# If we can't set configuration, it's already been set.
try:
dev.set_configuration()
- except usb.core.USBError:
+ except usb.core.USBError as e:
pass
+ self._dev = dev
+
# Get an endpoint instance.
cfg = dev.get_active_configuration()
intf = usb.util.find_descriptor(cfg, bInterfaceNumber=self._interface)
@@ -93,12 +103,6 @@ class Susb(object):
raise SusbError('Interface %04x:%04x - 0x%x not found' % (
self._vendor, self._product, self._interface))
- # Detach raiden.ko if it is loaded. CCD endpoints support either a kernel
- # module driver that produces a ttyUSB, or direct endpoint access, but
- # can't do both at the same time.
- if dev.is_kernel_driver_active(intf.bInterfaceNumber) is True:
- dev.detach_kernel_driver(intf.bInterfaceNumber)
-
read_ep_number = intf.bInterfaceNumber + self.READ_ENDPOINT
read_ep = usb.util.find_descriptor(intf, bEndpointAddress=read_ep_number)
self._read_ep = read_ep
@@ -106,3 +110,6 @@ class Susb(object):
write_ep_number = intf.bInterfaceNumber + self.WRITE_ENDPOINT
write_ep = usb.util.find_descriptor(intf, bEndpointAddress=write_ep_number)
self._write_ep = write_ep
+
+ def close(self):
+ usb.util.dispose_resources(self._dev)
diff --git a/extra/usb_power/powerlog.py b/extra/usb_power/powerlog.py
index 82950100f2..a8fcae9c9d 100755
--- a/extra/usb_power/powerlog.py
+++ b/extra/usb_power/powerlog.py
@@ -159,7 +159,8 @@ class Spower(object):
self._board = board
# Find the stm32.
- dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_list = list(dev_g)
if dev_list is None:
raise Exception("Power", "USB device not found")
diff --git a/extra/usb_serial/console.py b/extra/usb_serial/console.py
index 2494c59c79..e3288b8593 100755
--- a/extra/usb_serial/console.py
+++ b/extra/usb_serial/console.py
@@ -71,7 +71,8 @@ class Susb():
SusbError: An error accessing Susb object
"""
# Find the device.
- dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_list = list(dev_g)
if dev_list is None:
raise SusbError("USB device not found")
diff --git a/extra/usb_updater/fw_update.py b/extra/usb_updater/fw_update.py
index 367c0cad14..8a73070ccf 100755
--- a/extra/usb_updater/fw_update.py
+++ b/extra/usb_updater/fw_update.py
@@ -67,7 +67,8 @@ class Supdate(object):
vendor = self._brdcfg['vid']
product = self._brdcfg['pid']
- dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
+ dev_list = list(dev_g)
if dev_list is None:
raise Exception("Update", "USB device not found")
@@ -75,7 +76,7 @@ class Supdate(object):
dev = None
if serialname:
for d in dev_list:
- if usb.util.get_string(d, 256, d.iSerialNumber) == serialname:
+ if usb.util.get_string(d, d.iSerialNumber) == serialname:
dev = d
break
if dev is None: