Added latency (in ms) to $MODBUSSTATS output.

This commit is contained in:
Terje Io
2026-03-14 21:18:52 +01:00
parent 29ea451996
commit 588e3f831d
4 changed files with 23 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
## grblHAL ##
Latest build date is 20260312, see the [changelog](changelog.md) for details.
Latest build date is 20260314, see the [changelog](changelog.md) for details.
> [!NOTE]
> A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended.

View File

@@ -1,10 +1,24 @@
## grblHAL changelog
<a name="20260314">Build 20260314
Core:
* Added latency \(in ms\) to `$MODBUSSTATS` output.
Plugins:
* Spindle, all VFDs: "hardened" code against potential hardfault.
* SD card: allow tasks to run during long file listings.
---
<a name="20260312">Build 20260312
Core:
* Added platform specific formatting strings for int32_t, "hardened" task handler code.
* Added platform specific formatting strings for `int32_t`, "hardened" task handler code.
---

2
grbl.h
View File

@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20260312
#define GRBL_BUILD 20260314
#define GRBL_URL "https://github.com/grblHAL"

View File

@@ -72,6 +72,7 @@ static int8_t stream_instance = -1;
static uint32_t rx_timeout = 0, silence_until = 0, silence_timeout;
static modbus_exception_t exception_code = ModBus_NoException;
static modbus_silence_timeout_t silence;
static uint32_t latency = 0;
static queue_entry_t queue[MODBUS_QUEUE_LENGTH];
static rtu_settings_t modbus;
static volatile bool spin_lock = false, is_blocking = false, is_up = false;
@@ -202,6 +203,8 @@ static void modbus_poll (void *data)
char *buf = (char *)((queue_entry_t *)packet)->msg.adu;
uint16_t rx_len = packet->msg.rx_length; // store original length for CRC check
latency = max(latency, modbus.rx_timeout - rx_timeout);
do {
*buf++ = stream.read();
} while(--packet->msg.rx_length);
@@ -533,13 +536,13 @@ FLASHMEM static status_code_t report_stats (sys_state_t state, char *args)
{
char buf[110];
snprintf(buf, sizeof(buf) - 1, "TX: " UINT32FMT ", retries: " UINT32FMT ", timeouts: " UINT32FMT ", RX exceptions: " UINT32FMT ", CRC errors: " UINT32FMT,
stats.tx_count, stats.retries, stats.timeouts, stats.rx_exceptions, stats.crc_errors);
snprintf(buf, sizeof(buf) - 1, "TX: " UINT32FMT ", retries: " UINT32FMT ", timeouts: " UINT32FMT ", RX exceptions: " UINT32FMT ", CRC errors: " UINT32FMT ", latency: " UINT32FMT,
stats.tx_count, stats.retries, stats.timeouts, stats.rx_exceptions, stats.crc_errors, latency);
report_message(buf, Message_Info);
if(args && (*args == 'r' || *args == 'R'))
stats.tx_count = stats.retries = stats.timeouts = stats.rx_exceptions = stats.crc_errors = 0;
stats.tx_count = stats.retries = stats.timeouts = stats.rx_exceptions = stats.crc_errors = latency = 0;
return Status_OK;
}