From a02cee9d1ef4b6837e34df876b6405a901229a50 Mon Sep 17 00:00:00 2001 From: Terry Guo Date: Fri, 16 Aug 2013 11:18:06 +0800 Subject: [PATCH] A better way to find and save mbed hid devices --- .../debugger/pyOCD/interface/pywinusb_backend.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/workspace_tools/debugger/pyOCD/interface/pywinusb_backend.py b/workspace_tools/debugger/pyOCD/interface/pywinusb_backend.py index 1be33ad3a1f..90689039dd2 100644 --- a/workspace_tools/debugger/pyOCD/interface/pywinusb_backend.py +++ b/workspace_tools/debugger/pyOCD/interface/pywinusb_backend.py @@ -57,17 +57,18 @@ def getAllConnectedInterface(vid, pid): """ all_devices = hid.find_all_hid_devices() - # keep devices with good vid/pid + # find devices with good vid/pid + all_mbed_devices = [] for d in all_devices: - if (d.vendor_id != vid) or (d.product_id != pid): - all_devices.remove(d) + if (d.vendor_id == vid) and (d.product_id == pid): + all_mbed_devices.append(d) - if not all_devices: + if not all_mbed_devices: logging.debug("No Mbed device connected") return boards = [] - for dev in all_devices: + for dev in all_mbed_devices: try: dev.open() report = dev.find_output_reports()