Skip to content

fix: prevent ESP32 KISS modem stalls under USB backpressure#2819

Open
ViezeVingertjes wants to merge 3 commits into
meshcore-dev:devfrom
ViezeVingertjes:fix/kiss-modem-usb-backpressure
Open

fix: prevent ESP32 KISS modem stalls under USB backpressure#2819
ViezeVingertjes wants to merge 3 commits into
meshcore-dev:devfrom
ViezeVingertjes:fix/kiss-modem-usb-backpressure

Conversation

@ViezeVingertjes

@ViezeVingertjes ViezeVingertjes commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Switch ESP32-S3 KISS modem environments to HWCDC and move outbound KISS writes to a non-blocking queued frame path so loop() and TX completion keep progressing when the host reads slowly. Add native backpressure regression tests and correct the native_kiss_modem test filter so this suite runs directly with pio test.

Also should resolve #2646

Scenario Old behaviour New behaviour
Flood commands, stop reading write() blocks → loop() permanently wedged queue drops overflow frames, loop() keeps running
Resume reading after flood dead, PING never responds recovers in ~1.3s as backlog drains

Switch ESP32-S3 KISS modem environments to HWCDC and move outbound KISS writes to a non-blocking queued frame path so loop() and TX completion keep progressing when the host reads slowly. Add native backpressure regression tests and correct the native_kiss_modem test filter so this suite runs directly with pio test.
The new test_kiss_modem suite needs KissModem headers and sources that
only native_kiss_modem provides. Scope native to test_utils and run both
envs in the unit test workflow.
@ViezeVingertjes ViezeVingertjes marked this pull request as ready for review June 25, 2026 21:59
setTxTimeoutMs() and setTxBufferSize() are HWCDC-only APIs; calling
them on HardwareSerial (UART-bridge boards like T-Beam) fails to compile.
@ViezeVingertjes

Copy link
Copy Markdown
Contributor Author

What do you think about this solution, @agessaman?

I didn't want to butcher your branch/PR, so I made it a separate one. If we end up going with this approach, all the credit goes to you since you brought up the idea in the first place. Happy to add you as a co-author as well.

It's a bigger change in terms of LOC, but with KISS gaining popularity, I think it makes sense to make it as resilient as possible. Most of the changes in this PR are test related anyway. If you filter on the three files under examples/kiss_modem, the actual implementation changes aren't that extensive.

I've tested it both in code and on hardware, but if you get a chance to do the same and give it a try, I can probably get it merged a bit quicker.

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.

1 participant