altosui: Report error message back from libaltos
[fw/altos] / altosui / AltosUSBDevice.java
index 03ddf5a89c1792415bc065f268bc0fdfc70ccf94..b11a3934b1376906974eab03cdf02b8c698f3817 100644 (file)
@@ -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 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)
                if (getVendor() != Altos.vendor_altusmetrum)
                        return false;
                if (getProduct() < Altos.product_altusmetrum_min)
@@ -77,13 +84,13 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
                return false;
        }
 
                return false;
        }
 
-       static AltosUSBDevice[] list(int product) {
+       static java.util.List<AltosDevice> list(int product) {
                if (!Altos.load_library())
                        return null;
 
                SWIGTYPE_p_altos_list list = libaltos.altos_list_start();
 
                if (!Altos.load_library())
                        return null;
 
                SWIGTYPE_p_altos_list list = libaltos.altos_list_start();
 
-               ArrayList<AltosUSBDevice> device_list = new ArrayList<AltosUSBDevice>();
+               ArrayList<AltosDevice> device_list = new ArrayList<AltosDevice>();
                if (list != null) {
                        for (;;) {
                                AltosUSBDevice device = new AltosUSBDevice();
                if (list != null) {
                        for (;;) {
                                AltosUSBDevice device = new AltosUSBDevice();
@@ -95,9 +102,6 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
                        libaltos.altos_list_finish(list);
                }
 
                        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
        }
 }
\ No newline at end of file