public boolean isReady() {
return ready;
}
public void setReady(boolean ready) {
this.ready = ready;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public void paint(Graphics g ){
}
public void initPort(){
try {
portId = CommPortIdentifier.getPortIdentifier("COM1");
serialPort = (SerialPort)portId.open("Serial_Communication", 2000);
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
is = serialPort.getInputStream();
} catch (NoSuchPortException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (PortInUseException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (UnsupportedCommOperationException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
public void cleanPort(){
try {
is.close();
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
serialPort.close();
}
public void init(){
initPort();
JobThread job = new JobThread(this);
Thread t = new Thread(job);
t.start();
this.setBounds(0,0,0,0);
this.repaint();
}
public void start(){
}
public void stop(){
cleanPort();
}
private void showPorts(Graphics g ){
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-36137-4.html
必须予以坚决的回击
实力不如别人
抽检是随机调查