Skip to content
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

Adds getPortProperties for Linux, OSX, Windows #113

Open
wants to merge 17 commits into
base: 2.8.0
Choose a base branch
from

Conversation

RomanBelkov
Copy link

@RomanBelkov RomanBelkov commented Jul 10, 2017

Thanks @gohai for his amazing work for Linux/OSX (see closed, unmerged #33; opened #88)

As this repo is cold dead for some time, this PR has only the intention to inform you of this feature.

Also, if someone can help & make a code review, I would be very grateful for that, as I'm a C++ noob. You can make an issue or propose a PR in my fork.

gohai and others added 12 commits February 14, 2014 12:17
Opening /dev/cu.* doesn't require DCD to be asserted and succeeds immediately.
This includes /dev/tty.Bluetooth-Modem and friends.
Opening certain devices, such as serial endpoints over Bluetooth, can take a long time before they fail. Moreover, it's better to show devices even when the user currently doesn't have permissions to access them - else one might think of a problem with the device or driver, when a "sudo chmod 666" would do the trick.
Before dynamically extracting the matching native library, first try to load it using System.loadLibrary(). This is helpful when it's not desired to modify the host system (but rather make changes to java.library.path).
The command used to compile this on 10.9.1:
g++ -shared -arch i386 -arch x86_64 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -I"/System/Library/Frameworks/IOKit.framework/Headers" -o libjSSC-2.8_universal.jnilib jssc.cpp
getPortProperties() returns a map with keys and values as string. The currently available properties are: idProduct (lowercase hexadecimal zero-padded to four digits), idVendor (same as idProduct), manufacturer, product, serial. This is currently implemented for Linux and OS X (only in the Universal binary).

The command used to compile this on 10.9.1:
g++ -shared -arch i386 -arch x86_64 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -I"/System/Library/Frameworks/IOKit.framework/Headers" -framework CoreFoundation -framework IOKit -o libjSSC-2.8_universal.jnilib jssc.cpp
Command used to compile on a current Raspbian: g++ -shared -march=armv6 -mfpu=vfp -mfloat-abi=hard -I/usr/lib/jvm/jdk-7
-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -o libjSSC-2.8_armhf.so jssc.cpp
This was built with: g++ -shared -I /usr/lib/jdk1.8.0_121/include -I/usr/lib/jdk1.8.0_121/include/linux -o libjSSC-2.8_aarch64.so jssc.cpp
also made a few changes so that MS compiler would be able to compile
Compiled in MSVC 2017.
Needs to add setupapi.lib for linker & give path to JDK includes.
It appeared, that if you change device description (CP2102 in my case),
you'll still get default description given by Windows where the new, changed
device description is expected. Luckily, in Windows 7 and above there is a way to do so.

Note that this commit will probably break everything on XP & Vista.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants