I have the issue while using the SainSmart 4 Relay USB with my Mac (10.8.5). I am trying to access over Java while using the d2xx/fdti driver.
This is my Java Code:
public class Demo {
public static void main(String[] args) throws InterruptedException {
try {
List<FTDevice> fTDevices;
fTDevices = FTDevice.getDevices();
for (FTDevice fTDevice : fTDevices) {
System.out.println("fTDevice:" + fTDevice);
System.out.println("fTDevice.DevType:" + fTDevice.getDevType());
System.out.println("fTDevice.DevID:" + fTDevice.getDevID());
System.out.println("fTDevice.DevLocationID:" + fTDevice.getDevLocationID());
fTDevice.open();
fTDevice.setBaudRate(9600);
[...]
fTDevice.close();
}
} catch (FTD2XXException ex) {
Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
And I just get this exception:
com.ftdi.FTD2XXException: D2XX error, ftStatus:INVALID_HANDLE
at com.ftdi.FTDevice.ensureFTStatus(FTDevice.java:139)
at com.ftdi.FTDevice.setBaudRate(FTDevice.java:324)
at de.relay.Demo.main(Demo.java:27)
What does "INVALID_HANDLE" mean?
I also tried to connect over the serial port, which works.
# kextload -b com.FTDI.driver.FTDIUSBSerialDriver
# cu -l /dev/tty.usbserial-XXXXXXX --baud 9600
Connected.
Which "echo" would switch a relay? And how can i fix the exception? I really appreciate any help!
Cheers, Felix