diff options
author | Bdale Garbee <bdale@gag.com> | 2015-02-07 22:39:54 -0700 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2015-02-07 22:39:54 -0700 |
commit | f766a457323268857b3f2dfc7f42427437b71cb7 (patch) | |
tree | 8afc8a661d682fc34b16fc0b1b44f2844d34f336 /micropeak/MicroUSB.java | |
parent | db51224af01731e7323f6f696a7397d64eb80b92 (diff) | |
parent | e2cefd8593d269ce603aaf33f4a53a5c2dcb3350 (diff) |
Merge branch 'branch-1.6' into debian
Conflicts:
ChangeLog
altoslib/AltosTelemetryReader.java
configure.ac
Diffstat (limited to 'micropeak/MicroUSB.java')
-rw-r--r-- | micropeak/MicroUSB.java | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index 24f6722b..fa20488d 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -19,7 +19,8 @@ package org.altusmetrum.micropeak; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_3.*; +import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altosuilib_6.*; public class MicroUSB extends altos_device implements AltosDevice { @@ -74,25 +75,50 @@ public class MicroUSB extends altos_device implements AltosDevice { return libaltos.altos_open(this); } + private boolean isFTDI() { + int vid = getVendor(); + int pid = getProduct(); + if (vid == 0x0403 && pid == 0x6015) + return true; + return false; + } + private boolean isMicro() { - if (getVendor() != 0x0403) - return false; - if (getProduct() != 0x6015) - return false; - return true; + int vid = getVendor(); + int pid = getProduct(); + if (vid == AltosLib.vendor_altusmetrum && + pid == AltosLib.product_mpusb) + return true; + return false; } public boolean matchProduct(int product) { - return isMicro(); + return isFTDI() || isMicro(); } static java.util.List<MicroUSB> list() { if (!load_library()) return null; - SWIGTYPE_p_altos_list list = libaltos.altos_ftdi_list_start(); - ArrayList<MicroUSB> device_list = new ArrayList<MicroUSB>(); + + SWIGTYPE_p_altos_list list; + + list = libaltos.altos_ftdi_list_start(); + + if (list != null) { + for (;;) { + MicroUSB device = new MicroUSB(); + if (libaltos.altos_list_next(list, device) == 0) + break; + if (device.isFTDI()) + device_list.add(device); + } + libaltos.altos_list_finish(list); + } + + list = libaltos.altos_list_start(); + if (list != null) { for (;;) { MicroUSB device = new MicroUSB(); @@ -106,4 +132,4 @@ public class MicroUSB extends altos_device implements AltosDevice { return device_list; } -}
\ No newline at end of file +} |