summaryrefslogtreecommitdiff
path: root/ao-tools/altosui/AltosEepromDownload.java
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2010-11-20 17:40:49 +1000
committerAnthony Towns <aj@erisian.com.au>2010-11-20 17:40:49 +1000
commit081fbd5715f9d3d81d98e149fb95d40447c07a79 (patch)
tree073885e98179ef663f08aaaf52cb7e74c2c66427 /ao-tools/altosui/AltosEepromDownload.java
parent90b9bc4475011bead7117ed72fa5efa0f77b2813 (diff)
parent7920ed5c34b088f45ce4213b061ddd1ffe22cee8 (diff)
Merge branch 'buttonbox' of git://git.gag.com/fw/altos into buttonbox
Conflicts: ao-tools/altosui/AltosFlightUI.java
Diffstat (limited to 'ao-tools/altosui/AltosEepromDownload.java')
-rw-r--r--ao-tools/altosui/AltosEepromDownload.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/ao-tools/altosui/AltosEepromDownload.java b/ao-tools/altosui/AltosEepromDownload.java
index 8996b924..fb5dcfc0 100644
--- a/ao-tools/altosui/AltosEepromDownload.java
+++ b/ao-tools/altosui/AltosEepromDownload.java
@@ -26,7 +26,7 @@ import java.io.*;
import java.util.*;
import java.text.*;
import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.*;
import libaltosJNI.*;
@@ -78,7 +78,7 @@ public class AltosEepromDownload implements Runnable {
Thread eeprom_thread;
AltosEepromMonitor monitor;
- void CaptureLog() throws IOException, InterruptedException {
+ void CaptureLog() throws IOException, InterruptedException, TimeoutException {
int serial = 0;
int block, state_block = 0;
int addr;
@@ -97,8 +97,10 @@ public class AltosEepromDownload implements Runnable {
/* Pull the serial number out of the version information */
for (;;) {
- String line = serial_line.get_reply();
+ String line = serial_line.get_reply(1000);
+ if (line == null)
+ throw new TimeoutException();
if (line.startsWith("serial-number")) {
try {
serial = Integer.parseInt(line.substring(13).trim());
@@ -125,7 +127,9 @@ public class AltosEepromDownload implements Runnable {
any_valid = false;
monitor.set_value(state_names[state], state, block - state_block);
for (addr = 0; addr < 0x100;) {
- String line = serial_line.get_reply();
+ String line = serial_line.get_reply(1000);
+ if (line == null)
+ throw new TimeoutException();
int[] values = ParseHex(line);
if (values == null) {
@@ -228,10 +232,16 @@ public class AltosEepromDownload implements Runnable {
CaptureLog();
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
- device.getPath(),
+ device.toShortString(),
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException ie) {
+ } catch (TimeoutException te) {
+ JOptionPane.showMessageDialog(frame,
+ String.format("Connection to \"%s\" failed",
+ device.toShortString()),
+ "Connection Failed",
+ JOptionPane.ERROR_MESSAGE);
}
if (remote)
serial_line.printf("~");
@@ -256,18 +266,18 @@ public class AltosEepromDownload implements Runnable {
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
String.format("Cannot open device \"%s\"",
- device.getPath()),
+ device.toShortString()),
"Cannot open target device",
JOptionPane.ERROR_MESSAGE);
} catch (AltosSerialInUseException si) {
JOptionPane.showMessageDialog(frame,
String.format("Device \"%s\" already in use",
- device.getPath()),
+ device.toShortString()),
"Device in use",
JOptionPane.ERROR_MESSAGE);
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
- device.getPath(),
+ device.toShortString(),
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
}