本文整理匯總了Java中gnu.io.SerialPortEvent.FE屬性的典型用法代碼示例。如果您正苦於以下問題:Java SerialPortEvent.FE屬性的具體用法?Java SerialPortEvent.FE怎麽用?Java SerialPortEvent.FE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類gnu.io.SerialPortEvent
的用法示例。
在下文中一共展示了SerialPortEvent.FE屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serialEvent
/**
* Handles serial event.
*/
public void serialEvent(final int state, final InputStream inputStream, final SerialPortEvent e)
throws IOException{
switch (e.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
dataAvailable(inputStream);
break;
}
}
示例2: serialEvent
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32*1024*1024);
if(br.ready()) {
String line = br.readLine();
line = StringUtils.chomp(line);
line = line.replace(",",".");
response = line.trim();
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}", new Object[] { port, e.getMessage() });
}
break;
}
}
示例3: serialEvent
/**
* Event notification must be enabled for every event in setSerialPort() above.
* We can't call displayMessage.display() from this method, as we are not in FX thread.
*
* @param event
*/
@Override
public void serialEvent(SerialPortEvent event) {
switch(event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.FE:
case SerialPortEvent.OE:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
case SerialPortEvent.PE:
case SerialPortEvent.RI:
break;
case SerialPortEvent.DATA_AVAILABLE:
short[] payload;
int b;
while (true) {
try {
if (in.available() == 0) {
// No more data available.
break;
}
b = in.read();
} catch (IOException e) {
displayMessage.displayLogLater("error on receive: " + e.getMessage());
break;
}
payload = frameHandler.frameAssembler(b);
if (payload != null) {
displayMessage.displayFrameLater(frameHandler.displayFrame(payload));
}
}
break;
default:
displayMessage.displayLogLater("FrameHandler.serialEvent() - unknown event type: " + event.getEventType());
}
}
示例4: serialEvent
/**
* Serial port event listener.
* @param event an event
*/
public void serialEvent(final SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
// we get here if data has been received
String line = "";
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// read data
while (inputStream.available() > 0) {
while (reader.ready()) {
line = reader.readLine();
}
}
LOG.finer("Read: " + line);
if (!gpsFound) {
gpsFound = isGpsStream(line);
}
} catch (IOException e) {
LOG.log(Level.FINE, "IOException in serial-port -event", e);
}
break;
default:
break;
}
}
示例5: serialEvent
@Override
public void serialEvent(SerialPortEvent ev) {
switch (ev.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try {
while (in.available() > 0) {
if (!doRead()) {
break;
}
}
} catch (IOException ex) {
LOGGER.warn("I/O exception on read.", ex);
}
break;
default:
LOGGER.warn("Unknown case.");
break;
}
}
示例6: serialEvent
public void serialEvent(SerialPortEvent ev) {
switch( ev.getEventType() )
{
case SerialPortEvent.BI:
intp.println(String.format("EVENT: Received BI event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.CD:
intp.println(String.format("EVENT: Received CD event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.CTS:
intp.println(String.format("EVENT: Received CTS event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.DATA_AVAILABLE:
intp.println(String.format("EVENT: Received DATA_AVAIL event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.DSR:
intp.println(String.format("EVENT: Received DSR event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.FE:
intp.println(String.format("EVENT: Received FE event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.OE:
intp.println(String.format("EVENT: Received OE event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
intp.println(String.format("EVENT: Received OUT_BUF_EMPTY event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.PE:
intp.println(String.format("EVENT: Received PE event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
case SerialPortEvent.RI:
intp.println(String.format("EVENT: Received RI event: changed %s to %s", ev.getOldValue(), ev.getNewValue()));
break;
}
}
示例7: serialEvent
/**
* SerialPortEventListener method. This just calls the notify
* method on this object, so that all blocking methods are kicked
* awake whenever a serialEvent occurs.
*/
public void serialEvent(SerialPortEvent spe) {
switch(spe.getEventType())
{
case SerialPortEvent.BI:
logger.debug("SerialPortEvent: Break interrupt.");
break;
case SerialPortEvent.CD:
logger.debug("SerialPortEvent: Carrier detect.");
break;
case SerialPortEvent.CTS:
logger.debug("SerialPortEvent: Clear to send.");
break;
case SerialPortEvent.DATA_AVAILABLE:
logger.debug("SerialPortEvent: Data available at the serial port.");
break;
case SerialPortEvent.DSR:
logger.debug("SerialPortEvent: Data set ready.");
break;
case SerialPortEvent.FE:
logger.debug("SerialPortEvent: Framing error.");
break;
case SerialPortEvent.OE:
logger.debug("SerialPortEvent: Overrun error.");
break;
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
logger.debug("SerialPortEvent: Output buffer is empty.");
break;
case SerialPortEvent.PE:
logger.debug("SerialPortEvent: Parity error.");
break;
case SerialPortEvent.RI:
logger.debug("SerialPortEvent: Ring indicator.");
break;
}
logger.debug("SerialService.SerialEvent: oldValue=" + spe.getOldValue());
logger.debug("SerialService.SerialEvent: newValue=" + spe.getNewValue());
}
示例8: serialEvent
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32 * 1024 * 1024);
if (br.ready()) {
String line = br.readLine();
line = StringUtils.chomp(line);
line = line.replace(",", ".");
response = line.trim();
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}",
new Object[] { port, e.getMessage() });
}
break;
}
}
示例9: serialEvent
@Override
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
// we get here if data has been received
try {
// read data from serial device
while (serialPort.getInputStream().available() > 0) {
int currentByte = serialPort.getInputStream().read();
// Plugwise sends ASCII data, but for some unknown reason we sometimes get data with unsigned
// byte value >127 which in itself is very strange. We filter these out for the time being
if (currentByte < 128) {
readBuffer.put((byte) currentByte);
if (previousByte == CR && currentByte == LF) {
readBuffer.flip();
parseAndQueue(readBuffer);
readBuffer.clear();
previousByte = -1;
} else {
previousByte = currentByte;
}
}
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}", port, e.getMessage());
}
break;
}
}
示例10: serialEvent
/**
* 處理監控到的串口事件
*/
public void serialEvent(SerialPortEvent serialPortEvent) {
switch (serialPortEvent.getEventType()) {
case SerialPortEvent.BI: // 10 通訊中斷
ShowUtils.errorMessage("與串口設備通訊中斷");
break;
case SerialPortEvent.OE: // 7 溢位(溢出)錯誤
case SerialPortEvent.FE: // 9 幀錯誤
case SerialPortEvent.PE: // 8 奇偶校驗錯誤
case SerialPortEvent.CD: // 6 載波檢測
case SerialPortEvent.CTS: // 3 清除待發送數據
case SerialPortEvent.DSR: // 4 待發送數據準備好了
case SerialPortEvent.RI: // 5 振鈴指示
case SerialPortEvent.OUTPUT_BUFFER_EMPTY: // 2 輸出緩衝區已清空
break;
case SerialPortEvent.DATA_AVAILABLE: // 1 串口存在可用數據
byte[] data = null;
try {
if (serialport == null) {
ShowUtils.errorMessage("串口對象為空!監聽失敗!");
} else {
// 讀取串口數據
data = SerialPortManager.readFromPort(serialport);
dataView.append(ByteUtils.byteArrayToHexString(data,
true) + "\r\n");
}
} catch (Exception e) {
ShowUtils.errorMessage(e.toString());
// 發生讀取錯誤時顯示錯誤信息後退出係統
System.exit(0);
}
break;
}
}
示例11: serialEvent
@Override
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
/* Break interrupt */
case SerialPortEvent.BI:
/* Overrun error */
case SerialPortEvent.OE:
/* Framing error */
case SerialPortEvent.FE:
/* Parity error */
case SerialPortEvent.PE:
/* Carrier detect */
case SerialPortEvent.CD:
/* Clear to send */
case SerialPortEvent.CTS:
/* Data set ready */
case SerialPortEvent.DSR:
/* Ring indicator */
case SerialPortEvent.RI:
/* OUTPUT_BUFFER_EMPTY */
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
/* Data Available */
case SerialPortEvent.DATA_AVAILABLE:
SerialCommunication serialComm = new SerialCommunication(in);
serialComm.communicate();
break;
default:
close();
break;
}
}
示例12: serialEvent
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32*1024*1024);
while (br.ready()) {
String line = br.readLine();
line = StringUtils.chomp(line);
// little hack to overcome Locale limits of the RME Rain Manager
// note to the attentive reader : should we add support for system locale's
// in the Type classes? ;-)
line = line.replace(",",".");
line = line.trim();
if(previousLine==null) {
previousLine = line;
}
if(!previousLine.equals(line)) {
processData(line);
previousLine=line;
}
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}", new Object[] { port, e.getMessage() });
}
break;
}
}
示例13: serialEvent
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
// we get here if data has been received
boolean newlineFound = false;
if(readBuffer == null) {
readBuffer = ByteBuffer.allocate(maxBufferSize);
}
try {
// read data from serial device
while (serialPort.getInputStream().available() > 0) {
int aByte = serialPort.getInputStream().read();
if ((aByte)==13) {
readBuffer.put((byte)aByte);
int cr = serialPort.getInputStream().read();
readBuffer.put((byte)cr);
newlineFound = true;
break;
}
//Plugwise sends ASCII data, but for some unknown reason we sometimes get data with unsigned byte value >127
//which in itself is very strange. We filter these out for the time being
if(aByte < 128) {
readBuffer.put((byte)aByte);
}
}
// process data
if(readBuffer.position()!=0 && newlineFound==true) {
readBuffer.flip();
parseAndQueue(readBuffer);
readBuffer = null;
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}", new String[] { port, e.getMessage() });
}
break;
}
}
示例14: serialEvent
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32 * 1024 * 1024);
while (br.ready()) {
String line = br.readLine();
line = StringUtils.chomp(line);
// little hack to overcome Locale limits of the RME Rain Manager
// note to the attentive reader : should we add support for system locale's
// in the Type classes? ;-)
line = line.replace(",", ".");
line = line.trim();
if (previousLine == null) {
previousLine = line;
}
if (!previousLine.equals(line)) {
processData(line);
previousLine = line;
}
}
} catch (IOException e) {
logger.debug("Error receiving data on serial port {}: {}",
new Object[] { port, e.getMessage() });
}
break;
}
}