aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-02-07 14:20:47 -0500
committerKevin O'Connor <kevin@koconnor.net>2021-03-02 11:38:50 -0500
commit3c6eb376ac75b7820810f709f14d5d48257e1d45 (patch)
tree1e5387e8e12cc2ec76e7b03f681b40fe797e6a19 /klippy
parent9d3a3f3f306af5f1fbd39e537e10392f03f5b27d (diff)
downloadkutter-3c6eb376ac75b7820810f709f14d5d48257e1d45.tar.gz
kutter-3c6eb376ac75b7820810f709f14d5d48257e1d45.tar.xz
kutter-3c6eb376ac75b7820810f709f14d5d48257e1d45.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rwxr-xr-xklippy/console.py13
1 files changed, 10 insertions, 3 deletions
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] <serialdevice> <baud>"
+ usage = "%prog [options] <serialdevice>"
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()