private void baudTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_baudTextActionPerformed
try {
int rate;
port.setSerialPortParams(
rate = Integer.parseInt(baudText.getText()),
port.getDataBits(),
port.getStopBits(),
port.getParity());
textPane.append("\nset baud rate to " + baudText.getText() + "\n\n");
baudRate = rate;
prefs.putInt("baudRate", baudRate);
} catch (UnsupportedCommOperationException ex) {
log.warning(ex.toString());
textPane.append("\n*** could not set baud rate : " + ex + "\n\n");
}
}
java类gnu.io.UnsupportedCommOperationException的实例源码
HyperTerminal.java 文件源码
项目:jaer
阅读 23
收藏 0
点赞 0
评论 0
RXTXCommInterface.java 文件源码
项目:FlashLib
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void open() {
try{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if (portIdentifier.isCurrentlyOwned())
System.out.println("Error: Port is currently in use");
else {
CommPort port = portIdentifier.open(this.getClass().getName(), getTimeout());//for now class name
if (port instanceof SerialPort){
serial = (SerialPort) port;
serial.setSerialPortParams(baudrate, SerialPort.DATABITS_8
, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serial.enableReceiveTimeout(timeout);
this.in = serial.getInputStream();
this.out = serial.getOutputStream();
isOpened = true;
}
else
System.out.println("Error: Only serial ports are handled");
}
}
catch (PortInUseException | UnsupportedCommOperationException | NoSuchPortException | IOException e) {
if(serial != null)
serial.close();
serial = null;
e.printStackTrace();
}
}
SerialDataInterface.java 文件源码
项目:scorekeeperfrontend
阅读 24
收藏 0
点赞 0
评论 0
public void open() throws PortInUseException, UnsupportedCommOperationException, TooManyListenersException, IOException
{
if (open)
{
log.info(commId.getName() + " already open, skipping");
return;
}
log.info("Opening port " + commId.getName());
buffer = new ByteBuffer();
port = (SerialPort)commId.open("TimerInterface-"+commId.getName(), 30000);
port.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
port.addEventListener(this);
port.notifyOnDataAvailable(true);
port.enableReceiveTimeout(30);
os = port.getOutputStream();
is = port.getInputStream();
open = true;
}
RXTXUtility.java 文件源码
项目:4mila-1.0
阅读 30
收藏 0
点赞 0
评论 0
public static FMilaSerialPort getPort(int speed, String port) throws IOException {
SerialPort serialPort;
try {
CommPortIdentifier comm = CommPortIdentifier.getPortIdentifier(port);
if (comm.isCurrentlyOwned()) {
throw new IOException("StationInUseError");
}
serialPort = comm.open("4mila", 2000);
serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.disableReceiveTimeout();
serialPort.disableReceiveFraming();
serialPort.disableReceiveThreshold();
serialPort.notifyOnDataAvailable(true);
serialPort.notifyOnOutputEmpty(true);
}
catch (PortInUseException | UnsupportedCommOperationException | NoSuchPortException e) {
throw new IOException(e.getMessage(), e);
}
return new RXTXSerialPort(serialPort);
}
SerialLinkFactory.java 文件源码
项目:Ardulink-2
阅读 23
收藏 0
点赞 0
评论 0
@Override
public LinkDelegate newLink(SerialLinkConfig config)
throws NoSuchPortException, PortInUseException,
UnsupportedCommOperationException, IOException {
CommPortIdentifier portIdentifier = CommPortIdentifier
.getPortIdentifier(config.getPort());
checkState(!portIdentifier.isCurrentlyOwned(),
"Port %s is currently in use", config.getPort());
final SerialPort serialPort = serialPort(config, portIdentifier);
StreamConnection connection = new StreamConnection(
serialPort.getInputStream(), serialPort.getOutputStream(),
config.getProto());
ConnectionBasedLink connectionBasedLink = new ConnectionBasedLink(
connection, config.getProto());
@SuppressWarnings("resource")
Link link = config.isQos() ? new QosLink(connectionBasedLink)
: connectionBasedLink;
waitForArdulink(config, connectionBasedLink);
return new LinkDelegate(link) {
@Override
public void close() throws IOException {
super.close();
serialPort.close();
}
};
}
RtuTransportRxtx.java 文件源码
项目:modbus-mini
阅读 21
收藏 0
点赞 0
评论 0
@Override
synchronized protected void openPort() throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException {
if (port != null)
return;
log.info("Opening port: " + portName);
CommPortIdentifier ident = CommPortIdentifier.getPortIdentifier(portName);
port = ident.open("ModbusRtuClient on " + portName, 2000);
port.setOutputBufferSize(buffer.length);
port.setInputBufferSize(buffer.length);
try {
port.setSerialPortParams(baudRate, dataBits, stopBits, parity);
port.enableReceiveTimeout(timeout);
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
} catch (UnsupportedCommOperationException e) {
close();
throw e;
}
log.info("Port opened: " + port.getName());
}
RFXComSerialConnector.java 文件源码
项目:openhab-hdl
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void connect(String device) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException {
CommPortIdentifier portIdentifier = CommPortIdentifier
.getPortIdentifier(device);
CommPort commPort = portIdentifier
.open(this.getClass().getName(), 2000);
serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(38400, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.enableReceiveThreshold(1);
serialPort.disableReceiveTimeout();
in = serialPort.getInputStream();
out = serialPort.getOutputStream();
out.flush();
if (in.markSupported()) {
in.reset();
}
readerThread = new SerialReader(in);
readerThread.start();
}
SerialConnector.java 文件源码
项目:openhab-hdl
阅读 23
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
**/
public void open() {
try {
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(serialPortName);
CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000);
serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.enableReceiveThreshold(1);
serialPort.disableReceiveTimeout();
serialOutput = new OutputStreamWriter(serialPort.getOutputStream(), "US-ASCII");
serialInput = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
setSerialEventHandler(this);
connected = true;
} catch (NoSuchPortException noSuchPortException) {
logger.error("open(): No Such Port Exception: ", noSuchPortException);
connected = false;
} catch (PortInUseException portInUseException) {
logger.error("open(): Port in Use Exception: ", portInUseException);
connected = false;
} catch (UnsupportedCommOperationException unsupportedCommOperationException) {
logger.error("open(): Unsupported Comm Operation Exception: ", unsupportedCommOperationException);
connected = false;
} catch (UnsupportedEncodingException unsupportedEncodingException) {
logger.error("open(): Unsupported Encoding Exception: ", unsupportedEncodingException);
connected = false;
} catch (IOException ioException) {
logger.error("open(): IO Exception: ", ioException);
connected = false;
}
}
SerialSketchUploader.java 文件源码
项目:arduino-remote-uploader
阅读 22
收藏 0
点赞 0
评论 0
public void openSerial(String serialPortName, int speed) throws PortInUseException, IOException, UnsupportedCommOperationException, TooManyListenersException {
CommPortIdentifier commPortIdentifier = findPort(serialPortName);
// initalize serial port
serialPort = (SerialPort) commPortIdentifier.open("Arduino", 2000);
inputStream = serialPort.getInputStream();
serialPort.addEventListener(this);
// activate the DATA_AVAILABLE notifier
serialPort.notifyOnDataAvailable(true);
serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
}
VCDSerialPort.java 文件源码
项目:EasyVote
阅读 22
收藏 0
点赞 0
评论 0
/**
* Versucht den seriellen Port zu �ffnen. Klappt nur, wenn er noch nicht von einer anderen Anwendung benutzt wird. Der jeweilige
* Port wird mit �bergeben. UNter Windows ist die Schreibweise "COM8" zum Beispeil unter Linux "dev/tts0"
* @param portName
* @return
* @throws PortInUseException
* @throws IOException
* @throws UnsupportedCommOperationException
*/
public boolean oeffneSerialPort(String portName) throws PortInUseException, IOException, UnsupportedCommOperationException
{
Boolean foundPort = false;
if (serialPortGeoeffnet != false) {
System.out.println("Serialport bereits ge�ffnet");
schliesseSerialPort();
return false;
}
System.out.println("�ffne Serialport");
enumComm = CommPortIdentifier.getPortIdentifiers();
while(enumComm.hasMoreElements()) {
serialPortId = (CommPortIdentifier) enumComm.nextElement();
System.out.println("SerialportIDs:" + serialPortId.getName());
if (portName.contentEquals(serialPortId.getName())) {
foundPort = true;
break;
}
}
if (foundPort != true) {
System.out.println("Serialport nicht gefunden: " + portName);
return false;
}
serialPort = (SerialPort) serialPortId.open("�ffnen und Senden", 500);
outputStream = serialPort.getOutputStream();
inputStream = serialPort.getInputStream();
serialPort.notifyOnDataAvailable(true);
serialPort.setSerialPortParams(baudrate, dataBits, stopBits, parity);
serialPortGeoeffnet = true;
return true;
}
FlashExporter.java 文件源码
项目:Animator
阅读 20
收藏 0
点赞 0
评论 0
/**
* Write contents of stream inputStream to serial port
*
* @param stream
* @throws IOException
* @throws UnsupportedCommOperationException
* @throws PortInUseException
*/
public void write(InputStream inputStream) throws IOException,
UnsupportedCommOperationException, PortInUseException {
SerialPort serialPort = initSerialPort(getPortIdentifier(deviceName));
OutputStream serialOut = serialPort.getOutputStream();
writeTo(inputStream, serialOut);
serialOut.close();
serialPort.close();
}
FlashExporter.java 文件源码
项目:Animator
阅读 23
收藏 0
点赞 0
评论 0
public void write(String rawString)
throws UnsupportedCommOperationException, PortInUseException,
IOException {
SerialPort serialPort = initSerialPort(getPortIdentifier(deviceName));
OutputStream serialOut = serialPort.getOutputStream();
writeTo(rawString, serialOut);
serialOut.close();
serialPort.close();
}
GPSSerialDevice.java 文件源码
项目:GpsdInspector
阅读 21
收藏 0
点赞 0
评论 0
/**
* Sets the speed for the serial port.
* @param speed the speed to set (e.g. 4800, 9600, 19200, 38400, ...)
*/
public void setSerialPortSpeed(int speed)
throws IOException
{
try
{
serial_port_.setSerialPortParams(speed,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
catch(UnsupportedCommOperationException e)
{
e.printStackTrace();
throw new IOException(e.getMessage());
}
}
LoopbackEventTest.java 文件源码
项目:opennmszh
阅读 23
收藏 0
点赞 0
评论 0
/**
* Sets the serial port parameters to 57600bps-8N1
*/
private void setSerialPortParameters() throws IOException {
int baudRate = 57600; // 57600bps
try {
// Set serial port to 57600bps-8N1..my favourite
serialPort.setSerialPortParams(
baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
//serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
} catch (UnsupportedCommOperationException ex) {
throw new IOException("Unsupported serial port parameter");
}
}
SimulatedEhzSmlReader.java 文件源码
项目:jpowermeter
阅读 21
收藏 0
点赞 0
评论 0
@Override
public SmartMeterReading read(String device) throws PortInUseException, IOException, UnsupportedCommOperationException {
BigDecimal READING_POWER = new BigDecimal(new Random().nextInt(5000));
READING_TOTAL = READING_TOTAL.add(READING_POWER.divide(new BigDecimal(WATT_TO_WATTHOURS), 2, BigDecimal.ROUND_DOWN));
READING_ONE = READING_TOTAL;
SmartMeterReading smartMeterReading = new SmartMeterReading();
smartMeterReading.meterTotal = new Meter(READING_TOTAL, "WH");
smartMeterReading.meterOne = new Meter(READING_ONE, "WH");
smartMeterReading.meterTwo = new Meter(READING_TWO, "WH");
smartMeterReading.power = new Meter(READING_POWER, "W");
smartMeterReading.complete = true;
log.debug(smartMeterReading.toString());
return smartMeterReading;
}
SerialService.java 文件源码
项目:dz
阅读 21
收藏 0
点赞 0
评论 0
public synchronized void setBaudRate(int baudRate) throws IOException {
NDC.push("setBaudRate(" + baudRate + ")");
try {
if(!isPortOpen())
throw new IOException(null, new IllegalStateException("Port Not Open"));
try {
// set baud rate
serialPort.setSerialPortParams(baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
logger.debug("Set baudRate=" + baudRate);
} catch(UnsupportedCommOperationException ex) {
throw new IOException("Failed to set baud rate: ", ex);
}
} finally {
NDC.pop();
}
}
FlashExporter.java 文件源码
项目:Animator
阅读 28
收藏 0
点赞 0
评论 0
/**
* Write contents of stream inputStream to serial port
*
* @param stream
* @throws IOException
* @throws UnsupportedCommOperationException
* @throws PortInUseException
*/
public void write(InputStream inputStream) throws IOException,
UnsupportedCommOperationException, PortInUseException {
SerialPort serialPort = initSerialPort(getPortIdentifier(deviceName));
OutputStream serialOut = serialPort.getOutputStream();
writeTo(inputStream, serialOut);
serialOut.close();
serialPort.close();
}
FlashExporter.java 文件源码
项目:Animator
阅读 20
收藏 0
点赞 0
评论 0
public void write(String rawString)
throws UnsupportedCommOperationException, PortInUseException,
IOException {
SerialPort serialPort = initSerialPort(getPortIdentifier(deviceName));
OutputStream serialOut = serialPort.getOutputStream();
writeTo(rawString, serialOut);
serialOut.close();
serialPort.close();
}
RFXComSerialConnector.java 文件源码
项目:openhab1-addons
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void connect(String device)
throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException {
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(device);
CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000);
serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.enableReceiveThreshold(1);
serialPort.disableReceiveTimeout();
in = serialPort.getInputStream();
out = serialPort.getOutputStream();
out.flush();
if (in.markSupported()) {
in.reset();
}
readerThread = new SerialReader(in);
readerThread.start();
}
SerialConnector.java 文件源码
项目:openhab1-addons
阅读 28
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
**/
public void open() {
try {
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(serialPortName);
CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000);
serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.enableReceiveThreshold(1);
serialPort.disableReceiveTimeout();
serialOutput = new OutputStreamWriter(serialPort.getOutputStream(), "US-ASCII");
serialInput = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
setSerialEventHandler(this);
connected = true;
} catch (NoSuchPortException noSuchPortException) {
logger.error("open(): No Such Port Exception: ", noSuchPortException);
connected = false;
} catch (PortInUseException portInUseException) {
logger.error("open(): Port in Use Exception: ", portInUseException);
connected = false;
} catch (UnsupportedCommOperationException unsupportedCommOperationException) {
logger.error("open(): Unsupported Comm Operation Exception: ", unsupportedCommOperationException);
connected = false;
} catch (UnsupportedEncodingException unsupportedEncodingException) {
logger.error("open(): Unsupported Encoding Exception: ", unsupportedEncodingException);
connected = false;
} catch (IOException ioException) {
logger.error("open(): IO Exception: ", ioException);
connected = false;
}
}
SerialRXTXComm.java 文件源码
项目:meshnet
阅读 19
收藏 0
点赞 0
评论 0
public SerialRXTXComm(CommPortIdentifier portIdentifier, Layer3Base layer3) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException, TooManyListenersException{
if (portIdentifier.isCurrentlyOwned()) {
throw new IOException("Port is currently in use");
} else {
CommPort commPort = portIdentifier.open(this.getClass().getName(),
TIME_OUT);
if (commPort instanceof SerialPort) {
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
inStream = serialPort.getInputStream();
outStream = serialPort.getOutputStream();
new SerialReceiver().start();
/*serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);*/
} else {
throw new IOException("This is not a serial port!.");
}
}
this.layer2 = new Layer2Serial(this, layer3);
}
SerialTransport.java 文件源码
项目:jzwave
阅读 24
收藏 0
点赞 0
评论 0
public SerialTransport(String serialPortName) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException
{
CommPortIdentifier usablePort = CommPortIdentifier.getPortIdentifier(serialPortName);
commPort = (SerialPort)usablePort.open("SerialTransport", 0);
commPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
commPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
commPort.setDTR(true);
commPort.setRTS(true);
commPort.setEndOfInputChar((byte)0x0D);
}
SerialConnection.java 文件源码
项目:ArduinoLight
阅读 24
收藏 0
点赞 0
评论 0
/**
* Tries to establish a serial connection with the given portId and baudRate and set the _serialOutputStream.
* If the connection could be established, _open is set to true.
* @param portId a CommPortIdentifier-object, used for identifying and connecting to a port.
* @param baudRate This has to match the settings in the arduino-code. Recommended value: 256000.
* @throws PortInUseException, IllegalArgumentException
* @throws IllegalStateException if there is already a connection active
*/
public synchronized void open(CommPortIdentifier portId, int baudRate) throws PortInUseException
{
if (_open)
throw new IllegalStateException("This SerialConnection is already opened.");
try
{
_serialPort = (SerialPort) portId.open(_APPNAME, _TIME_OUT); //throws PortInUse
_serialPort.setSerialPortParams(baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
_serialOutputStream = new BufferedOutputStream(_serialPort.getOutputStream());
_open = true;
ShutdownHandler.getInstance().addShutdownListener(this);
DebugConsole.print("SerialConnection", "open", "Connecting successful!");
}
catch (UnsupportedCommOperationException | IOException ex)
{
DebugConsole.print("SerialConnection", "open", ex.toString());
throw new IllegalArgumentException(ex);
}
}
LoopbackEventTest.java 文件源码
项目:OpenNMS
阅读 20
收藏 0
点赞 0
评论 0
/**
* Sets the serial port parameters to 57600bps-8N1
*/
private void setSerialPortParameters() throws IOException {
int baudRate = 57600; // 57600bps
try {
// Set serial port to 57600bps-8N1..my favourite
serialPort.setSerialPortParams(
baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
//serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
} catch (UnsupportedCommOperationException ex) {
throw new IOException("Unsupported serial port parameter");
}
}
SerialPortManager.java 文件源码
项目:SerialPortDemo
阅读 32
收藏 0
点赞 0
评论 0
/**
* 打开串口
*
* @param portName
* 端口名称
* @param baudrate
* 波特率
* @return 串口对象
* @throws SerialPortParameterFailure
* 设置串口参数失败
* @throws NotASerialPort
* 端口指向设备不是串口类型
* @throws NoSuchPort
* 没有该端口对应的串口设备
* @throws PortInUse
* 端口已被占用
*/
public static final SerialPort openPort(String portName, int baudrate)
throws SerialPortParameterFailure, NotASerialPort, NoSuchPort,
PortInUse {
try {
// 通过端口名识别端口
CommPortIdentifier portIdentifier = CommPortIdentifier
.getPortIdentifier(portName);
// 打开端口,并给端口名字和一个timeout(打开操作的超时时间)
CommPort commPort = portIdentifier.open(portName, 2000);
// 判断是不是串口
if (commPort instanceof SerialPort) {
SerialPort serialPort = (SerialPort) commPort;
try {
// 设置一下串口的波特率等参数
serialPort.setSerialPortParams(baudrate,
SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {
throw new SerialPortParameterFailure();
}
return serialPort;
} else {
// 不是串口
throw new NotASerialPort();
}
} catch (NoSuchPortException e1) {
throw new NoSuchPort();
} catch (PortInUseException e2) {
throw new PortInUse();
}
}
StreamCommand.java 文件源码
项目:jaer
阅读 65
收藏 0
点赞 0
评论 0
/**
* set the baud rate used for communication; if the connection is
* already established, the baud rate will be changed on the fly
*
* @param baudRate the new baud rate
* @throws UnsupportedCommOperationException
*/
public void setBaudRate(int baudRate) throws UnsupportedCommOperationException
{
this.baudRate= baudRate;
if (isConnected()) {
port.setSerialPortParams(
baudRate,
dataBits,
stopBits,
paritiyFlags);
}
}
StreamCommandTest.java 文件源码
项目:jaer
阅读 23
收藏 0
点赞 0
评论 0
private void baudTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_baudTextActionPerformed
try {
streamer.setBaudRate(Integer.parseInt(baudText.getText()));
} catch (UnsupportedCommOperationException ex) {
logString("*** cannot set baud rate : " + ex + "\n");
}
}
HWP_UART.java 文件源码
项目:jaer
阅读 21
收藏 0
点赞 0
评论 0
public synchronized void setBaudRate(int baudRate) throws UnsupportedCommOperationException {
if (isOpen()) {
serialPort.setSerialPortParams(baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
}
HWP_UART.java 文件源码
项目:jaer
阅读 22
收藏 0
点赞 0
评论 0
public synchronized void setHardwareFlowControl(boolean flowControlFlag) throws UnsupportedCommOperationException {
if (isOpen()) {
if (flowControlFlag) {
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_OUT | SerialPort.FLOWCONTROL_RTSCTS_IN);
serialPort.setRTS(true);
log.info("Set HW flow control on!");
} else {
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
log.info("Set HW flow control off!");
}
}
}
RXTXCommInterface.java 文件源码
项目:FlashLib
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void setReadTimeout(int millis) {
timeout = millis;
if(serial != null){
try {
serial.enableReceiveTimeout(millis);
} catch (UnsupportedCommOperationException e) {
}
}
}