- public void connect(String port_name) throws IOException, NoSuchPortException, PortInUseException {
- comm_port = new RXTXPort(port_name);
- open(comm_port);
- }
-
- void init() {
- reader = new AltosSerialReader();
+ public void open(altos_device device) throws FileNotFoundException {
+ 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);
+ }
+
+ 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();
+ }