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>
void start_serial() throws InterruptedException {
if (remote) {
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();
}
}
serial_line.flush_input();
}
}
start_serial();
serial_line.printf("c s\nv\n");
for (;;) {
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);
if (line == null)
throw new TimeoutException();
get_int(line, "serial-number", serial);
/* 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(1000);
+ String line = serial_line.get_reply(5000);
if (line == null)
throw new TimeoutException();
if (line == null)
throw new TimeoutException();
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(1000);
+ String line = serial_line.get_reply(5000);
if (line == null)
throw new TimeoutException();
int[] values = ParseHex(line);
if (line == null)
throw new TimeoutException();
int[] values = ParseHex(line);
public void run () {
if (remote) {
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();
}
serial_line.printf("p\nE 0\n");
serial_line.flush_input();
}
public void actionPerformed(ActionEvent e) {
int channel = channels.getSelectedIndex();
reader.set_channel(channel);
public void actionPerformed(ActionEvent e) {
int channel = channels.getSelectedIndex();
reader.set_channel(channel);
- AltosPreferences.set_channel(serial, channel);
private void start_serial() throws InterruptedException {
if (remote) {
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();
}
}
serial.flush_input();
}
}
start_serial();
serial.printf("t\n");
for (;;) {
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))
if (line == null)
throw new TimeoutException();
if (get_string(line, "Igniter: drogue Status: ", status_name))
devices_opened.add(device.getPath());
}
altos = libaltos.altos_open(device);
devices_opened.add(device.getPath());
}
altos = libaltos.altos_open(device);
+ if (altos == null) {
+ close();
throw new FileNotFoundException(device.toShortString());
throw new FileNotFoundException(device.toShortString());
input_thread = new Thread(this);
input_thread.start();
print("~\nE 0\n");
input_thread = new Thread(this);
input_thread.start();
print("~\nE 0\n");
- set_monitor(monitor_mode);
+ }
+
+ public void set_radio() {
set_channel(AltosPreferences.channel(device.getSerial()));
set_callsign(AltosPreferences.callsign());
}
set_channel(AltosPreferences.channel(device.getSerial()));
set_callsign(AltosPreferences.callsign());
}
void set_channel(int channel) {
serial.set_channel(channel);
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)
}
public AltosTelemetryReader (AltosDevice in_device)
name = device.toShortString();
telem = new LinkedBlockingQueue<AltosLine>();
name = device.toShortString();
telem = new LinkedBlockingQueue<AltosLine>();
serial.add_monitor(telem);
}
}
serial.add_monitor(telem);
}
}