Commit 44ceb6ff authored by Guillaume Seguin's avatar Guillaume Seguin

WIP #575: improve // actions behavior in pronsole

parent 122631bc
...@@ -19,7 +19,7 @@ __version__ = "2014.08.01" ...@@ -19,7 +19,7 @@ __version__ = "2014.08.01"
from serial import Serial, SerialException, PARITY_ODD, PARITY_NONE from serial import Serial, SerialException, PARITY_ODD, PARITY_NONE
from select import error as SelectError from select import error as SelectError
from threading import Thread, Lock import threading
from Queue import Queue, Empty as QueueEmpty from Queue import Queue, Empty as QueueEmpty
import time import time
import platform import platform
...@@ -44,7 +44,7 @@ def locked(f): ...@@ -44,7 +44,7 @@ def locked(f):
def inner(*args, **kw): def inner(*args, **kw):
with inner.lock: with inner.lock:
return f(*args, **kw) return f(*args, **kw)
inner.lock = Lock() inner.lock = threading.Lock()
return inner return inner
def control_ttyhup(port, disable_hup): def control_ttyhup(port, disable_hup):
...@@ -126,6 +126,7 @@ class printcore(): ...@@ -126,6 +126,7 @@ class printcore():
if self.printer: if self.printer:
if self.read_thread: if self.read_thread:
self.stop_read_thread = True self.stop_read_thread = True
if threading.current_thread() != self.read_thread:
self.read_thread.join() self.read_thread.join()
self.read_thread = None self.read_thread = None
if self.print_thread: if self.print_thread:
...@@ -205,7 +206,7 @@ class printcore(): ...@@ -205,7 +206,7 @@ class printcore():
self.printer = None self.printer = None
return return
self.stop_read_thread = False self.stop_read_thread = False
self.read_thread = Thread(target = self._listen) self.read_thread = threading.Thread(target = self._listen)
self.read_thread.start() self.read_thread.start()
self._start_sender() self._start_sender()
...@@ -328,7 +329,7 @@ class printcore(): ...@@ -328,7 +329,7 @@ class printcore():
def _start_sender(self): def _start_sender(self):
self.stop_send_thread = False self.stop_send_thread = False
self.send_thread = Thread(target = self._sender) self.send_thread = threading.Thread(target = self._sender)
self.send_thread.start() self.send_thread.start()
def _stop_sender(self): def _stop_sender(self):
...@@ -371,7 +372,7 @@ class printcore(): ...@@ -371,7 +372,7 @@ class printcore():
return True return True
self.clear = False self.clear = False
resuming = (startindex != 0) resuming = (startindex != 0)
self.print_thread = Thread(target = self._print, self.print_thread = threading.Thread(target = self._print,
kwargs = {"resuming": resuming}) kwargs = {"resuming": resuming})
self.print_thread.start() self.print_thread.start()
return True return True
...@@ -451,7 +452,7 @@ class printcore(): ...@@ -451,7 +452,7 @@ class printcore():
self.paused = False self.paused = False
self.printing = True self.printing = True
self.print_thread = Thread(target = self._print, self.print_thread = threading.Thread(target = self._print,
kwargs = {"resuming": True}) kwargs = {"resuming": True})
self.print_thread.start() self.print_thread.start()
......
...@@ -1233,12 +1233,18 @@ class pronsole(cmd.Cmd): ...@@ -1233,12 +1233,18 @@ class pronsole(cmd.Cmd):
command = command[1] command = command[1]
if command == "pause": if command == "pause":
self.do_pause(None) self.do_pause(None)
sys.stdout.write(self.promptf())
sys.stdout.flush()
return True return True
elif command == "resume": elif command == "resume":
self.do_resume(None) self.do_resume(None)
sys.stdout.write(self.promptf())
sys.stdout.flush()
return True return True
elif command == "disconnect": elif command == "disconnect":
self.do_disconnect(None) self.do_disconnect(None)
sys.stdout.write(self.promptf())
sys.stdout.flush()
return True return True
return False return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment