diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-03-08 22:26:10 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-08 23:02:31 -0500 |
commit | 64407dc5d27da8fbc6b1cd6604a0e734da019b59 (patch) | |
tree | 33882dec9803e81cb21ab63c578bfde7cd591973 /klippy/serialhdl.py | |
parent | b0329465eccc61e704262c8a14d42aaf9897c495 (diff) | |
download | kutter-64407dc5d27da8fbc6b1cd6604a0e734da019b59.tar.gz kutter-64407dc5d27da8fbc6b1cd6604a0e734da019b59.tar.xz kutter-64407dc5d27da8fbc6b1cd6604a0e734da019b59.zip |
klippy: Support FIRMWARE_RESTART command
Add initial support for micro-controller resets via the Arduino reset
mechanism. Also, automatically attempt a firmware restart if the
printer CRC does not match.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialhdl.py')
-rw-r--r-- | klippy/serialhdl.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py index 1af64000..8112d703 100644 --- a/klippy/serialhdl.py +++ b/klippy/serialhdl.py @@ -3,7 +3,7 @@ # Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net> # # This file may be distributed under the terms of the GNU GPLv3 license. -import logging, threading +import logging, threading, time import serial import msgproto, chelper, util @@ -325,3 +325,16 @@ def stk500v2_leave(ser, reactor): res = ser.read(4096) logging.debug("Got %s from stk500v2" % (repr(res),)) ser.baudrate = origbaud + +# Attempt an arduino style reset on a serial port +def arduino_reset(serialport, reactor): + # First try opening the port at 1200 baud + ser = serial.Serial(serialport, 1200, timeout=0) + ser.read(1) + time.sleep(0.100) + # Then try toggling DTR + ser.dtr = True + time.sleep(0.100) + ser.dtr = False + time.sleep(0.100) + ser.close() |