Skip to content

Commit

Permalink
__main__.py implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
o-murphy committed Apr 29, 2024
1 parent 11c0571 commit fcc40cc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,45 @@ but also can work on each platform where **[PyUsb](https://github.com/construct/
# install a specific version (e.g. 0.0.1b1)
python -m pip install pydfuutil==0.0.1b1

## Usage
Run pydfuutil -h to got commandline options list
```Bash
pydfuutil -h python -m
# or
python -m pydfuutil -h

####### usage:
usage: pydfuutil [-h] [-V] [-v] [-l] [-e] [-d VID:PID] [-p BUS-PORT] [-c CONFIG_NR] [-i INTF_NR] [-a ALT] [-t SIZE] [-U FILE] [-D FILE] [-R] [-s ADDRESS]

Python implementation of DFU-Util tools

options:
-h, --help show this help message and exit
-V, --version Print the version number
-v, --verbose Print verbose debug statements
-l, --list List the currently attached DFU capable USB devices
-e, --detach Detach the currently attached DFU capable USB devices
-d VID:PID, --device VID:PID
Specify Vendor/Product ID of DFU device
-p BUS-PORT, --path BUS-PORT
Specify path to DFU device
-c CONFIG_NR, --cfg CONFIG_NR
Specify the Configuration of DFU device
-i INTF_NR, --intf INTF_NR
Specify the DFU Interface number
-a ALT, --alt ALT Specify the Altsetting of the DFU Interface
-t SIZE, --transfer-size SIZE
Specify the number of bytes per USB Transfer
-U FILE, --upload FILE
Read firmware from device into <file>
-D FILE, --download FILE
Write firmware from <file> into device
-R, --reset Issue USB Reset signalling once we're finished
-s ADDRESS, --dfuse-address ADDRESS
ST DfuSe mode, specify target address for raw file download or upload. Not applicable for DfuSe file (.dfu) downloads
```
## Todos
Expand Down
11 changes: 7 additions & 4 deletions pydfuutil/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ def main() -> None:
global VERBOSE

# Create argument parser
parser = argparse.ArgumentParser(description="Description of your program")
parser = argparse.ArgumentParser(
prog="pydfuutil",
description="Python implementation of DFU-Util tools"
)

# Add arguments
parser.add_argument("-V", "--version", action="version", version=VERSION,
Expand Down Expand Up @@ -621,7 +624,7 @@ def main() -> None:
help="Write firmware from <file> into device")
parser.add_argument("-R", "--reset", action="store_true",
help="Issue USB Reset signalling once we're finished")
parser.add_argument("-s", "--dfuse", metavar="ADDRESS",
parser.add_argument("-s", "--dfuse-address", metavar="ADDRESS",
help="ST DfuSe mode, specify target address "
"for raw file download or upload. "
"Not applicable for DfuSe file (.dfu) downloads")
Expand Down Expand Up @@ -694,8 +697,8 @@ def main() -> None:
if args.reset:
final_reset = 1

if args.dfuse:
dfuse_options = args.dfuse
if args.dfuse_address:
dfuse_options = args.dfuse_address

print(VERSION)

Expand Down

0 comments on commit fcc40cc

Please sign in to comment.