Replaced serial library with a newer one

Former-commit-id: 7ba3aaabba9b5e6ffaffc66612012babc8d3ce26
This commit is contained in:
Ziver Koc 2015-11-19 19:09:03 +01:00
parent 2df55ef214
commit c2138902f0
7 changed files with 14 additions and 26 deletions

Binary file not shown.

BIN
lib/jSerialComm-1.3.4.jar Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -22,13 +22,10 @@
package se.koc.hal.plugin.tellstick; package se.koc.hal.plugin.tellstick;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import se.koc.hal.plugin.tellstick.protocols.NexaSelfLearning;
import java.io.*; import java.io.*;
import com.fazecast.jSerialComm.SerialPort;
/** /**
* This version of the TwoWaySerialComm example makes use of the * This version of the TwoWaySerialComm example makes use of the
* SerialPortEventListener to avoid polling. * SerialPortEventListener to avoid polling.
@ -36,33 +33,24 @@ import java.io.*;
public class TellstickSerialComm extends Thread{ public class TellstickSerialComm extends Thread{
public static TellstickSerialComm instance; public static TellstickSerialComm instance;
private com.fazecast.jSerialComm.SerialPort serial;
private BufferedReader in; private BufferedReader in;
private OutputStream out; private Writer out;
private TellstickParser parser = new TellstickParser(); private TellstickParser parser = new TellstickParser();
private TellstickChangeListener listener; private TellstickChangeListener listener;
public void connect(String portName) throws Exception { public void connect(String portName) throws Exception {
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); serial = SerialPort.getCommPort(portName);
if (portIdentifier.isCurrentlyOwned()) { serial.setBaudRate(115200);
System.out.println("Error: Port is currently in use"); if(!serial.openPort())
} else { throw new IOException("Could not open port: "+portName);
CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); serial.setComPortTimeouts(
SerialPort.TIMEOUT_READ_SEMI_BLOCKING,
5000, 0);
if (commPort instanceof SerialPort) { in = new BufferedReader(new InputStreamReader(serial.getInputStream(), "UTF-8"));
SerialPort serialPort = (SerialPort) commPort; out = new BufferedWriter(new OutputStreamWriter(serial.getOutputStream(), "UTF-8"));
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
in = new BufferedReader(new InputStreamReader (serialPort.getInputStream()));
out = new BufferedOutputStream(serialPort.getOutputStream());
serialPort.disableReceiveTimeout();
serialPort.enableReceiveThreshold(1);
this.start();
} else {
System.out.println("Error: Only serial ports are handled by this example.");
}
}
} }
public void run() { public void run() {