-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathODriveUsbTest.java
More file actions
50 lines (39 loc) · 1.43 KB
/
ODriveUsbTest.java
File metadata and controls
50 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package odrive;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import javax.usb.UsbDevice;
import javax.usb.UsbHostManager;
import javax.usb.UsbHub;
import javax.usb.UsbServices;
public class ODriveUsbTest {
public static ArrayList<short[]> POSSIBLE_ODRIVE_IDS = new ArrayList<short[]>(
Arrays.asList(
new short[]{4617, 3377},
new short[]{4617, 3378},
new short[]{4617, 3379}
)
);
public static void main(String[] args) throws Exception {
UsbServices services = UsbHostManager.getUsbServices();
UsbHub rootHub = services.getRootUsbHub();
ArrayList<UsbDevice> devices = UsbHighLevel.findDevices(rootHub, POSSIBLE_ODRIVE_IDS);
// System.out.println(devices.size()+" devices found.");
ArrayList<ODrive> oDrives = new ArrayList<ODrive>();
for (UsbDevice odriveUsbDevice : devices) {
// System.out.println("Product: "+device.getProductString());
// System.out.println("Device info: "+device);
// System.out.println("Manufacturer: "+device.getManufacturerString());
// System.out.println("Serial number: "+device.getSerialNumberString());
// System.out.println();
ODrive odrive = new ODrive(odriveUsbDevice);
try{
odrive.loadConfiguration();
} catch (IOException io) {
odrive.readConfiguration();
odrive.saveConfiguration();
}
oDrives.add(odrive);
}
}
}