diff options
-rw-r--r-- | ao-tools/altosui/AltosConfig.java | 4 | ||||
-rw-r--r-- | ao-tools/altosui/AltosDevice.java | 52 | ||||
-rw-r--r-- | ao-tools/altosui/AltosEepromDownload.java | 4 | ||||
-rw-r--r-- | ao-tools/altosui/AltosFlashUI.java | 2 | ||||
-rw-r--r-- | ao-tools/altosui/AltosUI.java | 3 |
5 files changed, 41 insertions, 24 deletions
diff --git a/ao-tools/altosui/AltosConfig.java b/ao-tools/altosui/AltosConfig.java index 3d970748..7b6cd78c 100644 --- a/ao-tools/altosui/AltosConfig.java +++ b/ao-tools/altosui/AltosConfig.java @@ -238,12 +238,12 @@ public class AltosConfig implements Runnable, ActionListener { version = new string_ref("unknown"); product = new string_ref("unknown"); - device = AltosDeviceDialog.show(owner, AltosDevice.Any); + device = AltosDeviceDialog.show(owner, AltosDevice.product_any); serial_line = new AltosSerial(); if (device != null) { try { serial_line.open(device); - if (!device.matchProduct(AltosDevice.TeleMetrum)) + if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; config_thread = new Thread(this); config_thread.start(); diff --git a/ao-tools/altosui/AltosDevice.java b/ao-tools/altosui/AltosDevice.java index 9ae522c2..d671031d 100644 --- a/ao-tools/altosui/AltosDevice.java +++ b/ao-tools/altosui/AltosDevice.java @@ -39,6 +39,12 @@ public class AltosDevice extends altos_device { return loaded_library; } + static int usb_vendor_altusmetrum() { + if (load_library()) + return libaltosConstants.USB_VENDOR_ALTUSMETRUM; + return 0x000a; + } + static int usb_product_altusmetrum() { if (load_library()) return libaltosConstants.USB_PRODUCT_ALTUSMETRUM; @@ -65,26 +71,27 @@ public class AltosDevice extends altos_device { static int usb_product_teledongle() { if (load_library()) - return libaltosConstants.USB_PRODUCT_ALTUSMETRUM; + return libaltosConstants.USB_PRODUCT_TELEDONGLE; return 0x000c; } static int usb_product_teleterra() { if (load_library()) - return libaltosConstants.USB_PRODUCT_ALTUSMETRUM; + return libaltosConstants.USB_PRODUCT_TELETERRA; return 0x000d; } - public final static int AltusMetrum = usb_product_altusmetrum(); - public final static int TeleMetrum = usb_product_telemetrum(); - public final static int TeleDongle = usb_product_teledongle(); - public final static int TeleTerra = usb_product_teleterra(); - public final static int AltusMetrumMin = usb_product_altusmetrum_min(); - public final static int AltusMetrumMax = usb_product_altusmetrum_max(); + public final static int vendor_altusmetrum = usb_vendor_altusmetrum(); + public final static int product_altusmetrum = usb_product_altusmetrum(); + public final static int product_telemetrum = usb_product_telemetrum(); + public final static int product_teledongle = usb_product_teledongle(); + public final static int product_teleterra = usb_product_teleterra(); + public final static int product_altusmetrum_min = usb_product_altusmetrum_min(); + public final static int product_altusmetrum_max = usb_product_altusmetrum_max(); - public final static int Any = 0x10000; - public final static int BaseStation = 0x10000 + 1; + public final static int product_any = 0x10000; + public final static int product_basestation = 0x10000 + 1; public String toString() { String name = getName(); @@ -95,29 +102,34 @@ public class AltosDevice extends altos_device { } public boolean isAltusMetrum() { - if (getVendor() != AltusMetrum) + if (getVendor() != vendor_altusmetrum) return false; - if (getProduct() < AltusMetrumMin) + if (getProduct() < product_altusmetrum_min) return false; - if (getProduct() > AltusMetrumMax) + if (getProduct() > product_altusmetrum_max) return false; return true; } public boolean matchProduct(int want_product) { + System.out.printf("vendor %x product %x want %x\n", + getVendor(), getProduct(), want_product); + System.out.printf("vendor_altusmetrum: %d\n", vendor_altusmetrum); + System.out.printf("telemetrum: %d\n", product_telemetrum); + if (!isAltusMetrum()) return false; - if (want_product == Any) + if (want_product == product_any) return true; - if (want_product == BaseStation) - return matchProduct(TeleDongle) || matchProduct(TeleTerra); + if (want_product == product_basestation) + return matchProduct(product_teledongle) || matchProduct(product_teleterra); int have_product = getProduct(); - if (have_product == AltusMetrum) /* old devices match any request */ + if (have_product == product_altusmetrum) /* old devices match any request */ return true; if (want_product == have_product) @@ -127,19 +139,23 @@ public class AltosDevice extends altos_device { } static AltosDevice[] list(int product) { - if (!load_library()) + if (!load_library()) { + System.out.printf("no library\n"); return null; + } SWIGTYPE_p_altos_list list = libaltos.altos_list_start(); ArrayList<AltosDevice> device_list = new ArrayList<AltosDevice>(); if (list != null) { + System.out.printf("got device list\n"); SWIGTYPE_p_altos_file file; for (;;) { AltosDevice device = new AltosDevice(); if (libaltos.altos_list_next(list, device) == 0) break; + System.out.printf("got device\n"); if (device.matchProduct(product)) device_list.add(device); } diff --git a/ao-tools/altosui/AltosEepromDownload.java b/ao-tools/altosui/AltosEepromDownload.java index 6dbbd3eb..a7f64904 100644 --- a/ao-tools/altosui/AltosEepromDownload.java +++ b/ao-tools/altosui/AltosEepromDownload.java @@ -254,7 +254,7 @@ public class AltosEepromDownload implements Runnable { public AltosEepromDownload(JFrame given_frame) { frame = given_frame; - device = AltosDeviceDialog.show(frame, AltosDevice.Any); + device = AltosDeviceDialog.show(frame, AltosDevice.product_any); serial_line = new AltosSerial(); remote = false; @@ -262,7 +262,7 @@ public class AltosEepromDownload implements Runnable { if (device != null) { try { serial_line.open(device); - if (!device.matchProduct(AltosDevice.TeleMetrum)) + if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; eeprom_thread = new Thread(this); eeprom_thread.start(); diff --git a/ao-tools/altosui/AltosFlashUI.java b/ao-tools/altosui/AltosFlashUI.java index 18795695..5ed417da 100644 --- a/ao-tools/altosui/AltosFlashUI.java +++ b/ao-tools/altosui/AltosFlashUI.java @@ -187,7 +187,7 @@ public class AltosFlashUI build_dialog(); - debug_dongle = AltosDeviceDialog.show(frame, AltosDevice.Any); + debug_dongle = AltosDeviceDialog.show(frame, AltosDevice.product_any); if (debug_dongle == null) return; diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index ca587b25..edee146d 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -523,7 +523,8 @@ public class AltosUI extends JFrame { } private void ConnectToDevice() { - AltosDevice device = AltosDeviceDialog.show(AltosUI.this, AltosDevice.BaseStation); + AltosDevice device = AltosDeviceDialog.show(AltosUI.this, + AltosDevice.product_basestation); if (device != null) { try { |