Class SerialPortEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.fazecast.jSerialComm.SerialPortEvent
-
- All Implemented Interfaces:
Serializable
public class SerialPortEvent extends EventObject
This class describes an asynchronous serial port event.- See Also:
EventObject
, Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description SerialPortEvent(SerialPort comPort, int serialEventType)
Constructs aSerialPortEvent
object corresponding to the specified serial event type.SerialPortEvent(SerialPort comPort, int serialEventType, byte[] data)
Constructs aSerialPortEvent
object corresponding to the specified serial event type and containing the passed-in data bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getEventType()
Returns the type of serial port events that caused this object to be created.byte[]
getReceivedData()
Returns any raw data bytes associated with this serial port event.SerialPort
getSerialPort()
Returns theSerialPort
that triggered this event.String
toString()
Returns a string representation of the type of event represented by this object.-
Methods inherited from class java.util.EventObject
getSource
-
-
-
-
Constructor Detail
-
SerialPortEvent
public SerialPortEvent(SerialPort comPort, int serialEventType)
Constructs aSerialPortEvent
object corresponding to the specified serial event type.This constructor should only be used when the
SerialPortEvent
does not contain any data bytes.Valid serial event types are:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
SerialPort.LISTENING_EVENT_DATA_RECEIVED
SerialPort.LISTENING_EVENT_DATA_WRITTEN
SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
SerialPort.LISTENING_EVENT_CARRIER_DETECT
SerialPort.LISTENING_EVENT_CTS
SerialPort.LISTENING_EVENT_DSR
SerialPort.LISTENING_EVENT_RING_INDICATOR
SerialPort.LISTENING_EVENT_FRAMING_ERROR
SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_PARITY_ERROR
Note that event-based write callbacks are only supported on Windows operating systems. As such, the
SerialPort.LISTENING_EVENT_DATA_WRITTEN
event will never be called on a non-Windows system.Also, most control line status and error events from
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
toSerialPort.LISTENING_EVENT_PARITY_ERROR
are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all.- Parameters:
comPort
- TheSerialPort
about which this object is being created.serialEventType
- The type of serial port event that this object describes.- See Also:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
,SerialPort.LISTENING_EVENT_DATA_RECEIVED
,SerialPort.LISTENING_EVENT_DATA_WRITTEN
,SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
,SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
,SerialPort.LISTENING_EVENT_CARRIER_DETECT
,SerialPort.LISTENING_EVENT_CTS
,SerialPort.LISTENING_EVENT_DSR
,SerialPort.LISTENING_EVENT_RING_INDICATOR
,SerialPort.LISTENING_EVENT_FRAMING_ERROR
,SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_PARITY_ERROR
-
SerialPortEvent
public SerialPortEvent(SerialPort comPort, int serialEventType, byte[] data)
Constructs aSerialPortEvent
object corresponding to the specified serial event type and containing the passed-in data bytes.Valid serial event types are:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
SerialPort.LISTENING_EVENT_DATA_RECEIVED
SerialPort.LISTENING_EVENT_DATA_WRITTEN
SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
SerialPort.LISTENING_EVENT_CARRIER_DETECT
SerialPort.LISTENING_EVENT_CTS
SerialPort.LISTENING_EVENT_DSR
SerialPort.LISTENING_EVENT_RING_INDICATOR
SerialPort.LISTENING_EVENT_FRAMING_ERROR
SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_PARITY_ERROR
Note that event-based write callbacks are only supported on Windows operating systems. As such, the
SerialPort.LISTENING_EVENT_DATA_WRITTEN
event will never be called on a non-Windows system.Also, most control line status and error events from
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
toSerialPort.LISTENING_EVENT_PARITY_ERROR
are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all.- Parameters:
comPort
- TheSerialPort
about which this object is being created.serialEventType
- The type of serial port event that this object describes.data
- The raw data bytes corresponding to this serial port event.- See Also:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
,SerialPort.LISTENING_EVENT_DATA_RECEIVED
,SerialPort.LISTENING_EVENT_DATA_WRITTEN
,SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
,SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
,SerialPort.LISTENING_EVENT_CARRIER_DETECT
,SerialPort.LISTENING_EVENT_CTS
,SerialPort.LISTENING_EVENT_DSR
,SerialPort.LISTENING_EVENT_RING_INDICATOR
,SerialPort.LISTENING_EVENT_FRAMING_ERROR
,SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_PARITY_ERROR
-
-
Method Detail
-
toString
public final String toString()
Returns a string representation of the type of event represented by this object.- Overrides:
toString
in classEventObject
- Returns:
- A string representation of the type of event represented by this object.
-
getSerialPort
public final SerialPort getSerialPort()
Returns theSerialPort
that triggered this event.- Returns:
- The
SerialPort
that triggered this event.
-
getEventType
public final int getEventType()
Returns the type of serial port events that caused this object to be created.Return value will be a bitmask containing one or more of the following items OR'd together:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
SerialPort.LISTENING_EVENT_DATA_RECEIVED
SerialPort.LISTENING_EVENT_DATA_WRITTEN
SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
SerialPort.LISTENING_EVENT_CARRIER_DETECT
SerialPort.LISTENING_EVENT_CTS
SerialPort.LISTENING_EVENT_DSR
SerialPort.LISTENING_EVENT_RING_INDICATOR
SerialPort.LISTENING_EVENT_FRAMING_ERROR
SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
SerialPort.LISTENING_EVENT_PARITY_ERROR
Note that event-based write callbacks are only supported on Windows operating systems. As such, the
SerialPort.LISTENING_EVENT_DATA_WRITTEN
event will never be called on a non-Windows system.Also, most control line status and error events from
SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
toSerialPort.LISTENING_EVENT_PARITY_ERROR
are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all.- Returns:
- The serial port event that this object describes.
- See Also:
SerialPort.LISTENING_EVENT_DATA_AVAILABLE
,SerialPort.LISTENING_EVENT_DATA_RECEIVED
,SerialPort.LISTENING_EVENT_DATA_WRITTEN
,SerialPort.LISTENING_EVENT_PORT_DISCONNECTED
,SerialPort.LISTENING_EVENT_BREAK_INTERRUPT
,SerialPort.LISTENING_EVENT_CARRIER_DETECT
,SerialPort.LISTENING_EVENT_CTS
,SerialPort.LISTENING_EVENT_DSR
,SerialPort.LISTENING_EVENT_RING_INDICATOR
,SerialPort.LISTENING_EVENT_FRAMING_ERROR
,SerialPort.LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
,SerialPort.LISTENING_EVENT_PARITY_ERROR
-
getReceivedData
public final byte[] getReceivedData()
Returns any raw data bytes associated with this serial port event.- Returns:
- Any data bytes associated with this serial port event or null if none exist.
-
-