MIDI: parse the hardware port as a byte stream - #29
Open
diegoMalagrida wants to merge 1 commit into
Open
Conversation
diegoMalagrida
force-pushed
the
fix/din-midi-stream-parser
branch
2 times, most recently
from
July 29, 2026 08:44
f7d3245 to
694a401
Compare
torvalds
force-pushed
the
main
branch
2 times, most recently
from
August 11, 2026 00:07
0d04135 to
52eac9e
Compare
The screenless pedal is meant to be programmed over either USB or its TRS Type-A MIDI ports, and the scene protocol now carries its schema, state and routing commands over SysEx. The transmit side learned all the USB-MIDI CIN lengths in commit db24ff6 ("Get the USB-MIDI code index numbers right in both directions"), but uart_midi_read() still treats F0-F7 as zero-length status bytes. A SysEx request arriving at the TRS input disappears before handle_midi_packet() sees it. The same reader recognizes only channel voice messages. It drops every real-time byte, so MIDI Clock arriving at the TRS jack never reaches USB, and System Common messages disappear too. A two-byte channel message also leaves the final packet byte holding data from an earlier three-byte event. Replace that ad-hoc reader with a byte-stream parser. Keep channel running status, emit real-time without disturbing a partly read message, handle System Common, and pack SysEx into the CIN 4..7 forms USB-MIDI needs. System Reset is the real-time exception and clears the parser state. Zero-pad every packet byte that the MIDI message does not use. Keep the parser next to the CIN helpers so the hardware MIDI path has host-side coverage. Feed it channel running status, real-time interleaved with both channel and SysEx messages, System Common, System Reset, and all three SysEx ending forms. Fixes: 95881ae ("Re-organize MIDI code a bit, add UART option") Assisted-by: Codex:gpt-5 Signed-off-by: diegoMalagrida <diegomalagrida@gmail.com>
diegoMalagrida
force-pushed
the
fix/din-midi-stream-parser
branch
from
August 12, 2026 09:23
694a401 to
bf6b02b
Compare
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.
The screenless pedal can be programmed over either USB or TRS Type-A MIDI, and the current scene protocol carries schema, state, and routing commands over SysEx.
uart_midi_read()currently treats F0-F7 as zero-length status bytes, so a SysEx request arriving at the physical MIDI input is discarded beforehandle_midi_packet()sees it.The same reader drops every System Real-Time and System Common message. MIDI Clock arriving at the TRS jack therefore never reaches USB, and a two-byte channel message can retain the final byte of an earlier three-byte packet.
This replaces that ad-hoc reader with a byte-stream parser. It preserves channel running status, emits real-time without disturbing a partially received channel or SysEx message, handles System Common and System Reset, packs SysEx into CIN 4..7, and zero-pads unused packet bytes.
The host-side validation covers channel running status for two- and three-byte messages, real-time interleaved with channel and SysEx messages, System Reset, System Common, and all three SysEx ending forms. This revision is based on the reorganized tree and updates the validation include to
Firmware/midi/midi.h.Validated with:
make -BC Validation test-midi-cin && ./Validation/test-midi-cin(all MIDI checks pass)-Wall -Wextra -Wpedantic -Wconversionand AddressSanitizer/UBSan