K8090 Java

Hello,

I found a thread asking pretty much the same, but no answers. forum.velleman.eu/viewtopic.php?f=3&t=4341

What I am wondering is: Can the Relay card “K8090” be programmed with Java?

I have already created some code in Java, and I want to implement this relay card using my own code.

The thread I found is 6 years old, so there must have been someone between then and now that has developed someting in Java?

If possible, can you link me some sourcecode that I can study for better understanding?

Thank you!

There is no ready to use Java library for the K8090 (that I know of)

But serial port communication under Java is possible with the Java RXTX library
rxtx.qbang.org/

That gives you raw communication, but you would still need to implement the K8090 protocol on top of it

Fortunately is it possible to use in java with JNA. You must find k8090d.dll because velleman.kits.dll provided don’t working.

Import dll in java like as library (exemple with vm option "-Djava.library.path=“C:/folderWithContainDll”)

Create interface :

import com.sun.jna.Library;
import com.sun.jna.ptr.IntByReference;

public interface IUsbRelais extends Library {

    public IntByReference OpenDevice(String szPort );
    public  void CloseDevice(IntByReference hDevice);
    public  Boolean SendCommand( IntByReference hDevice, int cmd, int mask, int hparam, int lparam );

}

And use it :

relaisDll = (IUsbRelais) Native.loadLibrary(“k8090d”, IUsbRelais.class);
deviceIdentifier= relaisDll.OpenDevice(“COM3”);
relaisDll.SendCommand(deviceIdentifier, CMD_SWITCH_RELAY_OFF,RELAIS_4,0x00,0x00);