aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/serialhdl.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-08 10:29:59 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-15 15:15:52 -0400
commitc9b44b5bb6ad1ef293f5f03c6a22ce44a6f82dce (patch)
treeb03669c75a5cbd355c6b58d46d93e921a0db16e8 /klippy/serialhdl.py
parent2255176228effc67e868ca343f7354da2b7f4081 (diff)
downloadkutter-c9b44b5bb6ad1ef293f5f03c6a22ce44a6f82dce.tar.gz
kutter-c9b44b5bb6ad1ef293f5f03c6a22ce44a6f82dce.tar.xz
kutter-c9b44b5bb6ad1ef293f5f03c6a22ce44a6f82dce.zip
serialhdl: Support working with pseudo serial devices
Support working with devices that aren't really serial ports and thus do not have a baud rate. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialhdl.py')
-rw-r--r--klippy/serialhdl.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py
index 35e2a135..85e3b80e 100644
--- a/klippy/serialhdl.py
+++ b/klippy/serialhdl.py
@@ -64,12 +64,17 @@ class SerialReader:
while 1:
starttime = self.reactor.monotonic()
try:
- self.ser = serial.Serial(self.serialport, self.baud, timeout=0)
+ if self.baud:
+ self.ser = serial.Serial(
+ self.serialport, self.baud, timeout=0)
+ else:
+ self.ser = open(self.serialport, 'rb+')
except (OSError, serial.SerialException), e:
logging.warn("Unable to open port: %s" % (e,))
self.reactor.pause(starttime + 5.)
continue
- stk500v2_leave(self.ser, self.reactor)
+ if self.baud:
+ stk500v2_leave(self.ser, self.reactor)
self.serialqueue = self.ffi_lib.serialqueue_alloc(
self.ser.fileno(), 0)
self.background_thread = threading.Thread(target=self._bg_thread)