From 2b359b11c5e3fa09ea5621d5e4722ee0382fddc5 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Wed, 7 Oct 2026 10:23:18 +0200 Subject: [PATCH] arch/sim: Drain all host CAN frames per RX work cycle. sim_can_work() in sim_cansock.c and sim_canchar.c read a single frame from the host socket and requeued itself after SIM_CAN_WORK_DELAY (USEC2TICK(1000), one 10 ms tick with the default sim tick), capping RX at about 100 frames/s. A burst from the bus was then delivered over hundreds of milliseconds, and frames from an earlier burst reached sockets opened later. Loop while frames are available. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: raiden00pl --- arch/sim/src/sim/sim_canchar.c | 6 +++++- arch/sim/src/sim/sim_cansock.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/sim/src/sim/sim_canchar.c b/arch/sim/src/sim/sim_canchar.c index 37c927f51e5..572922a0cba 100644 --- a/arch/sim/src/sim/sim_canchar.c +++ b/arch/sim/src/sim/sim_canchar.c @@ -292,7 +292,11 @@ static void sim_can_work(void *arg) struct can_hdr_s hdr; int ret; - if (host_can_avail(&priv->host)) + /* Drain all frames queued on the host socket, otherwise only one frame + * is delivered per work period and the RX path lags behind the bus. + */ + + while (host_can_avail(&priv->host)) { /* Wait for data from host stack */ diff --git a/arch/sim/src/sim/sim_cansock.c b/arch/sim/src/sim/sim_cansock.c index b89ae67e11a..f7e2375f0b1 100644 --- a/arch/sim/src/sim/sim_cansock.c +++ b/arch/sim/src/sim/sim_cansock.c @@ -174,7 +174,11 @@ static void sim_can_work(void *arg) struct canfd_frame hframe; int ret; - if (host_can_avail(&priv->host)) + /* Drain all frames queued on the host socket, otherwise only one frame + * is delivered per work period and the RX path lags behind the bus. + */ + + while (host_can_avail(&priv->host)) { /* Wait for data from host stack */