From 64407dc5d27da8fbc6b1cd6604a0e734da019b59 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 8 Mar 2017 22:26:10 -0500 Subject: 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 --- klippy/serialhdl.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'klippy/serialhdl.py') 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 # # 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() -- cgit v1.2.3-70-g09d2