Skip to content

Commit

Permalink
Merge branch 'master' into fix-license-typo
Browse files Browse the repository at this point in the history
  • Loading branch information
TojikCZ authored Nov 22, 2023
2 parents 21cb171 + b97dc88 commit ccaeb01
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Add a way to download logs even on systemd journal based systems
* Bump the API version so it is the same as the xBuddy reported one
* Support the new multi-level telemetry data structure
* Don't send over serial when temperature calibration is running

0.7.1rc1 (2023-08-10)
* Fixed HTTP response status on HEAD request for non-existing files
Expand Down
14 changes: 14 additions & 0 deletions prusa/link/printer_adapter/prusa_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
PAUSE_PRINT_REGEX,
PRINTER_BOOT_REGEX,
RESUME_PRINT_REGEX,
TM_CAL_END_REGEX,
TM_CAL_START_REGEX,
TM_ERROR_LOG_REGEX,
)
from .telemetry_passer import TelemetryPasser
Expand Down Expand Up @@ -225,6 +227,10 @@ def __init__(self, cfg: Config, settings: Settings) -> None:
self.serial_parser.add_decoupled_handler(
MBL_TRIGGER_REGEX,
lambda sender, match: self.printer_polling.invalidate_mbl())
self.serial_parser.add_decoupled_handler(
TM_CAL_START_REGEX, self.block_serial_queue)
self.serial_parser.add_decoupled_handler(
TM_CAL_END_REGEX, self.unblock_serial_queue)

self.print_stat_doubler = PrintStatDoubler(self.serial_parser,
self.printer_polling)
Expand Down Expand Up @@ -796,6 +802,14 @@ def instruction_confirmed(self, _) -> None:
"""
self.state_manager.instruction_confirmed()

def block_serial_queue(self, *_, **__) -> None:
"""Blocks the serial queue"""
self.serial_queue.block_sending()

def unblock_serial_queue(self, *_, **__) -> None:
"""Unblocks the serial queue"""
self.serial_queue.unblock_sending()

def printer_reconnected(self, *_, **__) -> None:
"""
Connects the printer reconnect (reset) to many other components.
Expand Down
4 changes: 4 additions & 0 deletions prusa/link/printer_adapter/structures/regular_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@
TM_ERROR_CLEARED = re.compile(r"^TM: error cleared$")

URLS_FOR_WIZARD = re.compile(r"/(\d{1,3})?/?")

TM_CAL_START_REGEX = re.compile(r"^TM: calibration start$")
TM_CAL_END_REGEX = re.compile(r"^(TM: calibr\. failed!)|"
r"(Thermal Model settings:)$")
16 changes: 16 additions & 0 deletions prusa/link/serial/serial_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def __init__(self,
self.m110_workaround_slot = None
self.worked_around_m110 = False

# Allows to temporarily block sending to the serial queue
self._block_sending = False

self.serial_parser.add_handler(CONFIRMATION_REGEX,
self._confirmation_handler,
priority=float("inf"))
Expand All @@ -131,6 +134,8 @@ def _keep_sending(self):
if self.quit_evt.is_set():
break
self.send_event.clear()
if self._block_sending:
continue
with self.write_lock:
if not self.can_write():
continue
Expand All @@ -141,6 +146,16 @@ def _keep_sending(self):
"reader to fix the problem. In the meantime "
"waiting for a nudge to send again.")

def block_sending(self):
"""Block sending of instructions until we unblock again"""
self._block_sending = True

def unblock_sending(self):
"""Unblock sending of instructions"""
if self._block_sending:
self._block_sending = False
self._try_writing()

def _try_writing(self):
"""
Nudge the sender thread to send an instruction
Expand Down Expand Up @@ -550,6 +565,7 @@ def _printer_reconnected(self, was_printing):
prctl_name()
with self.write_lock:
self._flush_queues()
self._block_sending = False

final_instruction = None

Expand Down

0 comments on commit ccaeb01

Please sign in to comment.