-
Notifications
You must be signed in to change notification settings - Fork 209
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
Attempt to enable native UART on modern systems #1750
Attempt to enable native UART on modern systems #1750
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.
Hi @jahudka ,
Thanks very much for this, #1749 beat you to the bug report, but not the fix, so it's certainly appreciated!
Please can you target our 0.10 branch with this fix, as it should go into those patch releases too. You'll need to recommit against those or cherry-pick or similar as your branch has all the 0.10 to master changes in it already.
More generally this doesn't feel quite right, I'd assume it still exists in a file somewhere and we're just not loading it, we might need to do some more digging. My strpopts.h (on an older system) comes from libc6-dev.
I might generate another PR for you to test if you don't mind, to start off by us logging if this fails in future, rather than silently stopping.
// this provides a minimal ioctl() definition for modern systems | ||
// which don't have <stropts.h> anymore | ||
#include <ola/io/IOCtl.h> |
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 think from a bit of reading Linux shouldn't necessarily have stropts.h (as it's a POSIX thing).
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.
Yes, true, as I understand it, the Streams interface probably wasn't ever even really implemented, the header files were mostly present for decades before it was finally purged, I don't recall where but I read something along those lines in the past couple of days..
#else | ||
// this provides a minimal ioctl() definition for modern systems | ||
// which don't have <stropts.h> anymore | ||
#include <ola/io/IOCtl.h> | ||
#endif // HAVE_STROPTS_H | ||
|
||
#ifdef HAVE_ASM_TERMIOS_H |
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.
Which would suggest it's actually this bit that's breaking
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 don't think it is - ./configure
reports that both termios.h
and asm/termios.h
are present and usable, whereas stropts.h
is not; and in any case, if it were this, then my "fix" wouldn't actually fix anything.. so unless something really non-obvious is happening I don't think the issue is here.
include/ola/io/IOCtl.h
Outdated
#define INCLUDE_OLA_IO_IOCTL_H_ | ||
|
||
extern "C" { | ||
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW; |
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.
Is that definition in an existing header on your machine, if so which one?
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.
No, I found the source of stropts.h
here and extrapolated from there.
Hi, wow, fast and thorough! I'll go ahead and remake this PR against the 0.10 branch (I'm assuming I can't simply update this PR, I'll have to create a new one, right?). Regarding |
The perils of notifications! And I'm actually free today... 😆
Yeah sadly, a cherry-pick is the best I've managed, or you might be able to rebase or something (I don't think anything has actually changed in this file).
Yeah, it still feels like that ioctl should be defined somewhere even now, if we can use it. Would you also mind testing that this logs correctly on failure before you're patch (you'll need -l 3 or -l 4) #1751. Then we can either merge it as is, or you can pull it into your branch and adapt if we end up changing the includes requirements. |
Also please heed and fix the cpplint errors on Travis:
|
Regarding the logging: I've actually tried a lot of that when I was trying to get to the bottom of this - mostly exactly what you have in your PR, except in a somewhat.. sharper... language (I was getting slightly frustrated at that point lol). And the fun part is, I never actually got the log messages to display - I would update the code, run |
quick question re: |
You should stick with ulong. The syscall wrapper in libc is expecting a ulong when it's called, so using any other fixed-width type will cause issues on systems where ulong != the type used. In any case using
Other ideas are discussed at https://stackoverflow.com/questions/37710525/including-termios-h-and-asm-termios-h-in-the-same-project - if all else fails |
@peternewman I've finally successfully completed a build of your PR with the debug code - the pertinent section of the output looks like this:
@shenghaoyang I've seen the discussion about
This just caused my build to hang without apparent reason (to the point that I couldn't even SSH to the machine anymore). Whether we should or shouldn't be directly including things like |
Hi, I've rebased the PR onto the Also, @peternewman, I'm not sure how to interpret your confused smiley reactions in the two discussions above - would you please clarify? I know that the Sorry to put so much work on you guys, I know I should do my homework and I'm trying, it's just that this is all pretty new to me - I come from a web development background, C/C++ really isn't my strong suit, and I don't contribute to OSS projects that often, either.. so please bear with me and know that I have the best of intentions :-) |
What's your system for reference @shenghaoyang ?
Great, thanks for doing that, merged as you've probably seen.
I'd be surprised if it was something around the build specifically (unless it ran out of memory or something)!
I'd need to read up, but using a shipped header file generally feels much nicer to me than duplicating the definition in our own file (and risking it becoming out of date). It could also have issues on other OSes where the declaration differs slightly.
It's probably just flaky tests, although maybe not the segfault, I'll re-run them or have a look.
Hopefully the above covered it, I'd be far happier if we can just include an existing header file somehow for the declaration.
No worries at all, thanks for your efforts and contribution already! |
@peternewman I ran that on Debian "Bullseye". But it does bring in the kernel definition of Alternatively, See https://github.com/npat-efault/picocom/blob/master/termbits2.h - that header explains the duplicate definition problem in more detail and picocom's approach. Also, https://github.com/sigrokproject/libserialport/blob/master/linux_termios.c is interesting as well - libserialport isolates the linux specific declarations to a separate compilation unit. |
Sorry for taking a while to get back. I think I'd prefer @shenghaoyang 's solution, or just a rather hacky #undef like we've used elsewhere for Windows and like https://stackoverflow.com/a/48521433 rather than redefining the call ourselves. |
@peternewman well, in that case I'm afraid I'm not the right man for the job - it's all a little over my head - so we can probably close this and you or somebody else who knows what they're doing can open a new PR? |
No worries at all and thanks for all your attempts on this. I left it open because it did indeed work if people needed a quick fix. Now I've managed to have a look and come up with #1760 , I'll close this (as hopefully that works in the physical domain too).
We're always looking for people to work on the web front-end (especially the shiny new version) for OLA (and indeed some of our related projects) if you ever want to do some bits of that... 😃 |
Both current Raspberry Pi OS and Ubuntu for the Pi are missing the
stropts.h
header file, which causes the OLA ExtendedSerial helper to be compiled to always returnfalse
fromLinuxHelper::SetDmxBaud()
. This in turn makes it impossible to use the native UART DMX output plugin. This PR is an attempt to fix that by including an alternative bundled header file which defines theioctl()
function, which is the only thing needed out ofstropts.h
.I'd like to say up front that I'm not a C/C++ developer - in fact this is only the second time in my life that I'm attempting to mess around with C code - so please don't be too harsh with me if I've made newbie mistakes! As it is, the code compiles on Ubuntu 21.10 for RPi without errors and from the output of
olad
it is apparent that the issue is fixed by this workaround - that is, where previously the UART DMX plugin logged a warning about being unable to set the correct baud rate for the UART device, now the plugin outputs the expected line about the input and output rates being the expected250000
. I've tried to provide a "minimal" fix which would only be applied whenstropts.h
isn't present, so it should compile on other and / or older systems exactly as before, unless I'm mistaken.Of course, the usual UART configuration still applies - you still need to modify
/boot/firmware/config.txt
to disable bluetooth via adtoverlay
, enable UART and set the appropriate UART clock, and disable thehciuart
service - but even with all those things in place, neither the distributionola
package nor a fresh compile of OLA produced the expected result.Thanks everyone on the OLA team for creating and maintaining this project!