Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

Where to find error messages? #348

Closed Ir3nicuz closed 2 years ago

Ir3nicuz commented 3 years ago

I have the problem the openPort() method returns "false" and I want to know the reason. I do not find a hint in the documentation from where I have to read this information.

Normally java libs put all such information in exceptions instead of returning just true/false. But this lib seems not to use exceptions much often in the manner java suggests. Do I miss something in the documentation?

hedgecrw commented 3 years ago

Please test the attached library version and see if it works any better for you. There have been a ton of recent changes that have not made it into an actual release yet. Thanks! (Note, this test version does not yet work on Windows.)

https://drive.google.com/file/d/1hH2hXCEj39WUN1iz3F1TzLrpNvUro_aL/view?usp=sharing

The reason the native library exceptions are not bubbled up to the Java level was because this library supports so many different types of native systems with different types/granularity of error reporting that it was nearly impossible to combine all of that into something consistent in Java-land. With the library version I attached (and in future releases), I have added two functions which should allow you to view both the native errno and the source code line that threw it. These method signatures are:

int getLastErrorCode(); int getLastErrorLocation();

If you test these out, you should be able to do a search through the source code files under src/main/c/Posix to determine which line threw the error and look up what the error code means for your OS. Thanks!

hedgecrw commented 3 years ago

Please test using this version of the library (all OS's are enabled): https://drive.google.com/file/d/1QzWPJg5MU_2YrnsB1MsOWeTbjYD84D2h/view?usp=sharing

hedgecrw commented 2 years ago

Solved with new method calls in release of jSerialComm v2.8.0.