+ private void open() throws FileNotFoundException, AltosSerialInUseException {
+ synchronized (devices_opened) {
+ if (devices_opened.contains(device.getPath()))
+ throw new AltosSerialInUseException(device);
+ devices_opened.add(device.getPath());
+ }
+ close();
+ altos = libaltos.altos_open(device);
+ if (altos == null)
+ throw new FileNotFoundException(device.getPath());
+ input_thread = new Thread(this);
+ input_thread.start();
+ print("~\nE 0\n");
+ flush_output();
+ set_monitor(monitor_mode);
+ set_channel(AltosPreferences.channel(device.getSerial()));
+ set_callsign(AltosPreferences.callsign());
+ }
+
+ public void set_channel(int channel) {
+ if (altos != null) {
+ if (monitor_mode)
+ printf("m 0\nc r %d\nm 1\n", channel);
+ else
+ printf("c r %d\n", channel);
+ flush_output();
+ }