As we all know, jSerialCom is a high-quality Java library for reading serial data; Previously, RXTX was also a good choice,
So in jSerialCom, how to catch all kinds of interrupt events like RXTX?
In RXTX, there are these java statements to catch various interrupts event
serialPort.notifyOnFramingError (true); serialPort.notifyOnBreakInterrupt (true);
then,in catch code,we can write:
switch ( event.getEventType ()) {
case SerialPortEvent.FE :
break;
case SerialPortEvent.OUTPUT_ BUFFER_ EMPTY:
break;
case SerialPortEvent.DATA_ AVAILABLE:
//read data of serial port ...
break;
case default:
break;
But what about of jSerialCom? There is only 'LISTENING_EVENT_DATA_AVAILABLE' like blow code ? No need to catch other interrupt Requests?
if ( event.getEventType () != SerialPort.LISTENING_EVENT_DATA_AVAILABLE ) {
return;
}
Neither the current source code nor the API documentation has such a feature.
Fazecast/jSerialComm
public final void waitForSerialEvent() throws Exception
Windows:
JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configEventFlags(JNIEnv *env, jobject obj, jlong serialPortFD)
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_waitForEvent(JNIEnv *env, jobject obj, jlong serialPortFD)
Posix:
JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configEventFlags(JNIEnv *env, jobject obj, jlong serialPortFD)
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_waitForEvent(JNIEnv *env, jobject obj, jlong serialPortFD)
Documentation:
Home - jSerialComm
API Documentation
Class SerialPortEvent
Class SerialPortIOException