summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ef00182)
This was a bit harder than expected as I had to wire up a way to shut
down the whole monitor idle window when you clicked on the cancel button.
Signed-off-by: Keith Packard <keithp@keithp.com>
AltosConfigData config_data;
AltosGPS gps;
AltosConfigData config_data;
AltosGPS gps;
- int AltosRSSI() throws TimeoutException, InterruptedException {
- link.printf("s\n");
- String line = link.get_reply_no_dialog(5000);
- if (line == null)
- throw new TimeoutException();
- String[] items = line.split("\\s+");
- if (items.length < 2)
- return 0;
- if (!items[0].equals("RSSI:"))
- return 0;
- int rssi = Integer.parseInt(items[1]);
- return rssi;
- }
-
void start_link() throws InterruptedException, TimeoutException {
if (remote) {
link.set_radio_frequency(frequency);
void start_link() throws InterruptedException, TimeoutException {
if (remote) {
link.set_radio_frequency(frequency);
- void stop_link() throws InterruptedException, TimeoutException {
+ boolean stop_link() throws InterruptedException, TimeoutException {
if (remote)
link.stop_remote();
if (remote)
link.stop_remote();
+ return link.reply_abort;
- void update_state(AltosState state) throws InterruptedException, TimeoutException {
+ boolean update_state(AltosState state) throws InterruptedException, TimeoutException {
+ boolean aborted = false;
try {
start_link();
fetch.update_state(state);
try {
start_link();
fetch.update_state(state);
+ if (!link.has_error && !link.reply_abort)
+ worked = true;
if (worked) {
if (remote)
state.set_rssi(link.rssi(), 0);
listener_state.battery = link.monitor_battery();
}
}
if (worked) {
if (remote)
state.set_rssi(link.rssi(), 0);
listener_state.battery = link.monitor_battery();
}
}
}
public void set_frequency(double in_frequency) {
}
public void set_frequency(double in_frequency) {
public void run() {
AltosState state = new AltosState();
try {
public void run() {
AltosState state = new AltosState();
try {
- while (!link.has_error) {
try {
link.config_data();
update_state(state);
listener.update(state, listener_state);
} catch (TimeoutException te) {
}
try {
link.config_data();
update_state(state);
listener.update(state, listener_state);
} catch (TimeoutException te) {
}
+ if (link.has_error || link.reply_abort) {
+ listener.failed();
+ break;
+ }
Thread.sleep(1000);
}
} catch (InterruptedException ie) {
Thread.sleep(1000);
}
} catch (InterruptedException ie) {
public interface AltosIdleMonitorListener {
public void update(AltosState state, AltosListenerState listener_state);
public interface AltosIdleMonitorListener {
public void update(AltosState state, AltosListenerState listener_state);
-}
\ No newline at end of file
+ public void failed();
+}
};
public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt";
};
public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt";
+// public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt";
public static final int ao_telemetry_standard_len = 32;
public static final int ao_telemetry_0_9_len = 95;
public static final int ao_telemetry_standard_len = 32;
public static final int ao_telemetry_0_9_len = 95;
public void set_callsign(String callsign) {
this.callsign = callsign;
public void set_callsign(String callsign) {
this.callsign = callsign;
- printf ("c c %s\n", callsign);
- flush_output();
+ if (callsign != null) {
+ printf ("c c %s\n", callsign);
+ flush_output();
+ }
}
public boolean is_loader() throws InterruptedException {
}
public boolean is_loader() throws InterruptedException {
if (telemetry_rate < 0)
telemetry_rate = AltosPreferences.telemetry_rate(serial);
set_telemetry_rate(telemetry_rate);
if (telemetry_rate < 0)
telemetry_rate = AltosPreferences.telemetry_rate(serial);
set_telemetry_rate(telemetry_rate);
- if (callsign.equals(""))
+ if (callsign == null || callsign.equals(""))
callsign = AltosPreferences.callsign();
set_callsign(callsign);
printf("p\nE 0\n");
callsign = AltosPreferences.callsign();
set_callsign(callsign);
printf("p\nE 0\n");
SwingUtilities.invokeLater(r);
}
SwingUtilities.invokeLater(r);
}
+ public void failed() {
+ Runnable r = new Runnable() {
+ public void run() {
+ close();
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
Container bag;
AltosUIFreqList frequencies;
JTextField callsign_value;
Container bag;
AltosUIFreqList frequencies;
JTextField callsign_value;
+ private void close() {
+ try {
+ disconnect();
+ } catch (Exception ex) {
+ System.out.printf("Exception %s\n", ex.toString());
+ for (StackTraceElement el : ex.getStackTrace())
+ System.out.printf("%s\n", el.toString());
+ }
+ setVisible(false);
+ dispose();
+ AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ }
+
public AltosIdleMonitorUI(JFrame in_owner)
throws FileNotFoundException, TimeoutException, InterruptedException {
public AltosIdleMonitorUI(JFrame in_owner)
throws FileNotFoundException, TimeoutException, InterruptedException {
serial = device.getSerial();
serial = device.getSerial();
try {
link = new AltosSerial(device);
try {
link = new AltosSerial(device);
} catch (Exception ex) {
idle_exception(in_owner, ex);
return;
} catch (Exception ex) {
idle_exception(in_owner, ex);
return;
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
- try {
- disconnect();
- } catch (Exception ex) {
- System.out.printf("Exception %s\n", ex.toString());
- for (StackTraceElement el : ex.getStackTrace())
- System.out.printf("%s\n", el.toString());
- }
- setVisible(false);
- dispose();
- AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);