projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Broke TeleMetrum GPS reporting by holding the GPS mutex too much
[fw/altos]
/
altosui
/
AltosSerial.java
diff --git
a/altosui/AltosSerial.java
b/altosui/AltosSerial.java
index 6cee1609e1db5ba6815bc0a6fd7e7195e16861f1..b85a7fa1d4bf3e19984290d9cab4a0180a40006f 100644
(file)
--- a/
altosui/AltosSerial.java
+++ b/
altosui/AltosSerial.java
@@
-21,17
+21,12
@@
package altosui;
package altosui;
-import java.lang.*;
import java.io.*;
import java.io.*;
-import java.util.concurrent.*;
import java.util.*;
import java.util.*;
-import java.text.*;
import java.awt.*;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_2.*;
+import org.altusmetrum.altosuilib_1.*;
import libaltosJNI.*;
import libaltosJNI.*;
@@
-62,11
+57,8
@@
public class AltosSerial extends AltosLink {
public void flush_output() {
super.flush_output();
if (altos != null) {
public void flush_output() {
super.flush_output();
if (altos != null) {
- if (libaltos.altos_flush(altos) != 0) {
- libaltos.altos_close(altos);
- altos = null;
- abort_reply();
- }
+ if (libaltos.altos_flush(altos) != 0)
+ close_serial();
}
}
}
}
@@
-77,7
+69,7
@@
public class AltosSerial extends AltosLink {
Object[] options = { "Cancel" };
JOptionPane pane = new JOptionPane();
Object[] options = { "Cancel" };
JOptionPane pane = new JOptionPane();
- pane.setMessage(String.format("Connecting to %s, %7.3f MHz
", device.toShortString(), frequency
));
+ pane.setMessage(String.format("Connecting to %s, %7.3f MHz
as %s", device.toShortString(), frequency, callsign
));
pane.setOptions(options);
pane.setInitialValue(null);
pane.setOptions(options);
pane.setInitialValue(null);
@@
-127,6
+119,17
@@
public class AltosSerial extends AltosLink {
SwingUtilities.invokeLater(r);
}
SwingUtilities.invokeLater(r);
}
+ private void close_serial() {
+ synchronized (devices_opened) {
+ devices_opened.remove(device.getPath());
+ }
+ if (altos != null) {
+ libaltos.altos_free(altos);
+ altos = null;
+ }
+ abort_reply();
+ }
+
public void close() {
if (remote) {
try {
public void close() {
if (remote) {
try {
@@
-137,9
+140,8
@@
public class AltosSerial extends AltosLink {
if (in_reply != 0)
System.out.printf("Uh-oh. Closing active serial device\n");
if (in_reply != 0)
System.out.printf("Uh-oh. Closing active serial device\n");
- if (altos != null) {
- libaltos.altos_close(altos);
- }
+ close_serial();
+
if (input_thread != null) {
try {
input_thread.interrupt();
if (input_thread != null) {
try {
input_thread.interrupt();
@@
-148,13
+150,6
@@
public class AltosSerial extends AltosLink {
}
input_thread = null;
}
}
input_thread = null;
}
- if (altos != null) {
- libaltos.altos_free(altos);
- altos = null;
- }
- synchronized (devices_opened) {
- devices_opened.remove(device.getPath());
- }
if (debug)
System.out.printf("Closing %s\n", device.getPath());
}
if (debug)
System.out.printf("Closing %s\n", device.getPath());
}
@@
-162,10
+157,18
@@
public class AltosSerial extends AltosLink {
private void putc(char c) {
if (altos != null)
if (libaltos.altos_putchar(altos, c) != 0) {
private void putc(char c) {
if (altos != null)
if (libaltos.altos_putchar(altos, c) != 0) {
- libaltos.altos_close(altos);
- altos = null;
- abort_reply();
+ close_serial();
+ }
+ }
+
+ public void putchar(byte c) {
+ if (altos != null) {
+ if (debug)
+ System.out.printf(" %02x", (int) c & 0xff);
+ if (libaltos.altos_putchar(altos, (char) c) != 0) {
+ close_serial();
}
}
+ }
}
public void print(String data) {
}
public void print(String data) {