Fix UMP output integrity in the ATmega32U4 Arduino example#2
Merged
Conversation
Queue MIDI-CI SysEx7 replies atomically instead of word by word, so a full TX ring cannot leave half a packet at the head and corrupt USB output. Echo inbound Data128 (SysEx8 / MDS) directly, since the processor consumes MT 0x5 before the UMP callback.
Owner
Author
|
Two follow-ups from review: message type accessors instead of raw shifts, and the responder replies now pump the transport and retry while the TX ring is full instead of dropping. Revalidated on hardware: Discovery Reply and SysEx8 echo both confirmed on the wire. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1. Two issues came up in review of the example, both fixed here and both contained to the example (the midi2 core is untouched).
MIDI-CI Discovery replies are SysEx7 UMP packets, and the responder was queueing them one word at a time. If the TX ring had a single free slot when a reply was generated, the first word went in and the second was dropped, leaving half a packet at the head of the ring and corrupting later USB output. The reply now goes through the atomic whole-message write path, so a packet is either queued completely or not at all.
The other one is inbound Data128. The UMP processor consumes MT 0x5 (SysEx8 and Mixed Data Set) for reassembly before the callback runs, and reassembly is off in this example, so those messages were silently dropped instead of echoed. That contradicted the advertised Data128 surface and the echo behavior. Inbound Data128 is now echoed straight back, packet for packet.
The device behaves identically on the normal path and builds at the same footprint.