Skip to content

ntfc: Add optional line-buffered transport writes. - #10

Merged
acassis merged 3 commits into
apache:mainfrom
casaroli:feat/optional-line-buffering
Aug 31, 2026
Merged

ntfc: Add optional line-buffered transport writes.#10
acassis merged 3 commits into
apache:mainfrom
casaroli:feat/optional-line-buffering

Conversation

@casaroli

@casaroli casaroli commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the per-core line_buffered configuration option. It is disabled by default, preserving existing byte-wise writes for serial transports without flow control.

When enabled, sim and serial write an entire command in one operation. Buffered sim commands also disable the pexpect per-send delay. This reduces local simulator overhead and supports serial targets with reliable flow control.

Impact

  • Feature: optional per-core transport behavior.
  • Compatibility: no behavior change unless line_buffered is enabled.
  • Documentation: configuration reference and usage documentation updated.
  • Hardware: no board or driver changes.

Testing

  • Focused sim and serial transport tests: 9 passed.
  • Black and isort checks: passed.
  • Full tox coverage suite was previously run: 492 passed, 1 skipped. A newly added serial newline branch is covered by the focused tests; the subsequent full tox rerun was intentionally stopped before completion.

PR verification self-check

  • One focused functional change.
  • Default behavior is preserved and the feature is opt-in.

Assisted-by: ChatGPT:GPT-5.6-Terra

@casaroli
casaroli marked this pull request as ready for review July 26, 2026 13:06
@cederom
cederom requested a review from raiden00pl July 26, 2026 13:15
@casaroli
casaroli force-pushed the feat/optional-line-buffering branch from 356f838 to 0c7b712 Compare July 26, 2026 13:42
@casaroli

Copy link
Copy Markdown
Contributor Author

@cederom i added the coverage. can you please let the workflows run again?

@casaroli

Copy link
Copy Markdown
Contributor Author

@raiden00pl this will make the sim-1 job in nuttx 4x faster

@raiden00pl

raiden00pl commented Jul 26, 2026

Copy link
Copy Markdown
Member

I'll look at it tomorrow, but it looks good. It's nice that new contributors appear :)

Comment thread src/ntfc/device/sim.py Outdated
Comment thread src/ntfc/device/sim.py Outdated
@xiaoxiang781216

Copy link
Copy Markdown

@casaroli please fix the conflict.

Add the line_buffered per-core configuration option, disabled by default, to retain the existing byte-wise transport behavior.

When enabled, the simulator and serial transports write a complete command in one operation. Buffered simulator writes also disable pexpect per-send delay. This improves local simulator performance and supports serial transports with reliable flow control.

Document the option and cover both default and buffered command writes.

Assisted-by: ChatGPT:GPT-5.6-Terra
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@casaroli
casaroli force-pushed the feat/optional-line-buffering branch from 3e07a03 to 000fb3c Compare August 31, 2026 08:08
@xiaoxiang781216

Copy link
Copy Markdown

The per-send delay was turned off by DeviceSim._start_impl() after
host_open() returned.  A device that crashes comes back through
_dev_reopen(), which calls host_open() directly and never reaches the
device's own start, so the setting was lost for the rest of the run.

Setting it in host_open() keeps it across a reopen, and covers QEMU as well
as the simulator, since both are host-based devices.  It changes nothing for
either unless line_buffered is set, which is off by default.

The test moves with the behaviour: it now opens a device, reopens it and
checks the delay is still off.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
DeviceSim goes through get_os(), which refuses a configuration whose os it
does not recognise.  The other sim tests set it on the mock and this one did
not, so it raised before reaching what it meant to check.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@casaroli
casaroli force-pushed the feat/optional-line-buffering branch from 000fb3c to 33c92fd Compare August 31, 2026 09:00
@acassis
acassis merged commit 5490019 into apache:main Aug 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants