⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxtxserialport.java

📁 这是一款基于PlaceLab软件开发的导航系统中间件的客户端程序.
💻 JAVA
字号:
package org.placelab.demo.virtualgps;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import org.placelab.core.PlacelabProperties;import gnu.io.SerialPort;import gnu.io.UnsupportedCommOperationException;import gnu.io.NoSuchPortException;import gnu.io.CommPortIdentifier;import gnu.io.PortInUseException;public class RXTXSerialPort extends IOPort {	private InputStream in;	private OutputStream out;		public RXTXSerialPort () {				String device = PlacelabProperties.get("placelab.gps_device");		String baud = PlacelabProperties.get("placelab.gps_baud");				if (device.length() == 0) {			System.err.println("ERROR: placelab.gps_device not set.");			return;		}				if (baud.length()==0) {			baud = "4800";		}			    SerialPort sp;	    CommPortIdentifier p;	    InputStream inputStream;	    OutputStream outputStream;	    try {	      p = CommPortIdentifier.getPortIdentifier(device);	      sp = (SerialPort) p.open("placelabgps", 1000);	      sp.setSerialPortParams(Integer.parseInt(baud),	                             SerialPort.DATABITS_8,	                             SerialPort.STOPBITS_1,	                             SerialPort.PARITY_NONE);	      in = sp.getInputStream();	      out = sp.getOutputStream();	    }	    catch (UnsupportedCommOperationException e) {	    		System.err.println("ERR: UnsupportedCommOperationException: " + e);			return;		} catch (NoSuchPortException e) {			System.err.println("ERR: NoSuchPortException: " + e);			return;		} catch (PortInUseException e) {			System.err.println("ERR: PortInUseException: " + e);			return;		} catch (IOException e) {			System.err.println("ERR: IOException: " + e);			return;		}	}		public InputStream getInputStream () {		return in;	}		public OutputStream getOutputStream () {		return out;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -