-
Notifications
You must be signed in to change notification settings - Fork 202
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 support for OpenDeck boards #1746
base: master
Are you sure you want to change the base?
Add support for OpenDeck boards #1746
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial linting comments to start off with
f9adc09
to
66b846b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are four outstanding lint issues from cpplint:
https://app.travis-ci.com/github/OpenLightingProject/ola/jobs/540772260
https://app.travis-ci.com/github/OpenLightingProject/ola/jobs/540772260#L1316
Plus a few other comments.
66b846b
to
7d06309
Compare
7d06309
to
b8a6513
Compare
7a2f576
to
8073f38
Compare
I'm pleased to say the CI is now progressing a lot further than it was. You just need to implement your widget in the tests and I think you'll be good. The relevant file is: You can also run the tests locally with the usual You might also like to add a test for your firmware versioning (possibly pulling it out into a standalone function too). |
8073f38
to
2145408
Compare
I'm pretty lost with these tests... Not sure what the tests are doing, what's the expected data and how to interpret error I'm getting when running them, which is:
Also, I don't know what do EDIT: Figured. Those are ESTA and device IDs. Fixed now. |
8babe5b
to
771662a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more tidying and comments/questions
plugins/usbpro/OpenDeckWidget.cpp
Outdated
reinterpret_cast<uint8_t*>(&full_frame), | ||
length + 1); | ||
} else { | ||
return SendMessage(DMX_LABEL, &send_buffer[0], send_buffer.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You currently appear to be using the same label for your special diff packets as well as normal ones! How do you tell a normal DMX packet (which happens to have fewer than 512 slots) from a special packet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the label byte comes data length LSB/MSB. Once I process those I know - if the size is 513 it's normal packet, otherwise it's diff mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's not as simple as that.
Try running this on your OLA machine:
./examples/ola_set_dmx -u 0 -d 10,20,30,40,50
Or using the pre-compiled one the debs ship or whatever. That will send a DMX frame with only 5 slots in it, which will confuse your diff thing I'm sure. The standard only mandates some timing restrictions on DMX packets, they don't have to have all 512 slots plus the start code. Pedantically my 5 slot example is probably too short to be valid, but something around 30-40 slots can easily be acceptable.
Your most compliant option is probably to pick another label just for yourself (like others have done, and send that with your diff format), rather than re-using the existing diff label with a different format.
As an aside, I'd recommend making sure your code is hardened to issues like this too, e.g. if I say the length is one thing, then don't send that much data, or if with your diff format I address a slot that's greater than 512, or send the channel number (or only half of it), but not the slot value etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I didn't know that's possible / valid. Okay. I'll implement new label. I've put it in OpenDeckWidget.h
- not sure if that's the correct place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And sure, I'll handle the edge cases on firmware side once all the issues in this MR are solved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I didn't know that's possible / valid. Okay. I'll implement new label. I've put it in
OpenDeckWidget.h
- not sure if that's the correct place.
That matches what the other devices do. We should sort you out a login for our wiki so you can add some documentation on this format:
https://wiki.openlighting.org/index.php/USB_Protocol_Extensions
5966a48
to
4c2f26f
Compare
4c2f26f
to
1eb0c60
Compare
d9d2f6b
to
cd0633e
Compare
Had another look at this - not sure what to do next. Also don't know why the CI is failing, on my PC everything passes normally. |
Can I get some update on this? |
Sorry for not replying sooner @paradajz .
There are still a few outstanding comments (e.g. your own rate limiting key if you still want to do it). I'll see if the tests pass cleanly on a second run and try and re-review my outstanding comments and the code soon.
I think that test has occasionally been a bit intermittent so it might clear with a re-run now you've fixed the broken test. I've (accidentally) updated the online version of your branch to match master, so you may need to pull on your development machine. |
3a7e508
to
34d3255
Compare
Thanks for the reply - I've rebased on master to remove the merge commit. |
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
2559dd8
to
ba7bdfe
Compare
b7ccd82
to
cdfbd16
Compare
Hopefully no more changes are required. The CI is still failing but from what I see it's something completely unrelated (spell checker?). |
🤞
If you want to cherry-pick this commit it will shut it up: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really sorry, just the one niggle with the token bucket that I think will be worth testing in the long term.
plugins/usbpro/OpenDeckDevice.h
Outdated
if (m_bucket.GetToken(*m_wake_time)) { | ||
return m_widget->SendDMX(buffer); | ||
} else { | ||
OLA_INFO << "Port rated limited, dropping frame"; | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it will make it a little more complicated, you probably want to move the rate limiting check to within OpenDeckWidget.cpp, otherwise you risk wasting your tokens on unchanged packets which don't actually get sent, rather than saving them for the first diff or full packet that arrives!
Depending on your processing times, you might also choose to take another token (I think you can) if processing one (e.g. unpacking the diff) takes longer than the other one on your device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've added initial, maybe naive approach. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason you haven't just moved all the TokenBucket code to OpenDeckWidget, rather than keeping it outside and passing it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do that, but to create TokenBucket, I need some parameters first, namely:
max_burst, rate, max_burst, *wake_time
These aren't accessible in OpenDeckWidget. I might be missing something here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a bit beyond my understanding of OLA... Don't know what to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added simpler, alternative approach.
|
||
private: | ||
static const size_t MAX_DIFF_CHANNELS = 128; | ||
static const uint8_t DMX_SLOT_VALUE_DIFF_LABEL = 80; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label 80 (aka 0x50) doesn't seem to appear in our codebase, so looks good to go! 🥳
plugins/usbpro/OpenDeckWidget.cpp
Outdated
return SendMessage(DMX_SLOT_VALUE_DIFF_LABEL, | ||
&send_buffer[0], | ||
send_buffer.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the whitespace:
return SendMessage(DMX_SLOT_VALUE_DIFF_LABEL, | |
&send_buffer[0], | |
send_buffer.size()); | |
return SendMessage(DMX_SLOT_VALUE_DIFF_LABEL, | |
&send_buffer[0], | |
send_buffer.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
common/utils/StringUtilsTest.cpp
Outdated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, pesky GitHub editor!
plugins/usbpro/OpenDeckDevice.h
Outdated
if (m_bucket.GetToken(*m_wake_time)) { | ||
return m_widget->SendDMX(buffer); | ||
} else { | ||
OLA_INFO << "Port rated limited, dropping frame"; | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason you haven't just moved all the TokenBucket code to OpenDeckWidget, rather than keeping it outside and passing it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments
bool OpenDeckWidget::IsBufferDiff(const DmxBuffer &buffer) { | ||
return buffer != internal_buffer; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great minds! I literally just came here to write this after reviewing #1766 who's doing a very similar thing...
So is this ready for merging? |
This PR adds support for OpenDeck boards.
What is OpenDeck?
OpenDeck is open-source platform for building MIDI controllers which supports many different boards (some AVR, some STM32). More info on the website. Since firmware version 6.0.0, I have added support for DMX - more specifically, through CDC interface, Enttec Widget API was implemented so that the boards are compatible with OLA. A drawback for my boards was that in default USB Pro implementation, DMX data was sent constantly to the boards, even if data hasn't changed. Since my boards do many other things other than DMX, performance issues arose (at least on AVR, STM32 can handle it). I've started discussion about it here.
What this PR does is: