Class SerialInterrupt
- java.lang.Object
-
- com.pi4j.jni.SerialInterrupt
-
public class SerialInterrupt extends Object
This class provides static methods to configure the native Pi4J library to listen to serial interrupts and invoke callbacks into this class. Additionally, this class provides a listener registration allowing Java consumers to subscribe to serial data receive events.
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
- See Also:
- https://pi4j.com/
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addListener(int fileDescriptor, SerialInterruptListener listener)
Java consumer code can all this method to register itself as a listener for pin state changes.static int
disableSerialDataReceiveCallback(int fileDescriptor)
This method is used to instruct the native code to stop the monitoring thread monitoring interrupts on the selected serial port.static int
enableSerialDataReceiveCallback(int fileDescriptor)
This method is used to instruct the native code to setup a monitoring thread to monitor interrupts that represent changes to the selected serial port.static boolean
hasListener(int fileDescriptor)
Returns true if the listener is already registered for event callbacks.static void
removeListener(int fileDescriptor)
Java consumer code can all this method to unregister itself as a listener for pin state changes.
-
-
-
Method Detail
-
enableSerialDataReceiveCallback
public static int enableSerialDataReceiveCallback(int fileDescriptor)
This method is used to instruct the native code to setup a monitoring thread to monitor interrupts that represent changes to the selected serial port.
- Parameters:
fileDescriptor
- the serial file descriptor/handle- Returns:
- A return value of a negative number represents an error. A return value of '0' represents success and that the serial port is already being monitored. A return value of '1' represents success and that a new monitoring thread was created to handle the requested serial port.
-
disableSerialDataReceiveCallback
public static int disableSerialDataReceiveCallback(int fileDescriptor)
This method is used to instruct the native code to stop the monitoring thread monitoring interrupts on the selected serial port.
- Parameters:
fileDescriptor
- the serial file descriptor/handle- Returns:
- A return value of a negative number represents an error. A return value of '0' represents success and that no existing monitor was previously running. A return value of '1' represents success and that an existing monitoring thread was stopped for the requested serial port.
-
addListener
public static void addListener(int fileDescriptor, SerialInterruptListener listener)
Java consumer code can all this method to register itself as a listener for pin state changes.
- Parameters:
fileDescriptor
- the serial file descriptor/handlelistener
- A class instance that implements the GpioInterruptListener interface.- See Also:
SerialInterruptListener
,SerialInterruptEvent
-
removeListener
public static void removeListener(int fileDescriptor)
Java consumer code can all this method to unregister itself as a listener for pin state changes.
- Parameters:
fileDescriptor
- the serial file descriptor/handle- See Also:
SerialInterruptListener
,SerialInterruptEvent
-
hasListener
public static boolean hasListener(int fileDescriptor)
Returns true if the listener is already registered for event callbacks.
- Parameters:
fileDescriptor
- the serial file descriptor/handle- See Also:
SerialInterruptListener
,SerialInterruptEvent
-
-