Skip to content

Commit

Permalink
Add flash command to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman committed Jul 19, 2022
1 parent 32c8019 commit 80f24c9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pslab/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import List, Tuple

import numpy as np
import mcbootflash

import pslab
import pslab.protocol as CP
Expand Down Expand Up @@ -232,6 +233,10 @@ def main(args: argparse.Namespace):
install(args)
return

if args.function == "flash":
flash(args)
return

handler = SerialHandler(port=args.port)

if args.function == "collect":
Expand Down Expand Up @@ -465,6 +470,7 @@ def cmdline(args: List[str] = None):
add_wave_args(subparser)
add_pwm_args(subparser)
add_install_args(subparser)
add_flash_args(subparser)
main(parser.parse_args(args))


Expand Down Expand Up @@ -516,3 +522,29 @@ def add_install_args(subparser: argparse._SubParsersAction):
default=False,
help="Overwrite existing udev rule.",
)


def flash(args: argparse.Namespace):
"""Flash firmware over USB.
Parameters
----------
args : :class:`argparse.Namespace`
Parsed arguments.
"""
mcbootflash.flash(args)


def add_flash_args(subparser: argparse._SubParsersAction):
"""Add arguments for flash function to ArgumentParser.
Parameters
----------
subparser : :class:`argparse._SubParsersAction`
SubParser to add other arguments related to flash function.
"""
parser = mcbootflash.get_parser()
parser.prog = "pslab"
parser.usage = "Flash firmware to PSLab v6."
parser.add_argument("-b", "--baudrate", default=460800, help=argparse.SUPPRESS)
subparser.add_parser("flash", parents=[parser], add_help=False)

0 comments on commit 80f24c9

Please sign in to comment.