projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosui: Move AltosConfigData.java to library
[fw/altos]
/
altosui
/
AltosSerial.java
diff --git
a/altosui/AltosSerial.java
b/altosui/AltosSerial.java
index 0a531aa96faa8b2b0b27fc0f412b78c920648231..161f0e905995bab3bac4389432ca52034daa82c8 100644
(file)
--- a/
altosui/AltosSerial.java
+++ b/
altosui/AltosSerial.java
@@
-31,6
+31,7
@@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.*;
+import org.altusmetrum.AltosLib.*;
import libaltosJNI.*;
import libaltosJNI.*;
@@
-40,7
+41,7
@@
import libaltosJNI.*;
* threads.
*/
* threads.
*/
-public class AltosSerial implements Runnable {
+public class AltosSerial implements Runnable
, AltosLink
{
static java.util.List<String> devices_opened = Collections.synchronizedList(new LinkedList<String>());
static java.util.List<String> devices_opened = Collections.synchronizedList(new LinkedList<String>());
@@
-55,7
+56,7
@@
public class AltosSerial implements Runnable {
boolean monitor_mode;
int telemetry;
double frequency;
boolean monitor_mode;
int telemetry;
double frequency;
- static boolean debug;
+
public
static boolean debug;
boolean remote;
LinkedList<String> pending_output = new LinkedList<String>();
Frame frame;
boolean remote;
LinkedList<String> pending_output = new LinkedList<String>();
Frame frame;
@@
-323,8
+324,10
@@
public class AltosSerial implements Runnable {
}
altos = device.open();
if (altos == null) {
}
altos = device.open();
if (altos == null) {
+ final String message = device.getErrorString();
close();
close();
- throw new FileNotFoundException(device.toShortString());
+ throw new FileNotFoundException(String.format("%s (%s)",
+ device.toShortString(), message));
}
if (debug)
System.out.printf("Open %s\n", device.getPath());
}
if (debug)
System.out.printf("Open %s\n", device.getPath());
@@
-361,12
+364,28
@@
public class AltosSerial implements Runnable {
}
}
}
}
+ private void set_radio_freq(int frequency) {
+ if (altos != null) {
+ if (monitor_mode)
+ printf("m 0\nc F %d\nm %x\n",
+ frequency, telemetry_len());
+ else
+ printf("c F %d\n", frequency);
+ flush_output();
+ }
+ }
+
public void set_radio_frequency(double frequency,
public void set_radio_frequency(double frequency,
+ boolean has_frequency,
boolean has_setting,
int cal) {
if (debug)
boolean has_setting,
int cal) {
if (debug)
- System.out.printf("set_radio_frequency %7.3f %b %d\n", frequency, has_setting, cal);
- if (has_setting)
+ System.out.printf("set_radio_frequency %7.3f (freq %b) (set %b) %d\n", frequency, has_frequency, has_setting, cal);
+ if (frequency == 0)
+ return;
+ if (has_frequency)
+ set_radio_freq((int) Math.floor (frequency * 1000));
+ else if (has_setting)
set_radio_setting(AltosConvert.radio_frequency_to_setting(frequency, cal));
else
set_channel(AltosConvert.radio_frequency_to_channel(frequency));
set_radio_setting(AltosConvert.radio_frequency_to_setting(frequency, cal));
else
set_channel(AltosConvert.radio_frequency_to_channel(frequency));
@@
-374,8
+393,11
@@
public class AltosSerial implements Runnable {
public void set_radio_frequency(double in_frequency) throws InterruptedException, TimeoutException {
frequency = in_frequency;
public void set_radio_frequency(double in_frequency) throws InterruptedException, TimeoutException {
frequency = in_frequency;
+ if (frequency == 0.0)
+ frequency = AltosPreferences.frequency(device.getSerial());
config_data();
set_radio_frequency(frequency,
config_data();
set_radio_frequency(frequency,
+ config_data.radio_frequency != 0,
config_data.radio_setting != 0,
config_data.radio_calibration);
}
config_data.radio_setting != 0,
config_data.radio_calibration);
}
@@
-417,9
+439,9
@@
public class AltosSerial implements Runnable {
if (debug)
System.out.printf("start remote %7.3f\n", frequency);
if (frequency == 0.0)
if (debug)
System.out.printf("start remote %7.3f\n", frequency);
if (frequency == 0.0)
- frequency = AltosPreferences.frequency(device.getSerial());
+ frequency = Altos
UI
Preferences.frequency(device.getSerial());
set_radio_frequency(frequency);
set_radio_frequency(frequency);
- set_callsign(AltosPreferences.callsign());
+ set_callsign(Altos
UI
Preferences.callsign());
printf("p\nE 0\n");
flush_input();
remote = true;
printf("p\nE 0\n");
flush_input();
remote = true;