public class SerialNativeInterface
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
ERR_INCORRECT_SERIAL_PORT |
static long |
ERR_PERMISSION_DENIED |
static long |
ERR_PORT_BUSY |
static long |
ERR_PORT_NOT_FOUND |
static int |
OS_LINUX |
static int |
OS_MAC_OS_X |
static int |
OS_SOLARIS |
static int |
OS_WINDOWS |
static java.lang.String |
PROPERTY_JSSC_IGNPAR |
static java.lang.String |
PROPERTY_JSSC_NO_TIOCEXCL |
static java.lang.String |
PROPERTY_JSSC_PARMRK |
Constructor and Description |
---|
SerialNativeInterface() |
Modifier and Type | Method and Description |
---|---|
boolean |
closePort(long handle)
Close port
|
int[] |
getBuffersBytesCount(long handle)
Get bytes count in buffers of port
|
int |
getEventsMask(long handle)
Get events mask
|
int |
getFlowControlMode(long handle)
Get flow control mode
|
static java.lang.String |
getLibraryBaseVersion()
Get jSSC Base Version
|
static java.lang.String |
getLibraryMinorSuffix()
Get jSSC minor suffix.
|
static java.lang.String |
getLibraryVersion()
Get jSSC version.
|
int[] |
getLinesStatus(long handle)
Getting lines states
|
static java.lang.String |
getNativeLibraryVersion()
Get jSSC native library version
|
static int |
getOsType()
Get OS type (OS_LINUX || OS_WINDOWS || OS_SOLARIS)
|
java.lang.String[] |
getSerialPortNames()
Get serial port names like an array of String
|
long |
openPort(java.lang.String portName,
boolean useTIOCEXCL)
Open port
|
boolean |
purgePort(long handle,
int flags)
Purge of input and output buffer
|
byte[] |
readBytes(long handle,
int byteCount)
Read data from port
|
boolean |
sendBreak(long handle,
int duration)
Send Break singnal for setted duration
|
boolean |
setDTR(long handle,
boolean value)
Change DTR line state
|
boolean |
setEventsMask(long handle,
int mask)
Set events mask
|
boolean |
setFlowControlMode(long handle,
int mask)
Set flow control mode
|
boolean |
setParams(long handle,
int baudRate,
int dataBits,
int stopBits,
int parity,
boolean setRTS,
boolean setDTR,
int flags)
Setting the parameters of opened port
|
boolean |
setRTS(long handle,
boolean value)
Change RTS line state
|
int[][] |
waitEvents(long handle)
Wait events
|
boolean |
writeBytes(long handle,
byte[] buffer)
Write data to port
|
public static final int OS_LINUX
public static final int OS_WINDOWS
public static final int OS_SOLARIS
public static final int OS_MAC_OS_X
public static final long ERR_PORT_BUSY
public static final long ERR_PORT_NOT_FOUND
public static final long ERR_PERMISSION_DENIED
public static final long ERR_INCORRECT_SERIAL_PORT
public static final java.lang.String PROPERTY_JSSC_NO_TIOCEXCL
public static final java.lang.String PROPERTY_JSSC_IGNPAR
public static final java.lang.String PROPERTY_JSSC_PARMRK
public static int getOsType()
public static java.lang.String getLibraryVersion()
public static java.lang.String getLibraryBaseVersion()
public static java.lang.String getLibraryMinorSuffix()
public static java.lang.String getNativeLibraryVersion()
public long openPort(java.lang.String portName, boolean useTIOCEXCL)
portName
- name of port for openinguseTIOCEXCL
- enable/disable using of TIOCEXCL. Take effect only on *nix based systemspublic boolean setParams(long handle, int baudRate, int dataBits, int stopBits, int parity, boolean setRTS, boolean setDTR, int flags)
handle
- handle of opened portbaudRate
- data transfer ratedataBits
- number of data bitsstopBits
- number of stop bitsparity
- paritysetRTS
- initial state of RTS line (ON/OFF)setDTR
- initial state of DTR line (ON/OFF)flags
- additional Native settings. Take effect only on *nix based systemspublic boolean purgePort(long handle, int flags)
handle
- handle of opened portflags
- flags specifying required actions for purgePort methodpublic boolean closePort(long handle)
handle
- handle of opened portpublic boolean setEventsMask(long handle, int mask)
handle
- handle of opened portmask
- events maskpublic int getEventsMask(long handle)
handle
- handle of opened portpublic int[][] waitEvents(long handle)
handle
- handle of opened portpublic boolean setRTS(long handle, boolean value)
handle
- handle of opened portvalue
- true - ON, false - OFFpublic boolean setDTR(long handle, boolean value)
handle
- handle of opened portvalue
- true - ON, false - OFFpublic byte[] readBytes(long handle, int byteCount)
handle
- handle of opened portbyteCount
- count of bytes required to readpublic boolean writeBytes(long handle, byte[] buffer)
handle
- handle of opened portbuffer
- array of bytes to writepublic int[] getBuffersBytesCount(long handle)
handle
- handle of opened portpublic boolean setFlowControlMode(long handle, int mask)
handle
- handle of opened portmask
- mask of flow control modepublic int getFlowControlMode(long handle)
handle
- handle of opened portpublic java.lang.String[] getSerialPortNames()
public int[] getLinesStatus(long handle)
handle
- handle of opened portpublic boolean sendBreak(long handle, int duration)
handle
- handle of opened portduration
- duration of Break signal