From 4c2f5863c8f6fe8f9eb9eb2c221488e9e8d3d0bd Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:07:39 +1100 Subject: [PATCH] raster: do not show a running raster as disabled mid-cycle The function cleared enabled at the top of every cycle and set it again in the RUN state, so a non-realtime reader polling the pin could see 0 while the raster ran. After stop() it then saw 0 before the function had handled the stop, wrote the next program header, and the stop's hal_port_clear() wiped it; the next start read pixel data as the header and faulted with InvalidBPP. Write enabled once per state instead, and only clear it once a stop has been handled. Found by Hannes Diethelm's parallel test runs (#4669). A 2ms delay after the old clear fails tests/raster 2 of 3; with this change it passes. --- src/hal/components/raster.comp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hal/components/raster.comp b/src/hal/components/raster.comp index e89a71cbe86..427453e5bd4 100644 --- a/src/hal/components/raster.comp +++ b/src/hal/components/raster.comp @@ -193,16 +193,21 @@ static bool read_pixel_data(const hal_port_t port, int bits_per_pixel, hal_real_ FUNCTION(_) { output_set(-1.0); - enabled_set(0); + // enabled is written once per state, never cleared at the top: a + // non-realtime reader polls it while this runs and must not see a + // running raster as stopped if (reset) { + enabled_set(0); state_set(IDLE); fault_set(0); fault_code_set(ERROR_NONE); hal_port_clear(program_ptr); } else if (state == FAULT) { + enabled_set(0); fault_set(1); } else if (state == IDLE) { + enabled_set(0); bitmap_position_set(0.0); current_pixel_value_set(-1.0); previous_pixel_value_set(-1.0); @@ -237,6 +242,7 @@ FUNCTION(_) { if(!run) { state_set(IDLE); hal_port_clear(program_ptr); + enabled_set(0); } else { enabled_set(1); @@ -246,6 +252,7 @@ FUNCTION(_) { previous_pixel_value_set(current_pixel_value); if(!read_pixel_data(program_ptr, bpp, current_pixel_value_ptr)) { + enabled_set(0); state_set(FAULT); fault_code_set(ERROR_BADPIXELDATA); return;