X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosUSBDevice.java;h=ed5f8307d178bba720de462c47b358e3f4f4ddf4;hp=03ddf5a89c1792415bc065f268bc0fdfc70ccf94;hb=95268d681c9a6652d84db383f55a4fe8a4ac5173;hpb=9cdef76c1275b343099d0d01af82d7eadd36a410 diff --git a/altosui/AltosUSBDevice.java b/altosui/AltosUSBDevice.java index 03ddf5a8..ed5f8307 100644 --- a/altosui/AltosUSBDevice.java +++ b/altosui/AltosUSBDevice.java @@ -39,11 +39,18 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { } + public String getErrorString() { + altos_error error = new altos_error(); + + libaltos.altos_get_last_error(error); + return String.format("%s (%d)", error.getString(), error.getCode()); + } + public SWIGTYPE_p_altos_file open() { return libaltos.altos_open(this); } - public boolean isAltusMetrum() { + private boolean isAltusMetrum() { if (getVendor() != Altos.vendor_altusmetrum) return false; if (getProduct() < Altos.product_altusmetrum_min) @@ -64,7 +71,12 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { if (want_product == Altos.product_basestation) return matchProduct(Altos.product_teledongle) || matchProduct(Altos.product_teleterra) || - matchProduct(Altos.product_telebt); + matchProduct(Altos.product_telebt) || + matchProduct(Altos.product_megadongle); + + if (want_product == Altos.product_altimeter) + return matchProduct(Altos.product_telemetrum) || + matchProduct(Altos.product_megametrum); int have_product = getProduct(); @@ -77,13 +89,13 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { return false; } - static AltosUSBDevice[] list(int product) { + static java.util.List list(int product) { if (!Altos.load_library()) return null; SWIGTYPE_p_altos_list list = libaltos.altos_list_start(); - ArrayList device_list = new ArrayList(); + ArrayList device_list = new ArrayList(); if (list != null) { for (;;) { AltosUSBDevice device = new AltosUSBDevice(); @@ -95,9 +107,6 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { libaltos.altos_list_finish(list); } - AltosUSBDevice[] devices = new AltosUSBDevice[device_list.size()]; - for (int i = 0; i < device_list.size(); i++) - devices[i] = device_list.get(i); - return devices; + return device_list; } } \ No newline at end of file