projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosui: switch channel selector to combo box. Shorten displayed device names
[fw/altos]
/
ao-tools
/
altosui
/
AltosEepromDownload.java
diff --git
a/ao-tools/altosui/AltosEepromDownload.java
b/ao-tools/altosui/AltosEepromDownload.java
index bd9e4b4853920297569fdb7f6baa818f1b593d9d..fb5dcfc0db06574611cc00b4f277f6be6a5c9ca5 100644
(file)
--- 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.*;
import java.text.*;
import java.util.prefs.*;
-import java.util.concurrent.
LinkedBlockingQueue
;
+import java.util.concurrent.
*
;
import libaltosJNI.*;
import libaltosJNI.*;
@@
-78,7
+78,7
@@
public class AltosEepromDownload implements Runnable {
Thread eeprom_thread;
AltosEepromMonitor monitor;
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;
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 (;;) {
/* 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());
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;) {
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) {
int[] values = ParseHex(line);
if (values == null) {
@@
-228,10
+232,16
@@
public class AltosEepromDownload implements Runnable {
CaptureLog();
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
CaptureLog();
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
- device.
getPath
(),
+ device.
toShortString
(),
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException ie) {
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("~");
}
if (remote)
serial_line.printf("~");
@@
-244,12
+254,11
@@
public class AltosEepromDownload implements Runnable {
frame = given_frame;
device = AltosDeviceDialog.show(frame, AltosDevice.product_any);
frame = given_frame;
device = AltosDeviceDialog.show(frame, AltosDevice.product_any);
- serial_line = new AltosSerial();
remote = false;
if (device != null) {
try {
remote = false;
if (device != null) {
try {
- serial_line
.open
(device);
+ serial_line
= new AltosSerial
(device);
if (!device.matchProduct(AltosDevice.product_telemetrum))
remote = true;
eeprom_thread = new Thread(this);
if (!device.matchProduct(AltosDevice.product_telemetrum))
remote = true;
eeprom_thread = new Thread(this);
@@
-257,12
+266,18
@@
public class AltosEepromDownload implements Runnable {
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
String.format("Cannot open device \"%s\"",
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
String.format("Cannot open device \"%s\"",
- device.
getPath
()),
+ device.
toShortString
()),
"Cannot open target device",
JOptionPane.ERROR_MESSAGE);
"Cannot open target device",
JOptionPane.ERROR_MESSAGE);
+ } catch (AltosSerialInUseException si) {
+ JOptionPane.showMessageDialog(frame,
+ String.format("Device \"%s\" already in use",
+ device.toShortString()),
+ "Device in use",
+ JOptionPane.ERROR_MESSAGE);
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
} catch (IOException ee) {
JOptionPane.showMessageDialog(frame,
- device.
getPath
(),
+ device.
toShortString
(),
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
}
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
}