Skip to content

Conversation

@tatsuy
Copy link
Contributor

@tatsuy tatsuy commented Dec 19, 2025

This change extends the SITL SerialDevice corruption simulator to cover more UART/serial failure modes, making it easier to stress-test serial parsers under Valgrind and catch potential buffer overruns.

What’s added

  • stall: return 0 bytes even though data was available
  • short-read: return only a short prefix of the available bytes
  • burst: corrupt a small consecutive range of bytes

drop/add/flip are kept as-is.

Notes

  • This is guarded behind AP_SIM_SERIALDEVICE_CORRUPTION_ENABLED, so there is no behavior change when corruption is disabled.
  • Intended usage is to enable corruption and run SITL under Valgrind (e.g. sim_vehicle.py -V) to verify there are no memory errors even under heavy serial corruption.

@peterbarker
Copy link
Contributor

This looks OK, but we're now corrupting a lot of bytes!

How was this tested?

@tatsuy
Copy link
Contributor Author

tatsuy commented Dec 21, 2025

I used this commit to test the serial-corruption scenarios for #31663 in SITL under Valgrind. The corruption scenarios were useful because they exposed an additional packet-boundary handling issue, and I was able to add a fix for it.

I didn’t add per-mode unit tests (e.g. forcing each corruption type or packet dumps).

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.

2 participants