Fazecast / jSerialComm

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

Custom baudrate thanks Termios2 under Linux #529

Closed ooobelix closed 7 months ago

ooobelix commented 1 year ago

Hi! I'm trying tu use jSerialComm on BeagleBoardBlack (java version "1.8.0361" only) specially for this commit: [c37a9d1 - Use termios2 for custom baud rates on Linux_

Setting baudrate at 8930 for example, return :

After reading the code, I think that I need to call "setConfigOptions" in "PosixHelperFunctions.c" file but it seems to be implemented into Android version only:

$ grep -ri setconfigoptions .
grep: ./src/main/resources/Android/arm64-v8a/libjSerialComm.so : fichiers binaires correspondent
grep: ./src/main/resources/Android/x86/libjSerialComm.so : fichiers binaires correspondent
grep: ./src/main/resources/Android/x86_64/libjSerialComm.so : fichiers binaires correspondent
grep: ./src/main/resources/Android/armeabi-v7a/libjSerialComm.so : fichiers binaires correspondent
hedgecrw commented 1 year ago

setConfigOptions gets called automatically upon opening a port or changing any of the configuration parameters (for all OSs). You just happen to be searching for this string in the shared libraries pre-checked into GitHub (which is only Android)...the rest of the binaries get built upon GitHub commit.

The problem you're seeing with an error code of 25 at the indicated line (specifically for Linux) means that the underlying request to set the custom baud rate you have specified (8930) is not supported by the hardware. I'm not sure that there's anything that can be done about that other than to use a well-supported baud rate (like 9600).

ooobelix commented 1 year ago

So I was wrong about Android implementation, I prefer :+1:

But one possibility of termios2 is to set custom baudrate, I have write it in C and it's works well on BeagleBoardBlack

hedgecrw commented 1 year ago

Are you saying you have a termios2 implementation in C that works when connecting to your BeagleBoardBlack at 8930 baud rate? If so, could you post that implementation here (or compare it to the implementation in PosixHelperFunctions.c for Linux) and see what is different? Thanks!

ooobelix commented 1 year ago

I'm using this code : LIN Bus

With JSC, when I set 9600, the code works well.

For my understand, the custom baudrate is possible thanks BOTHER and CBAUD. In PosixHelperFunctions.c, you "<< IBSHIFT"

Thanks for your help!

hedgecrw commented 11 months ago

I made some updates to the custom baud rate settings. Please try the following SNAPSHOT version and see what happens:

SNAPSHOT Version: 2.10.5-SNAPSHOT SNAPSHOT Direct Download Link SNAPSHOT Instructions

hedgecrw commented 7 months ago

This should be resolved with today's release of v2.11.0.