Improve simulator serial port performance

Report here problems in any of ChibiOS components. This forum is NOT for support.
jpa
Posts: 6
Joined: Mon May 14, 2012 3:13 pm
Been thanked: 2 times

Improve simulator serial port performance

Postby jpa » Mon Jan 29, 2024 5:09 pm

The simulator serial port to TCP/IP connection is very useful for automated testing.
However, it is slow - in current ChibiOS code I get about 6 kB/s.
The patch below is a simple modification that handles serial interrupts in loop until the buffer is fully processed.
Operating system will usually combine the multiple 1-byte writes into a single TCP packet.
With the patch and 256 byte serial buffer size I get 300 kB/s transfer speed.

Code: Select all

diff --git a/os/hal/ports/simulator/posix/hal_lld.c b/os/hal/ports/simulator/posix/hal_lld.c
index 29eb30659..71fb82011 100755
--- a/os/hal/ports/simulator/posix/hal_lld.c
+++ b/os/hal/ports/simulator/posix/hal_lld.c
@@ -73,7 +73,7 @@ void _sim_check_for_interrupts(void) {
   bool int_occurred = false;
 
 #if HAL_USE_SERIAL
-  if (sd_lld_interrupt_pending()) {
+  while (sd_lld_interrupt_pending()) {
     int_occurred = true;
   }
 #endif
diff --git a/os/hal/ports/simulator/win32/hal_lld.c b/os/hal/ports/simulator/win32/hal_lld.c
index 541b0f000..c967971ba 100644
--- a/os/hal/ports/simulator/win32/hal_lld.c
+++ b/os/hal/ports/simulator/win32/hal_lld.c
@@ -79,7 +79,7 @@ void _sim_check_for_interrupts(void) {
   bool int_occurred = false;
 
 #if HAL_USE_SERIAL
-  if (sd_lld_interrupt_pending()) {
+  while (sd_lld_interrupt_pending()) {
     int_occurred = true;
   }
 #endif

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 10 guests