diff options
author | Keith Packard <keithp@keithp.com> | 2010-11-13 16:07:04 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-11-13 16:07:04 -0800 |
commit | dcfa56498d1b65a213b8aba9cbd6c4806532383c (patch) | |
tree | 196742b9dea168b18f6fbadaa54573a15fefd2b3 /ao-tools/altosui/AltosConfig.java | |
parent | 8463ffcaca6bcd31e645aba71c171f548dce96d8 (diff) |
altosui: Open serial device at 'new' time. Prohibit duplicate opens.
With the per-serial UI, there's never a reason to create a serial
device without opening it right away. This eliminates the bug caused
by not opening the serial device for telemetry reception.
Serial devices can now be opened only once; this eliminates errors
when trying to reflash or configure devices while receiving telemetry.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/altosui/AltosConfig.java')
-rw-r--r-- | ao-tools/altosui/AltosConfig.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ao-tools/altosui/AltosConfig.java b/ao-tools/altosui/AltosConfig.java index 30f7d541..09e204a9 100644 --- a/ao-tools/altosui/AltosConfig.java +++ b/ao-tools/altosui/AltosConfig.java @@ -231,10 +231,9 @@ public class AltosConfig implements Runnable, ActionListener { product = new string_ref("unknown"); device = AltosDeviceDialog.show(owner, AltosDevice.product_any); - serial_line = new AltosSerial(); if (device != null) { try { - serial_line.open(device); + serial_line = new AltosSerial(device); if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; config_thread = new Thread(this); @@ -245,6 +244,12 @@ public class AltosConfig implements Runnable, ActionListener { device.getPath()), "Cannot open target device", JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(owner, + String.format("Device \"%s\" already in use", + device.getPath()), + "Device in use", + JOptionPane.ERROR_MESSAGE); } catch (IOException ee) { JOptionPane.showMessageDialog(owner, device.getPath(), |