altosui: New AltosSerial.set_radio function sets channel/call
authorKeith Packard <keithp@keithp.com>
Wed, 24 Nov 2010 03:08:07 +0000 (19:08 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 24 Nov 2010 03:10:27 +0000 (19:10 -0800)
Use this anytime you need to set the device radio channel and call
sign, either for telemetry reception or packet mode origination. This
uses the saved callsign and per-device radio channel number. Do not
use this when opening a telemetrum as there won't be a saved channel number.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosConfig.java
ao-tools/altosui/AltosEepromDownload.java
ao-tools/altosui/AltosFlightUI.java
ao-tools/altosui/AltosIgnite.java
ao-tools/altosui/AltosSerial.java
ao-tools/altosui/AltosTelemetryReader.java

index 6bda20d804135880b7511f8b4e89bba806fa3d42..52dbfd795998b98d7ce7f84f828519cdd27ba2ad 100644 (file)
@@ -109,9 +109,8 @@ public class AltosConfig implements Runnable, ActionListener {
 
        void start_serial() throws InterruptedException {
                if (remote) {
-                       serial_line.set_channel(AltosPreferences.channel(device.getSerial()));
-                       serial_line.set_callsign(AltosPreferences.callsign());
-                       serial_line.printf("p\n");
+                       serial_line.set_radio();
+                       serial_line.printf("p\nE 0\n");
                        serial_line.flush_input();
                }
        }
@@ -128,7 +127,7 @@ public class AltosConfig implements Runnable, ActionListener {
                        start_serial();
                        serial_line.printf("c s\nv\n");
                        for (;;) {
-                               String line = serial_line.get_reply(1000);
+                               String line = serial_line.get_reply(5000);
                                if (line == null)
                                        throw new TimeoutException();
                                get_int(line, "serial-number", serial);
index fb5dcfc0db06574611cc00b4f277f6be6a5c9ca5..02fc36f298cfc6922710aaace084a6fa091e1eb0 100644 (file)
@@ -97,7 +97,7 @@ public class AltosEepromDownload implements Runnable {
                /* Pull the serial number out of the version information */
 
                for (;;) {
-                       String  line = serial_line.get_reply(1000);
+                       String  line = serial_line.get_reply(5000);
 
                        if (line == null)
                                throw new TimeoutException();
@@ -127,7 +127,7 @@ 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(1000);
+                               String  line = serial_line.get_reply(5000);
                                if (line == null)
                                        throw new TimeoutException();
                                int[] values = ParseHex(line);
@@ -216,8 +216,7 @@ public class AltosEepromDownload implements Runnable {
 
        public void run () {
                if (remote) {
-                       serial_line.set_channel(AltosPreferences.channel(device.getSerial()));
-                       serial_line.set_callsign(AltosPreferences.callsign());
+                       serial_line.set_radio();
                        serial_line.printf("p\nE 0\n");
                        serial_line.flush_input();
                }
index 732f7395565eee41b2d0388c4474cd4f8ddb99b1..24d25bd7c46a0a4683fc732ce4441711a48a3fed 100644 (file)
@@ -148,7 +148,6 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                                public void actionPerformed(ActionEvent e) {
                                        int channel = channels.getSelectedIndex();
                                        reader.set_channel(channel);
-                                       AltosPreferences.set_channel(serial, channel);
                                }
                        });
                        c.gridx = 0;
index 8e92ec1b71531df85a3bdb210521a380876338e4..75c0a17a9bb0fb8bfec7cdbf8ced2d4d050ce956 100644 (file)
@@ -35,9 +35,8 @@ public class AltosIgnite {
 
        private void start_serial() throws InterruptedException {
                if (remote) {
-                       serial.set_channel(AltosPreferences.channel(device.getSerial()));
-                       serial.set_callsign(AltosPreferences.callsign());
-                       serial.printf("~\np\n");
+                       serial.set_radio();
+                       serial.printf("p\nE 0\n");
                        serial.flush_input();
                }
        }
@@ -100,7 +99,7 @@ public class AltosIgnite {
                start_serial();
                serial.printf("t\n");
                for (;;) {
-                       String line = serial.get_reply(1000);
+                       String line = serial.get_reply(5000);
                        if (line == null)
                                throw new TimeoutException();
                        if (get_string(line, "Igniter: drogue Status: ", status_name))
index 8a6ad05e823cfac824121a8afc08ca6e804f18c2..b19143e58b7080070457d606a93e8798deaf9a71 100644 (file)
@@ -198,13 +198,18 @@ public class AltosSerial implements Runnable {
                        devices_opened.add(device.getPath());
                }
                altos = libaltos.altos_open(device);
-               if (altos == null)
+               if (altos == null) {
+                       close();
                        throw new FileNotFoundException(device.toShortString());
+               }
                input_thread = new Thread(this);
                input_thread.start();
                print("~\nE 0\n");
+               set_monitor(false);
                flush_output();
-               set_monitor(monitor_mode);
+       }
+
+       public void set_radio() {
                set_channel(AltosPreferences.channel(device.getSerial()));
                set_callsign(AltosPreferences.callsign());
        }
index de5f50e93052895ac7d7e9aefd06ec48ccdae8c9..6c5a93978c69a4156e0e44fe3b94b3ea7a9c92c0 100644 (file)
@@ -44,10 +44,7 @@ class AltosTelemetryReader extends AltosFlightReader {
 
        void set_channel(int channel) {
                serial.set_channel(channel);
-       }
-
-       void set_callsign(String callsign) {
-               serial.set_callsign(callsign);
+               AltosPreferences.set_channel(device.getSerial(), channel);
        }
 
        public AltosTelemetryReader (AltosDevice in_device)
@@ -58,6 +55,7 @@ class AltosTelemetryReader extends AltosFlightReader {
                name = device.toShortString();
 
                telem = new LinkedBlockingQueue<AltosLine>();
+               serial.set_radio();
                serial.add_monitor(telem);
        }
 }