I am trying to send data via USB to a serial cable using the jUSB library. I am coding in NetBeans IDE on Windows.
What is the message problem: “USB Host support not available” in the following code:
package usb.core;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import usb.core.*;
public class Main {
public static void main(String[] args) throws IOException {
try {
Host host = HostFactory.getHost();
Bus[] bus = host.getBusses();
int total_bus = bus.length;
System.out.println(total_bus);
for (int i = 0; i < total_bus; i++) {
Device root = bus[i].getRootHub();
int total_port = root.getNumPorts();
for (int j = 1; j <= total_port; j++) {
Device device = root.getChild(j);
if (device != null) {
Configuration config = device.getConfiguration();
int total_interface = config.getNumInterfaces();
for (int k = 0; k < total_interface; k++) {
Interface itf = config.getInterface(k, 0);
int total_ep = itf.getNumEndpoints();
for (int l = 0; l < total_ep; l++) {
Endpoint ep = itf.getEndpoint(l);
String io_type = ep.getType();
boolean input = ep.isInput();
if (input) {
InputStream in;
in = ep.getInputStream();
in.close();
}
else {
OutputStream out;
out = ep.getOutputStream();
out.close();
}
}
}
}
}
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
source
share