-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retry count for USB MIDI Tx #566
Add retry count for USB MIDI Tx #566
Conversation
I'm not sure why the clang-format checker failed. I ran |
@ndonald2 its so weird, I've had this happen a few times depending on the workstation I'm on. Honestly, not sure why even with the same .clang-format file and version it'll act different. Maybe undefinied behavior, or slight differences on different OSes. The manual fix is just the spacing in this one line in usb_midi.h: - MidiUsbTransport(const MidiUsbTransport& other) = default;
+ MidiUsbTransport(const MidiUsbTransport& other) = default; Anyway, thanks again for the PR this looks good. Should be able to merge it today. If you don't know off the top of your head, that's fine its not necessarily the same scope as either PR anyway. |
@stephenhensley weird indeed!
I haven't tried System Realtime yet, but that is definitely going to come up fairly soon for the project I'm working on. The way I discovered this bug was by sending System Exclusive messages in rapid succession, so at least can verify that works. |
@ndonald2 |
@stephenhensley just chiming in for a comment on clang-format:
In most commerical repos I worked on in the past, we had a local clang-format binary commited to a I'm a bit tight on time right now, but I'll see if I can make a PR to propose something like this. |
@TheSlowGrowth that's an excellent idea, and would certainly make things quite a bit easier for everyone. |
@ndonald2 looks great! Thanks again for the PR! |
Thanks! I also love the idea of auto-formatting git hooks. Curious if @TheSlowGrowth is referring to client-side git hooks? For context, I think client-side hooks are fantastic for this kind of thing (and much more) however I'm not sure there's actually a way to enforce usage of them. My understanding is that users can install whatever client side hooks they want (or not) per repository so when I've seen them used on projects it's usually as an optional install-script in the repo that sets them up client side. Server-side hooks can also be useful (e.g. reject commit if it doesn't pass muster) but since Github doesn't allow user-configured server side hooks, you don't see them as often, except on private git servers. In any case - +1 for automation tooling, usually a win for developer experience regardless of what form it takes. |
Yes, what I meant are client side hooks. The workflow would be:
I'll see if I can draft something, but as I said, I can't guarantee I can find the time... |
* Add retry count for USB MIDI Tx * Revert indentation change to please clang-format
Summary
Fix an issue where attempting to send MIDI messages over USB in rapid succession would frequently fail due to the USB CDC driver Tx not having finished yet and still being in the "busy" state.
Details
I noticed that attempting to send a bunch of messages immediately back to back from Daisy over USB MIDI was causing some messages to be lost. After some investigation I was able to trace this to the USB CDC implementation (in
usb_cdc_if.c
):The problem is that a previous transmit attempt had not actually completed yet - apparently this function does not block for the duration of the actual transmit, and the state flag isn't reset by the time the next transmit is attempted so it was silently failing.
The "fix" is to simply retry USB MIDI transmits up to a user-configurable amount of times (default 3) after a short delay. Using 100 microseconds for the delay is an empirical best guess. It solved the issue for my use case (sending a bunch of Sysex messages in a row).
Note, minor formatting changes are a result of running
clang-format
on these files after I added code.