I have the source code in (POSIX) C for an RS422 Serial Driver.
I've been asked to create the JNI for using the 8 driver interfaces:
This seems like something that enough people would want to do that there'd be a Standard or Common Practice way to do this. However, my Google-foo has let me down on finding it.
Since I have the source code, I've considered re-compliling the driver code into a library and writing the JNI to call into that library. The potential problem I see with this is that normally the driver would get dynamically linked into the kernel, and the calls from Java would run the library functions in userspace.
I've also considered creating the JNI to call clib functions (read, write, ioctl, ...). Then the driver would get used normally, but the problem I see with this is that install() and uninstall() do not seem to have a standard (POSIX) C function that directly corresponds do them. Most Linux forums mention insmod and mknod to install the driver and make the device node, but LynxOS uses dr_install and dev_install.
So here's my question: Is there a Standard or Common Practice way to access a driver from Java?
Thanks for the reply. Looking at the Java.comm I will want to make that my eventual interface to the serial driver. When I look at the CommDriver's initialize() function, it is during that method call that any required Native Libraries are loaded.
So what I was hoping to find out about was a standard or common practice that applies to the code that lies between the 8 driver interfaces and the CommDriver subclass and CommPort subclass.
If you're going to write a JNI shim between Java and the driver, it will end up being a .so or .dll that is loaded into the JVM using System.loadLibrary()
Both Windows and Linux .dll and .so files have a mechanism to provide initialisation and teardown of the .dll/so. So you could put the install/uninstall calls in there.
Hope this helps
So what I was hoping to find out about was a standard or common practice that applies to the code ...
As applies to java.comm?
I doubt there is such a thing. There just are not that many implementations. And most are proprietary so they are not saying.
You can look at rxtx (java comm api) and download the reference implementation and see which ways they do it. If they both do it one way that might be good. If they do it different ways then neither means much.