ort gnu.io.*;
import java.io.*;
import java.util.*;
import com.call.dao.*;
public class SerialReader extends Observable implements Runnable,SerialPortEventListener
{
static CommPortIdentifier portId;
int delayRead = 100;
int numBytes; // buffer中的实际数据字节数
private static byte[] readBuffer = new byte[1024]; // 4k的buffer空间,缓存串口读入的数据
static Enumeration portList;
InputStream inputStream;
OutputStream outputStream;
static SerialPort serialPort;
HashMap serialParams;
Thread readThread;//本来是static类型的
//端口是否打开了
boolean isOpen = false;
// 端口读入数据事件触发后,等待n毫秒后再读取,以便让数据一次性读完
public static final String PARAMS_DELAY = "delay read"; // 延时等待端口数据准备的时间
public static final String PARAMS_TIMEOUT = "timeout"; // 超时时间
public static final String PARAMS_PORT = "port name"; // 端口名称
public static final String PARAMS_DATABITS = "data bits"; // 数据位
public static final String PARAMS_STOPBITS = "stop bits"; // 停止位
public static final String PARAMS_PARITY = "parity"; // 奇偶校验
public static final String PARAMS_RATE = "rate"; // 波特率
public boolean isOpen(){
温馨提示:答案为网友推荐,仅供参考