From 3c6eb376ac75b7820810f709f14d5d48257e1d45 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 7 Feb 2021 14:20:47 -0500 Subject: console: Make baud an optional parameter Make the baud rate an optional parameter to the console.py tool. When not present, it will default to 250000. Signed-off-by: Kevin O'Connor --- klippy/console.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'klippy/console.py') diff --git a/klippy/console.py b/klippy/console.py index ab501d9a..bbf5377d 100755 --- a/klippy/console.py +++ b/klippy/console.py @@ -202,11 +202,18 @@ class KeyboardReader: self.data = kbdlines[-1] def main(): - usage = "%prog [options] " + usage = "%prog [options] " opts = optparse.OptionParser(usage) + opts.add_option("-b", "--baud", type="int", dest="baud", help="baud rate") options, args = opts.parse_args() - serialport, baud = args - baud = int(baud) + if len(args) != 1: + opts.error("Incorrect number of arguments") + serialport = args[0] + + baud = options.baud + if baud is None and not (serialport.startswith("/dev/rpmsg_") + or serialport.startswith("/tmp/")): + baud = 250000 logging.basicConfig(level=logging.DEBUG) r = reactor.Reactor() -- cgit v1.2.3-70-g09d2