This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b359b11c5e arch/sim: Drain all host CAN frames per RX work cycle.
2b359b11c5e is described below

commit 2b359b11c5e3fa09ea5621d5e4722ee0382fddc5
Author: raiden00pl <[email protected]>
AuthorDate: Wed Oct 7 10:23:18 2026 +0200

    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 <[email protected]>
---
 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 */
 

Reply via email to