This is an automated email from the ASF dual-hosted git repository.
acassis 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 e4ed6156ca2 arch/sim: fix incomplete HCI socket data reading in
simulator interrupt handler
e4ed6156ca2 is described below
commit e4ed6156ca215b58f73e961aefe29f8edf752d23
Author: fangzhenwei <[email protected]>
AuthorDate: Thu Feb 26 17:41:05 2026 +0800
arch/sim: fix incomplete HCI socket data reading in simulator interrupt
handler
The sim_bthcisock_interrupt() handler for Bluetooth HCI sockets in the
simulatorwas using
an if statement to check for available data on the HCI socket. Thismeant
that only a single
packet would be read and processed per interrupt trigger,even if multiple
packets were waiting
in the socket buffer.
This led to incomplete data processing: unread packets would remain in the
bufferuntil the next
interrupt tick, causing delayed handling of Bluetooth HCI
events/commands,packet backlogs,
or missed data in high-throughput scenarios.
This fix replaces the if with a while loop to:
1. Continuously check for and read available data from the HCI socket until
no more
packets are present in the buffer.
2. Ensure all pending HCI packets are processed in a single interrupt
handler invocation.
3. Eliminate packet backlogs and reduce latency in Bluetooth HCI
communication.
The change maintains the same core data reception logic
(bthcisock_receive()) butensures it runs
for all available packets, improving the reliability and responsivenessof
the simulator's Bluetooth HCI socket implementation.
Signed-off-by: chao an <[email protected]>
---
arch/sim/src/sim/sim_hcisocket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sim/src/sim/sim_hcisocket.c b/arch/sim/src/sim/sim_hcisocket.c
index a827cfefc83..5774458c703 100644
--- a/arch/sim/src/sim/sim_hcisocket.c
+++ b/arch/sim/src/sim/sim_hcisocket.c
@@ -268,7 +268,7 @@ static void sim_bthcisock_interrupt(wdparm_t arg)
{
struct bthcisock_s *dev = (struct bthcisock_s *)arg;
- if (host_bthcisock_avail(dev->fd))
+ while (host_bthcisock_avail(dev->fd))
{
bthcisock_receive(&dev->drv);
}