Skip to content

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

Merged
liamcottle merged 3 commits into
meshcore-dev:devfrom
ViezeVingertjes:fix/kiss-modem-usb-backpressure
Jul 23, 2026
Merged

fix: prevent ESP32 KISS modem stalls under USB backpressure#2819
liamcottle merged 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

@ViezeVingertjes
ViezeVingertjes marked this pull request as ready for review June 25, 2026 21:59
@ViezeVingertjes

ViezeVingertjes commented Jun 26, 2026

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, it can get merged a bit quicker.

@ViezeVingertjes

Copy link
Copy Markdown
Contributor Author

In case this one gets merged, it might need a change on your side too or not? @rightup
(Due to changing DARDUINO_USB_MODE)

@rightup

rightup commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Thanks, @agessaman

@agessaman

Copy link
Copy Markdown
Contributor

Sorry I didn't see this earlier. I'm vacationing at the moment and haven't been giving my email much time. I gave it a skim and I don't have any additional thoughts. Users will definitely appreciate being able to use those devices.

@ViezeVingertjes

ViezeVingertjes commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Would be great if this one could go through @liamcottle @ripplebiz 💯

It doesnt affect many devices; but the devices it does (Heltec v4 for example) are probably amongst the most popular ones for this purpose.

@ViezeVingertjes
ViezeVingertjes force-pushed the fix/kiss-modem-usb-backpressure branch from 879037b to 03d1c09 Compare July 3, 2026 05:47
ViezeVingertjes and others added 3 commits July 18, 2026 22:43
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.
setTxTimeoutMs() and setTxBufferSize() are HWCDC-only APIs; calling
them on HardwareSerial (UART-bridge boards like T-Beam) fails to compile.

Co-Authored-By: Adam Gessaman <adam@gessaman.com>
@ViezeVingertjes
ViezeVingertjes force-pushed the fix/kiss-modem-usb-backpressure branch from 03d1c09 to 3b69e78 Compare July 18, 2026 20:46
@ViezeVingertjes

Copy link
Copy Markdown
Contributor Author

Been running this for a while now; as stable as it gets. 💯

@liamcottle
liamcottle merged commit d531a98 into meshcore-dev:dev Jul 23, 2026
15 checks passed
@liamcottle

Copy link
Copy Markdown
Member

Been running this for a while now; as stable as it gets. 💯

Epic! Thanks for your work on this :)

hermes-gadget added a commit to gadgethd/MeshCore-MQTT that referenced this pull request Jul 24, 2026
Upstream commits:
- e780cca Merge pull request meshcore-dev#3033 from liamcottle/board/lilygo-tbeam-sx1276
- 520fa77 increase tbeam sx1276 max group channels from 8 to 40
- d531a98 Merge pull request meshcore-dev#2819 from ViezeVingertjes/fix/kiss-modem-usb-backpressure
- 3b69e78 fix: guard HWCDC serial config behind ARDUINO_USB_MODE
- 39ff5b8 fix: run KISS modem unit tests in CI via native_kiss_modem env
- fb2c61f fix: prevent ESP32 KISS modem stalls under USB backpressure

Clean auto-merge (no conflicts). MQTT additions preserved.
Affected files: 17 (KISS modem backpressure, T-Beam SX1276 channels, variant INIs)
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