diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-02-07 17:13:15 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-03-13 11:29:41 -0500 |
commit | babde17c4c804e0a0903481a8f05d713eeabdc3e (patch) | |
tree | 474ab66d27bb92cdc3c53e8543a7e0f46484a183 /klippy | |
parent | a20f4a8759563737eb14e1047416ab049ba35b06 (diff) | |
download | kutter-babde17c4c804e0a0903481a8f05d713eeabdc3e.tar.gz kutter-babde17c4c804e0a0903481a8f05d713eeabdc3e.tar.xz kutter-babde17c4c804e0a0903481a8f05d713eeabdc3e.zip |
console: Add support for connecting via CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rwxr-xr-x | klippy/console.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/klippy/console.py b/klippy/console.py index bacca30d..a9200149 100755 --- a/klippy/console.py +++ b/klippy/console.py @@ -30,9 +30,11 @@ help_txt = """ re_eval = re.compile(r'\{(?P<eval>[^}]*)\}') class KeyboardReader: - def __init__(self, reactor, serialport, baud): + def __init__(self, reactor, serialport, baud, canbus_iface, canbus_nodeid): self.serialport = serialport self.baud = baud + self.canbus_iface = canbus_iface + self.canbus_nodeid = canbus_nodeid self.ser = serialhdl.SerialReader(reactor) self.reactor = reactor self.start_time = reactor.monotonic() @@ -54,7 +56,10 @@ class KeyboardReader: def connect(self, eventtime): self.output(help_txt) self.output("="*20 + " attempting to connect " + "="*20) - if self.baud: + if self.canbus_iface is not None: + self.ser.connect_canbus(self.serialport, self.canbus_nodeid, + self.canbus_iface) + elif self.baud: self.ser.connect_uart(self.serialport, self.baud) else: self.ser.connect_pipe(self.serialport) @@ -207,6 +212,10 @@ def main(): opts.add_option("-v", action="store_true", dest="verbose", help="enable debug messages") opts.add_option("-b", "--baud", type="int", dest="baud", help="baud rate") + opts.add_option("-c", "--canbus_iface", dest="canbus_iface", + help="Use CAN bus interface; serialdevice is the chip UUID") + opts.add_option("-i", "--canbus_nodeid", type="int", dest="canbus_nodeid", + default=64, help="The CAN nodeid to use (default 64)") options, args = opts.parse_args() if len(args) != 1: opts.error("Incorrect number of arguments") @@ -223,7 +232,8 @@ def main(): logging.basicConfig(level=debuglevel) r = reactor.Reactor() - kbd = KeyboardReader(r, serialport, baud) + kbd = KeyboardReader(r, serialport, baud, options.canbus_iface, + options.canbus_nodeid) try: r.run() except KeyboardInterrupt: |