-
Notifications
You must be signed in to change notification settings - Fork 221
Initial FTDI RDM support #1541
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
base: master
Are you sure you want to change the base?
Initial FTDI RDM support #1541
Conversation
This will probably replace Write(DmxBuffer) in the future and maybe should return bool.
…or logic to prevent memory leaks (I hope).
…rewrite/undo a lot of my changes but figure I should maintain stuff just in case.
…or ftdidmx, code still very ugly and hacky and olad doesn't shut down properly.
…tput to FtdiDmxThread::SendRDMRequest()
It still doesn't work and some behaviors are plain wrong (the callbacks being called when stuff can't get to the line) Sadly my second FTDI interface is broken so I can't currently check if RDM packets are actually hitting the line or not. Also still leaves olad that doesn't shutdown without kill -9.
Added the DiscoveryAgent and inheritance from DiscoverableRDMControllerInterface
At this point only UnMuteAll gets called, after its' callback is fired no further RDM packets are sent. Also I'm pretty sure I may be leaking some memory.
Added some more debug output for when an operation is pending/
…more debug output. Works now, but reply is not being read I really need to get another FTDI interface or some other way to monitor the line :/ Also shutdown works again (which may be due to next commit)
… switching messing up the reading of the reply. Still no luck, will need to wait for new FTDI board to read the line.
1. Clear packetbuffer before use. 2. Fix logic of callbacks (else was to wrong if()) 3. Fix packet reconstruction for non-DUB replies: the MAB is recognized as another byte by the FTDI so it reads 1 byte more then the actual packet so we hand of starting 1 byte later and 1 byte less total.
…cks. This declutters rest of the code.
It runs them, the pending request should be destroyed by the core that generated it which is why it can be set to null.
Old scheduling logic commented out, will be removed in next commit.
peternewman
left a comment
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.
A few initial notes to get you started...
|
Travis lint errors will need fixing too: |
|
And this compiler error: |
|
It works though!!! I've just plugged in an FTDI RS485 lead and done some discovery and identify! 🎆 🍾 💯 👍 |
This fixes it, and works for me: |
|
Also can you update the FTDI plugin's readme please, probably with a general note, and a list of known good, and known bad devices, where it works or doesn't (e.g. the likely biasing issue on the Enttec Open, although I never could find the circuit diagram the other day to confirm). |
…r seems more logical at hw level so moved there. Thread level function still commented out in code will be removed later. The thread does not seem to need to be echo aware, however once I do tests we'll know for sure.
… is ON. Also fixed debug output targets to right targets. TODO: Add echo detection to setup. TODO: Convert Write(DmxBuffer) to use Write(ola::io::ByteString)
As mentioned on IRC it seems to me that this behavior is not desirable.
far causes crashes because Size() is too often 0 instead of within allowed range.
TODO: Update docs and run through valgrind.
Valgrind results suggests no leak in plugin, however there do seem to be leaks in RDM Core.
…null packets also with only 24 slots of data.
…d list into variable. Also one spelling correction I missed.
peternewman
left a comment
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 comments
| m_tv.tv_usec / ONE_THOUSAND); | ||
| } | ||
|
|
||
| int64_t BaseTimeVal::InMicroSeconds() const { |
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 returns exactly the same value as BaseTimeVal::AsInt(), any reason we need the second function?
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 is returning msec not usec...
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 guess AsInt is too then; I've just double-checked and the code is identical in both, only the method name changes.
| timespec req; | ||
| req.tv_sec = requested / USEC_IN_SECONDS; | ||
| req.tv_nsec = (requested % USEC_IN_SECONDS) * ONE_THOUSAND; | ||
| req.tv_sec = 0; |
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.
Why is this assigned and then reset?
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 suspect an error on my part, though I also have a suspicion that maybe I did not want this function to exceed 1s
| bool StringToInt(const string &value, | ||
| unsigned int *output, | ||
| bool strict, | ||
| uint8_t base) { |
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.
Like the stuff in https://github.com/OpenLightingProject/ola/blob/master/common/utils/StringUtilsTest.cpp#L541-L564 for example.
So passing in something in base 36, and also validating that 123ABC converts to the same value as 123abc.
| return false; | ||
| } | ||
|
|
||
| *output = static_cast<unsigned int>(l); |
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.
But if we've returned false we shouldn't bother setting the value.
| class FtdiDmxThread : public ola::thread::Thread { | ||
| enum { | ||
| HALF_SECOND_MS = 500, | ||
| ALMOST_SECOND_MS = 900, |
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.
Likewise
|
@peternewman I may want to retry getting this in, I suspect it will be better to do a new PR against the current branch and maybe also smaller PRs (in as much as that is possible) that add differnent features, WDYT? |
|
@Keeper-of-the-Keys I -- as well as others -- am also interested in getting this in. Any chance some effort could be put towards this. |
I tried picking it back up but it turns out I broke one of my FTDI boards, I don't really have budget at the moment to buy new boards and thus it got snowed under other projects that pay my bills at the moment. Specifically this PR is too large to get merged IMHO and my plan was to start working on the different components and get them merged one by one but as said need working hardware to develop software. That being said I do still hope to get to it... |
|
@Keeper-of-the-Keys would you mind reaching out to me? chris at bigcove.io |
The support is not 100% according to the standard, it for instance does not check if after the minimum wait duration a full packet was actually received and if not waits longer.
This should of course only be a problem for devices that for some reason don't manage to send an RDM packet within normal/optimal timings.
I figure that adding that logic/better timings should be part of a separate later PR.