From f526ec0395efa64c11f9c4c8a563f8a4d240dfb5 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Sat, 21 Mar 2026 20:23:50 +0100 Subject: [PATCH] Small changes to ensure that output during startup do not cause hangs due to no client connection when native USB is default. --- changelog.md | 8 ++++++++ grbl.h | 2 +- report.c | 36 ++++++++++++++++++------------------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/changelog.md b/changelog.md index 7d10035..d429597 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ ## grblHAL changelog +Build 20260321 + +Core: + +* Small changes to ensure that output during startup do not cause hangs due to no client connection when native USB is default. + +--- + Build 20260320 Core: diff --git a/grbl.h b/grbl.h index 8e6150a..387592e 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20260320 +#define GRBL_BUILD 20260321 #define GRBL_URL "https://github.com/grblHAL" diff --git a/report.c b/report.c index 57a1a1a..2a2367d 100644 --- a/report.c +++ b/report.c @@ -210,30 +210,28 @@ FLASHMEM void report_init (void) // operation. Errors events can originate from the g-code parser, settings module, or asynchronously // from a critical error, such as a triggered hard limit. Interface should always monitor for these // responses. -FLASHMEM static status_code_t report_status_message (status_code_t status_code) +FLASHMEM static status_code_t report_status_message (status_code_t status) { - switch(status_code) { + if(status == Status_Handled) + status = Status_OK; - case Status_Handled: - status_code = Status_OK; - // no break - case Status_OK: // STATUS_OK + if(hal.stream.is_connected()) { + if(status == Status_OK) hal.stream.write("ok" ASCII_EOL); - break; - - default: - hal.stream.write(appendbuf(3, "error:", uitoa((uint32_t)status_code), ASCII_EOL)); - break; + else + hal.stream.write(appendbuf(3, "error:", uitoa((uint32_t)status), ASCII_EOL)); } - return status_code; + return status; } // Prints alarm messages. FLASHMEM static alarm_code_t report_alarm_message (alarm_code_t alarm_code) { - hal.stream.write_all(appendbuf(3, "ALARM:", uitoa((uint32_t)alarm_code), ASCII_EOL)); - hal.delay_ms(100, NULL); // Force delay to ensure message clears output stream buffer. + if(hal.stream.is_connected()) { + hal.stream.write_all(appendbuf(3, "ALARM:", uitoa((uint32_t)alarm_code), ASCII_EOL)); + hal.delay_ms(100, NULL); // Force delay to ensure message clears output stream buffer. + } return alarm_code; } @@ -856,10 +854,12 @@ FLASHMEM void report_startup_line (uint8_t n, char *line) FLASHMEM void report_execute_startup_message (char *line, status_code_t status_code) { - hal.stream.write(">"); - hal.stream.write(line); - hal.stream.write(":"); - grbl.report.status_message(status_code); + if(hal.stream.is_connected()) { + hal.stream.write(">"); + hal.stream.write(line); + hal.stream.write(":"); + grbl.report.status_message(status_code); + } } // Prints build info line