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