GNOME Bugzilla – Bug 660276
BSD port
Last modified: 2020-11-25 15:39:44 UTC
Currently moserial has hardcoded values for what reasonable names are for serial ports...on Linux. Would patches be accepted to allow for BSD device names too? Currently my patches are for the generated C files using #ifndef __linux__, how would one use something like that in vala, or can I just use the same construct and let the C compiler figure out what to do?
Please patch SettingsDialog.vala. You just need to expand this section: private void populateDevices(){ List<string> deviceTypes = new List<string> (); deviceTypes.append ("/dev/ttyS"); deviceTypes.append ("/dev/ttyUSB"); deviceTypes.append ("/dev/rfcomm"); ... add your BSD stuff here ... You shouldn't need ifdefs - nonexistent ports are ignored, so the BSD-specific stuff shouldn't show up when running on Linux, and vice versa. - Mike
Created attachment 197595 [details] [review] Add some bsd device files
Also, patching Settings.vala to change DEFAULT_DEVICEFILE isn't needed either with these changes?
I think deviceTypes.append ("/dev/cua0"); should be deviceTypes.append ("/dev/cua"); because moserial appends and tests 0..31 automatically. Your code would start testing at "/dev/cua00" (two zeroes). Right? I have to check into the DEFAULT_DEVICEFILE issue. - Mike
Right, that should indeed be /dev/cua, Ill update it before pushing, ok?
If you have commit access, go ahead and push those two lines. - Mike
Done ;-)
Thanks for the patch! Regarding DEFAULT_DEVICEFILE: it is OK to leave it as-is. That will result in a non-existent-port setting the first time the user runs moserial on BSD, but moserial will remember the last-used port on later runs, so it should be OK. If you really wanted to, you might be able to add BSD-specific #ifdefs to the vala code (https://live.gnome.org/Vala/ConditionalCompilationSample), so that "/dev/cua0" was the BSD default. I haven't tried that. - Mike
I think it's ok to leave that as is for now, especially since it's only an "issue" at the first start. Finally, moserial supports several non-standard baud rates, which only seem to be defined on Linux. Right now I have a block like this in the C code: /* Add defines for various non-standard speeds. */ #ifndef B460800 #define B460800 460800 #endif Is there a similar construct that can be used in the src/SerialConnection.vala source?
I'm not sure how that should be handled. It MIGHT be possible to add a check for BSD in configure.ac, and then use conditional compilation in the vala code. Something like #if ! IS_BSD case 1000000: baudRate=Linux.Termios.B1000000; break; #endif where IS_BSD is from a test in configure.ac. But I've never tried that... Does Linux.Termios.CRTSCTS work in BSD? That flag enables hardware handshaking. It would be a major annoyance if that didn't work in BSD. - Mike
Yep, that works as it's standard. The baudrates that were added were non-standard and as such not supported in our termios.h.