summaryrefslogtreecommitdiff
path: root/tools/pydfu.py
diff options
context:
space:
mode:
authorTobias Thyrrestrup <tt@LEGO.com>2021-05-18 15:38:49 +0200
committerDamien George <damien@micropython.org>2021-05-21 15:39:40 +1000
commit247d7e2e8e7ec262a141b0fc4190a94cce8103ef (patch)
treed8ab2a8267f171d80c7720c51d4c8563ec86c7c8 /tools/pydfu.py
parentea81bcf1c0ddeb8be34192cbededecfa425c039b (diff)
tools/pydfu.py: Remove default VID/PID values.
As the new default behaviour, this allows PyDFU to be used with all devices, not just the ones matching a specific set of VID/PID values. But it's still possible to specify VID/PID if needed to narrow down the selection of the USB device. Signed-off-by: Tobias Thyrrestrup <tt@LEGO.com>
Diffstat (limited to 'tools/pydfu.py')
-rwxr-xr-xtools/pydfu.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/tools/pydfu.py b/tools/pydfu.py
index 42b4fa2da..ea658d300 100755
--- a/tools/pydfu.py
+++ b/tools/pydfu.py
@@ -23,10 +23,6 @@ import usb.core
import usb.util
import zlib
-# VID/PID
-__VID = 0x0483
-__PID = 0xDF11
-
# USB request __TIMEOUT
__TIMEOUT = 4000
@@ -112,10 +108,10 @@ def find_dfu_cfg_descr(descr):
return None
-def init():
+def init(**kwargs):
"""Initializes the found DFU device so that we can program it."""
global __dev, __cfg_descr
- devices = get_dfu_devices(idVendor=__VID, idProduct=__PID)
+ devices = get_dfu_devices(**kwargs)
if not devices:
raise ValueError("No DFU device found")
if len(devices) > 1:
@@ -565,15 +561,13 @@ def cli_progress(addr, offset, size):
def main():
"""Test program for verifying this files functionality."""
global __verbose
- global __VID
- global __PID
# Parse CMD args
parser = argparse.ArgumentParser(description="DFU Python Util")
parser.add_argument(
"-l", "--list", help="list available DFU devices", action="store_true", default=False
)
- parser.add_argument("--vid", help="USB Vendor ID", type=lambda x: int(x, 0), default=__VID)
- parser.add_argument("--pid", help="USB Product ID", type=lambda x: int(x, 0), default=__PID)
+ parser.add_argument("--vid", help="USB Vendor ID", type=lambda x: int(x, 0), default=None)
+ parser.add_argument("--pid", help="USB Product ID", type=lambda x: int(x, 0), default=None)
parser.add_argument(
"-m", "--mass-erase", help="mass erase device", action="store_true", default=False
)
@@ -588,14 +582,18 @@ def main():
__verbose = args.verbose
- __VID = args.vid
- __PID = args.pid
+ kwargs = {}
+ if args.vid:
+ kwargs["idVendor"] = args.vid
+
+ if args.pid:
+ kwargs["idProduct"] = args.pid
if args.list:
- list_dfu_devices(idVendor=__VID, idProduct=__PID)
+ list_dfu_devices(**kwargs)
return
- init()
+ init(**kwargs)
command_run = False
if args.mass_erase: