Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usb printing debug improvements #16144

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions plugins/USBPrinting/AutoDetectBaudJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, serial_port: int) -> None:
self._all_baud_rates = [115200, 250000, 500000, 230400, 76800, 57600, 38400, 19200, 9600]

def run(self) -> None:
Logger.log("d", "Auto detect baud rate started.")
Logger.debug(f"Auto detect baud rate started for {self._serial_port}")
wait_response_timeouts = [3, 15, 30]
wait_bootloader_times = [1.5, 5, 15]
write_timeout = 3
Expand All @@ -46,8 +46,7 @@ def run(self) -> None:
wait_bootloader = wait_bootloader_times[retry]
else:
wait_bootloader = wait_bootloader_times[-1]
Logger.log("d", "Checking {serial} if baud rate {baud_rate} works. Retry nr: {retry}. Wait timeout: {timeout}".format(
serial = self._serial_port, baud_rate = baud_rate, retry = retry, timeout = wait_response_timeout))
Logger.debug(f"Checking {self._serial_port} if baud rate {baud_rate} works. Retry nr: {retry}. Wait timeout: {wait_response_timeout}")

if serial is None:
try:
Expand All @@ -61,7 +60,9 @@ def run(self) -> None:
serial.baudrate = baud_rate
except ValueError:
continue
sleep(wait_bootloader) # Ensure that we are not talking to the boot loader. 1.5 seconds seems to be the magic number

# Ensure that we are not talking to the boot loader. 1.5 seconds seems to be the magic number
sleep(wait_bootloader)

serial.write(b"\n") # Ensure we clear out previous responses
serial.write(b"M105\n")
Expand All @@ -83,4 +84,5 @@ def run(self) -> None:

serial.write(b"M105\n")
sleep(15) # Give the printer some time to init and try again.
Logger.debug(f"Unable to find a working baudrate for {serial}")
self.setResult(None) # Unable to detect the correct baudrate.