diff options
Diffstat (limited to 'ao-tools')
-rw-r--r-- | ao-tools/altosui/AltosConfig.java | 4 | ||||
-rw-r--r-- | ao-tools/altosui/AltosDevice.java | 96 | ||||
-rw-r--r-- | ao-tools/altosui/AltosDeviceDialog.java | 13 | ||||
-rw-r--r-- | ao-tools/altosui/AltosEepromDownload.java | 4 | ||||
-rw-r--r-- | ao-tools/altosui/AltosFlashUI.java | 2 | ||||
-rw-r--r-- | ao-tools/altosui/AltosTelemetryReader.java | 12 | ||||
-rw-r--r-- | ao-tools/altosui/AltosUI.java | 17 | ||||
-rw-r--r-- | ao-tools/altosui/Makefile.am | 52 | ||||
-rw-r--r-- | ao-tools/altosui/altos-windows.nsi | 3 | ||||
-rw-r--r-- | ao-tools/altosui/altosui.1 | 16 | ||||
-rw-r--r-- | ao-tools/libaltos/Makefile.am | 21 |
11 files changed, 190 insertions, 50 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 e62a0a7a..f646305b 100644 --- a/ao-tools/altosui/AltosDevice.java +++ b/ao-tools/altosui/AltosDevice.java @@ -22,22 +22,76 @@ import libaltosJNI.*; public class AltosDevice extends altos_device { - static boolean initialized = false; - static { - try { - System.loadLibrary("altos"); - libaltos.altos_init(); + static public boolean initialized = false; + static public boolean loaded_library = false; + + public static boolean load_library() { + if (!initialized) { + try { + System.loadLibrary("altos"); + libaltos.altos_init(); + loaded_library = true; + } catch (UnsatisfiedLinkError e) { + loaded_library = false; + } initialized = true; - } catch (UnsatisfiedLinkError e) { - System.err.println("Native library failed to load.\n" + e); } + 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; + return 0x000a; + } + + static int usb_product_altusmetrum_min() { + if (load_library()) + return libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MIN; + return 0x000a; + } + + static int usb_product_altusmetrum_max() { + if (load_library()) + return libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MAX; + return 0x000d; } - public final static int AltusMetrum = libaltosConstants.USB_PRODUCT_ALTUSMETRUM; - public final static int TeleMetrum = libaltosConstants.USB_PRODUCT_TELEMETRUM; - public final static int TeleDongle = libaltosConstants.USB_PRODUCT_TELEDONGLE; - public final static int TeleTerra = libaltosConstants.USB_PRODUCT_TELETERRA; - public final static int Any = 0x10000; - public final static int BaseStation = 0x10000 + 1; + + static int usb_product_telemetrum() { + if (load_library()) + return libaltosConstants.USB_PRODUCT_TELEMETRUM; + return 0x000b; + } + + static int usb_product_teledongle() { + if (load_library()) + return libaltosConstants.USB_PRODUCT_TELEDONGLE; + return 0x000c; + } + + static int usb_product_teleterra() { + if (load_library()) + return libaltosConstants.USB_PRODUCT_TELETERRA; + return 0x000d; + } + + 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 product_any = 0x10000; + public final static int product_basestation = 0x10000 + 1; public String toString() { String name = getName(); @@ -48,11 +102,11 @@ public class AltosDevice extends altos_device { } public boolean isAltusMetrum() { - if (getVendor() != libaltosConstants.USB_VENDOR_ALTUSMETRUM) + if (getVendor() != vendor_altusmetrum) return false; - if (getProduct() < libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MIN) + if (getProduct() < product_altusmetrum_min) return false; - if (getProduct() > libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MAX) + if (getProduct() > product_altusmetrum_max) return false; return true; } @@ -62,15 +116,15 @@ public class AltosDevice extends altos_device { 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) @@ -80,7 +134,7 @@ public class AltosDevice extends altos_device { } static AltosDevice[] list(int product) { - if (!initialized) + if (!load_library()) return null; SWIGTYPE_p_altos_list list = libaltos.altos_list_start(); diff --git a/ao-tools/altosui/AltosDeviceDialog.java b/ao-tools/altosui/AltosDeviceDialog.java index 3df4c6eb..ec78e288 100644 --- a/ao-tools/altosui/AltosDeviceDialog.java +++ b/ao-tools/altosui/AltosDeviceDialog.java @@ -49,10 +49,15 @@ public class AltosDeviceDialog extends JDialog implements ActionListener { dialog.setVisible(true); return value; } else { - JOptionPane.showMessageDialog(frame, - "No AltOS devices available", - "No AltOS devices", - JOptionPane.ERROR_MESSAGE); + /* check for missing altos JNI library, which + * will put up its own error dialog + */ + if (AltosUI.load_library(frame)) { + JOptionPane.showMessageDialog(frame, + "No AltOS devices available", + "No AltOS devices", + JOptionPane.ERROR_MESSAGE); + } return null; } } 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/AltosTelemetryReader.java b/ao-tools/altosui/AltosTelemetryReader.java index fdedbde2..ae9682ab 100644 --- a/ao-tools/altosui/AltosTelemetryReader.java +++ b/ao-tools/altosui/AltosTelemetryReader.java @@ -41,6 +41,7 @@ public class AltosTelemetryReader extends AltosReader { public AltosTelemetryReader (FileInputStream input) { boolean saw_boost = false; + int current_tick = 0; records = new LinkedList<AltosRecord> (); @@ -51,9 +52,20 @@ public class AltosTelemetryReader extends AltosReader { break; } try { + System.out.printf("%s\n", line); AltosTelemetry record = new AltosTelemetry(line); if (record == null) break; + if (records.isEmpty()) { + current_tick = record.tick; + } else { + int tick = record.tick | (current_tick & ~ 0xffff); + if (tick < current_tick - 0x1000) + tick += 0x10000; + current_tick = tick; + record.tick = current_tick; + } + System.out.printf("\tRSSI %d tick %d\n", record.rssi, record.tick); if (!saw_boost && record.state >= Altos.ao_flight_boost) { saw_boost = true; diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 3aaeb888..edee146d 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -70,8 +70,22 @@ public class AltosUI extends JFrame { public AltosVoice voice = new AltosVoice(); + public static boolean load_library(Frame frame) { + if (!AltosDevice.load_library()) { + JOptionPane.showMessageDialog(frame, + String.format("No AltOS library in \"%s\"", + System.getProperty("java.library.path","<undefined>")), + "Cannot load device access library", + JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + public AltosUI() { + load_library(null); + String[] statusNames = { "Height (m)", "State", "RSSI (dBm)", "Speed (m/s)" }; Object[][] statusData = { { "0", "pad", "-50", "0" } }; @@ -509,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 { diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index dd4b31e6..fa391889 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -1,7 +1,11 @@ JAVAROOT=classes AM_JAVACFLAGS=-encoding UTF-8 -CLASSPATH_ENV=CLASSPATH=".:classes:../libaltos:$(FREETTS)/*:/usr/share/java/*" +man_MANS=altosui.1 + +altoslibdir=$(libdir)/altos + +CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:../libaltos:$(FREETTS)/*:/usr/share/java/*" bin_SCRIPTS=altosui @@ -88,16 +92,40 @@ MACOSX_EXTRA=$(FIRMWARE) WINDOWS_FILES=$(FAT_FILES) altos.dll $(top_srcdir)/telemetrum.inf $(WINDOWS_ICON) -all-local: classes/altosui $(JAR) $(FATJAR) altosui altosui-test +all-local: classes/altosui $(JAR) altosui altosui-test clean-local: - -rm -rf classes/altosui $(JAR) $(FATJAR) \ - $(LINUX_DIST) $(MACOSX_DIST) $(WINDOWS_DIST) $(FREETTS_CLASS) \ + -rm -rf classes $(JAR) $(FATJAR) \ + $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(FREETTS_CLASS) \ $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log \ altosui altosui-test macosx linux fat: $(FATJAR) $(LINUX_DIST) $(MACOSX_DIST) $(WINDOWS_DIST) +if FATINSTALL + +FATTARGET=$(FATDIR)/$(VERSION) + +LINUX_DIST_TARGET=$(FATTARGET)/$(LINUX_DIST) +MACOSX_DIST_TARGET=$(FATTARGET)/$(MACOSX_DIST) +WINDOWS_DIST_TARGET=$(FATTARGET)/$(WINDOWS_DIST) + +fat: $(LINUX_DIST_TARGET) $(MACOSX_DIST_TARGET) $(WINDOWS_DIST_TARGET) + +$(LINUX_DIST_TARGET): $(LINUX_DIST) + mkdir -p $(FATTARGET) + cp -p $< $@ + +$(MACOSX_DIST_TARGET): $(MACOSX_DIST) + mkdir -p $(FATTARGET) + cp -p $< $@ + +$(WINDOWS_DIST_TARGET): $(WINDOWS_DIST) + mkdir -p $(FATTARGET) + cp -p $< $@ + +endif + altosuidir=$(datadir)/java install-altosuiJAVA: altosui.jar @@ -131,15 +159,23 @@ Manifest-fat.txt: altosui: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "$(FREETTS)/*" -Djava.library.path="$(libdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@ + echo 'exec java -cp "$(FREETTS)/*" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@ chmod +x $@ altosui-test: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "$(FREETTS)/*" -Djava.library.path="../libaltos" -jar altosui.jar "$$*"' >> $@ + echo 'exec java -cp "$(FREETTS)/*" -Djava.library.path="../libaltos/.libs" -jar altosui.jar "$$@"' >> $@ chmod +x $@ -$(LIBALTOS): +libaltos.so: + -rm -f "$@" + $(LN_S) ../libaltos/.libs/"$@" . + +libaltos.dylib: + -rm -f "$@" + $(LN_S) ../libaltos/"$@" . + +altos.dll: -rm -f "$@" $(LN_S) ../libaltos/"$@" . @@ -169,4 +205,4 @@ $(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA) $(WINDOWS_DIST): $(WINDOWS_FILES) altos-windows.nsi -rm -f $@ - makensis -Oaltos-windows.log "-XOutFile $@" "-DVERSION=$(VERSION)" altos-windows.nsi
\ No newline at end of file + makensis -Oaltos-windows.log "-XOutFile $@" "-DVERSION=$(VERSION)" altos-windows.nsi diff --git a/ao-tools/altosui/altos-windows.nsi b/ao-tools/altosui/altos-windows.nsi index 6ebec214..37777fd6 100644 --- a/ao-tools/altosui/altos-windows.nsi +++ b/ao-tools/altosui/altos-windows.nsi @@ -40,6 +40,9 @@ Section "Install Driver" InstDriver SetOutPath $TEMP File "../../telemetrum.inf" InstDrv::InstallDriver /NOUNLOAD "$TEMP\telemetrum.inf" + + SetOutPath $INSTDIR + File "../../telemetrum.inf" SectionEnd Section "AltosUI Application" diff --git a/ao-tools/altosui/altosui.1 b/ao-tools/altosui/altosui.1 index c3130fce..57fa4489 100644 --- a/ao-tools/altosui/altosui.1 +++ b/ao-tools/altosui/altosui.1 @@ -16,7 +16,7 @@ .\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. .\" .\" -.TH AO-VIEW 1 "altosui" "" +.TH ALTOSUI 1 "altosui" "" .SH NAME altosui \- Rocket flight monitor .SH SYNOPSIS @@ -24,21 +24,23 @@ altosui \- Rocket flight monitor .SH DESCRIPTION .I altosui connects to a TeleDongle or TeleMetrum device through a USB serial device. -It provides a user interface to monitor, record and review rocket flight data. +It provides a menu-oriented +user interface to monitor, record and review rocket flight data. .SH USAGE When connected to a TeleDongle device, altosui turns on the radio receiver and listens for telemetry packets. It displays the received telemetry data, and reports flight status via voice synthesis. All received telemetry information is recorded to a file. .P -When connected to a TeleMetrum device, altosui downloads the eeprom -data and stores it in a file. +When connected to a TeleMetrum device, altosui can be used to configure the +TeleMetrum, and to downloads the eeprom data and store it in a file. +.P +A number of other menu options exist, including the ability to export flight +data in different formats. .SH FILES All data log files are recorded into a user-specified directory -(default ~/AltOS). Files are named using the current date, the serial +(default ~/TeleMetrum). Files are named using the current date, the serial number of the reporting device, the flight number recorded in the data and either '.telem' for telemetry data or '.eeprom' for eeprom data. -.SH "SEE ALSO" -ao-view(1), ao-load(1), ao-eeprom(1) .SH AUTHOR Keith Packard diff --git a/ao-tools/libaltos/Makefile.am b/ao-tools/libaltos/Makefile.am index 4d29d80e..388d2104 100644 --- a/ao-tools/libaltos/Makefile.am +++ b/ao-tools/libaltos/Makefile.am @@ -1,11 +1,22 @@ JAVAC=javac -AM_CFLAGS="-I$(JVM_INCLUDE)" +AM_CFLAGS=-DLINUX -DPOSIX_TTY -I$(JVM_INCLUDE) AM_JAVACFLAGS=-encoding UTF-8 -lib_LTLIBRARIES=libaltos.la +altoslibdir=$(libdir)/altos + +altoslib_LTLIBRARIES=libaltos.la + +libaltos_la_LDFLAGS = -version-info 1:0:1 libaltos_la_SOURCES=\ - libaltos.c + libaltos.c \ + libaltos_wrap.c + +noinst_PROGRAMS=cjnitest + +cjnitest_LDADD=libaltos.la + +LIBS= HFILES=libaltos.h @@ -18,6 +29,8 @@ $(SWIG_FILE): libaltos.i0 $(HFILES) all-local: classlibaltos.stamp +libaltos_wrap.c: classlibaltos.stamp + classlibaltos.stamp: $(SWIG_FILE) swig -java -package libaltosJNI $(SWIG_FILE) mkdir -p libaltosJNI @@ -25,4 +38,4 @@ classlibaltos.stamp: $(SWIG_FILE) touch classlibaltos.stamp clean-local: - -rm -rf libaltosJNI *.class *.java classlibaltos.stamp $(SWIG_FILE)
\ No newline at end of file + -rm -rf libaltosJNI *.class *.java classlibaltos.stamp $(SWIG_FILE) libaltos_wrap.c |