-
Notifications
You must be signed in to change notification settings - Fork 55
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
Provide possibility to set "exotic" ports' names #179
Comments
I hope can provide solution for this issue on next week. |
The page linked does not reference a specific port pattern, but has documents that allude to the port pattern.
Relevant code: jssc/src/main/java/jssc/SerialPortList.java Lines 51 to 55 in 8dd99a4
|
@andrey-patin-1979 Please link direct documentation to support this statement. |
|
Right, but we can only code for what we know. So far the proposal as we've identified are: case SerialNativeInterface.OS_LINUX: {
- PORTNAMES_REGEXP = Pattern.compile("(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm|ttyO)[0-9]{1,3}");
+ PORTNAMES_REGEXP = Pattern.compile("(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm|ttyO|ttyM|ttyMXUSB|ttyMUE)[0-9]{1,3}");
PORTNAMES_PATH = "/dev/";
break;
} This adds three new options that are compatible with Moxa's documentation:
We may choose to recognize all |
@tresf, actually I was thinking about adding special Java-option that will allow to add "exotic names" to PORTNAMES_REGEXP for any OSes. It looks more convenient way to fix this issue once and for all. Do you agree? |
I don't see this feature being particularly useful for Windows, but I think it would be a nice addition to the API regardless due to its usefulness on macOS and Linux. Like any feature, it may be a security concern for companies to offer an arbitrary codepath to flat file reads, so I think this feature should have an option to disable it. I still believe that the library should "Just work", so adding values -- such as those introduced by MOXA devices -- is still desired, they've been in the industry for decades. |
Just to make sure I understand you, @tresf, correctly, you want to add this feature by yourself? |
I would ask for two PRs, one with well-known names one with the REGEX/future unknown names feature. |
OK, would you, @tresf, please create a branches for both of these changes (seems I don't have rights to do it)? |
You would normally create your own fork, then your own branch, then PR. |
@tresf, 1-st PR created (#180) I don't know if I need to create any tests for this PR (with changed value of PORTNAMES_REGEXP) or in 2-nd PR for new option, if I need to create test(s) then please provide me an information how to run them. |
I appreciate the offer. At time of writing this, I don't think we would need tests for all the different port patterns -- at least not the scope of #180 -- although I'm not opposed to having Linux tests that simulate the various port names, I wouldn't expect you to spearhead this effort for such a simple change. Perhaps we add this requirement before merging the next PR with a dynamic REGEX pattern, but this next PR may have other requirements (such as any raised security concerns) that will naturally prolong its merge. |
Allows matching of MOXA device port names in Linux Related: #179
@tresf, in that case I need to know how to run tests at least on Windows, could you provide me such information (since I didn't find anything in Wiki and mvn clean test didn't make a trick too. |
Why? This request/feature is for OSs that allow arbitrary POSIX paths to be used for Serial communication. Windows doesn't allow this. With regards to why tests aren't running... JUnit skips all Windows tests in the VirtualPortRule file -- which I find to be tremendously confusing -- but I don't write a lot of unit tests, so take my opinion with a grain of salt. jssc/src/test/java/jssc/junit/rules/VirtualPortRule.java Lines 65 to 74 in defbff6
With regards to creating unit tests for Linux, this would likely require adding a symbolic link to the filesystem that matches a the arbitrary pattern proposed in this #179 (comment). e.g. export _JAVA_OPTIONS="-Dportnames.match="(ttyFOO|ttyBAR)[0-9]{1,3}" With regards to how to make the test ALSO use that port pattern, I'm at a bit of a loss. I did not write these unit tests, but I think you can find them somewhere around here:
What I'm not sure about is whether or not we actually use the pattern matching in our tests. If not, that's something we should probably fix. We would expect the enhancement PR to help with this. |
Some drivers for different OSes can call serial ports with different "exotic" names (e.g. "muiO" for Moxa on Linux (https://moxa.com/en/support/product-support/software-and-documentation?psid=114475)).
It would be helpful if there were possibility to provide such "exotic" ports names into the library.
The text was updated successfully, but these errors were encountered: