Class SerialUtilities
java.lang.Object
com.inductiveautomation.ignition.common.script.builtin.SerialUtilities
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Deprecated.static final boolean
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeSerialPort
(String port) configureSerialPort
(org.python.core.PyObject[] pyArgs, String[] keywords) Configure a serial port for later use.static void
openSerialPort
(String port) static SerialUtilities.PortManager
static byte[]
static byte[]
ReadnumberOfBytes
bytes from a serial port.static String
readBytesAsString
(String port, int numberOfBytes) static String
readBytesAsString
(String port, int numberOfBytes, int timeout) ReadnumberOfBytes
from a serial port and convert them to a String.static String
readBytesAsString
(String port, int numberOfBytes, int timeout, String encoding) Readbytes
from a serial port and convert them to a String.static String
static String
static String
static String
Read one line from a serial port.static String
Read from a serial port until a delimiter character is encountered.static String
Read from a serial port until a delimiter character is encountered.static void
Send asendBreak
break signal to a serial port.static void
static void
static void
Write a String,toWrite
, to a serial port.static void
writeBytes
(String port, byte[] toWrite) static void
writeBytes
(String port, byte[] toWrite, int timeout) Write a byte[],toWrite
, to a serial port.
-
Field Details
-
BIT_RATE_110
public static final int BIT_RATE_110- See Also:
-
BIT_RATE_150
public static final int BIT_RATE_150- See Also:
-
BIT_RATE_300
public static final int BIT_RATE_300- See Also:
-
BIT_RATE_600
public static final int BIT_RATE_600- See Also:
-
BIT_RATE_1200
public static final int BIT_RATE_1200- See Also:
-
BIT_RATE_2400
public static final int BIT_RATE_2400- See Also:
-
BIT_RATE_4800
public static final int BIT_RATE_4800- See Also:
-
BIT_RATE_9600
public static final int BIT_RATE_9600- See Also:
-
BIT_RATE_19200
public static final int BIT_RATE_19200- See Also:
-
BIT_RATE_38400
public static final int BIT_RATE_38400- See Also:
-
BIT_RATE_57600
public static final int BIT_RATE_57600- See Also:
-
BIT_RATE_115200
public static final int BIT_RATE_115200- See Also:
-
BIT_RATE_230400
public static final int BIT_RATE_230400- See Also:
-
BIT_RATE_460800
public static final int BIT_RATE_460800- See Also:
-
BIT_RATE_921600
public static final int BIT_RATE_921600- See Also:
-
HANDSHAKE_CTS_DTR
Deprecated.- See Also:
-
HANDSHAKE_CTS_RTS
Deprecated.- See Also:
-
HANDSHAKE_DSR_DTR
Deprecated.- See Also:
-
HANDSHAKE_HARD_IN
Deprecated.- See Also:
-
HANDSHAKE_HARD_OUT
Deprecated.- See Also:
-
HANDSHAKE_NONE
Deprecated.- See Also:
-
HANDSHAKE_SOFT_IN
Deprecated.- See Also:
-
HANDSHAKE_SOFT_OUT
Deprecated.- See Also:
-
HANDSHAKE_SPLIT_MASK
Deprecated.- See Also:
-
HANDSHAKE_XON_XOFF
Deprecated.- See Also:
-
FLOW_CONTROL_DISABLED
public static final int FLOW_CONTROL_DISABLED- See Also:
-
FLOW_CONTROL_RTS_ENABLED
public static final int FLOW_CONTROL_RTS_ENABLED- See Also:
-
FLOW_CONTROL_CTS_ENABLED
public static final int FLOW_CONTROL_CTS_ENABLED- See Also:
-
FLOW_CONTROL_DSR_ENABLED
public static final int FLOW_CONTROL_DSR_ENABLED- See Also:
-
FLOW_CONTROL_DTR_ENABLED
public static final int FLOW_CONTROL_DTR_ENABLED- See Also:
-
FLOW_CONTROL_XONXOFF_IN_ENABLED
public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED- See Also:
-
FLOW_CONTROL_XONXOFF_OUT_ENABLED
public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED- See Also:
-
DATA_BITS_5
public static final int DATA_BITS_5- See Also:
-
DATA_BITS_6
public static final int DATA_BITS_6- See Also:
-
DATA_BITS_7
public static final int DATA_BITS_7- See Also:
-
DATA_BITS_8
public static final int DATA_BITS_8- See Also:
-
PARITY_EVEN
public static final int PARITY_EVEN- See Also:
-
PARITY_MARK
public static final int PARITY_MARK- See Also:
-
PARITY_NONE
public static final int PARITY_NONE- See Also:
-
PARITY_ODD
public static final int PARITY_ODD- See Also:
-
PARITY_SPACE
public static final int PARITY_SPACE- See Also:
-
STOP_BITS_1
public static final int STOP_BITS_1- See Also:
-
STOP_BITS_2
public static final int STOP_BITS_2- See Also:
-
DEFAULT_BIT_RATE
public static final int DEFAULT_BIT_RATE- See Also:
-
DEFAULT_DATA_BITS
public static final int DEFAULT_DATA_BITS- See Also:
-
DEFAULT_PARITY
public static final int DEFAULT_PARITY- See Also:
-
DEFAULT_STOP_BITS
public static final int DEFAULT_STOP_BITS- See Also:
-
DEFAULT_HANDSHAKE
Deprecated.- See Also:
-
DEFAULT_FLOW_CONTROL
public static final int DEFAULT_FLOW_CONTROL- See Also:
-
DEFAULT_HARDWARE_FLOW_CONTROL
public static final boolean DEFAULT_HARDWARE_FLOW_CONTROL- See Also:
-
DEFAULT_READ_TIMEOUT_MS
public static final int DEFAULT_READ_TIMEOUT_MS- See Also:
-
DEFAULT_WRITE_TIMEOUT_MS
public static final int DEFAULT_WRITE_TIMEOUT_MS- See Also:
-
-
Method Details
-
configureSerialPort
public static SerialUtilities.SerialConfigurator configureSerialPort(org.python.core.PyObject[] pyArgs, String[] keywords) Configure a serial port for later use.- Returns:
- A
SerialUtilities.SerialConfigurator
that can be used to configure the serial port instead of or in addition to the given keyword arguments.
-
port
public static SerialUtilities.PortManager port(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException - Throws:
IOException
-
openSerialPort
- Throws:
IOException
-
closeSerialPort
- Throws:
IOException
-
sendBreak
Send asendBreak
break signal to a serial port.- Parameters:
port
- The previously configured serial port to use.millis
- Approximate length of break signal, in milliseconds.- Throws:
IOException
InterruptedException
-
readBytes
- Throws:
IOException
-
readBytes
ReadnumberOfBytes
bytes from a serial port.- Parameters:
port
- The previously configured serial port to use.numberOfBytes
- The number of bytes to read.timeout
- Maximum amount of time, in milliseconds, to block before returning.- Returns:
- A byte[] containing
numberOfBytes
bytes read from the serial port. - Throws:
IOException
-
readBytesAsString
- Throws:
IOException
-
readBytesAsString
public static String readBytesAsString(String port, int numberOfBytes, int timeout) throws IOException ReadnumberOfBytes
from a serial port and convert them to a String.- Parameters:
port
- The previously configured serial port to use.numberOfBytes
- The number of bytes to read.timeout
- Maximum amount of time, in milliseconds, to block before returning.- Returns:
- A String created from the bytes read, using
String(byte[])
. - Throws:
IOException
-
readBytesAsString
public static String readBytesAsString(String port, int numberOfBytes, int timeout, String encoding) throws IOException Readbytes
from a serial port and convert them to a String.- Parameters:
port
- The previously configured serial port to use.numberOfBytes
- The number of bytes to read.timeout
- Maximum amount of time, in milliseconds, to block before returning.encoding
- Charset to use to decode the string. If null, uses platform default charset.- Returns:
- A String created from the bytes read, using
String(byte[])
. - Throws:
IOException
-
readLine
- Throws:
IOException
-
readLine
- Throws:
IOException
-
readLine
- Throws:
IOException
-
readLine
public static String readLine(String port, int timeout, String encoding, boolean crlfRequired) throws IOException Read one line from a serial port.- Parameters:
port
- The previously configured serial port to use.timeout
- Maximum amount of time, in milliseconds, to block before returning.encoding
- The String encoding to use.crlfRequired
-true
if both CR and LF are required to delimit a line.- Returns:
- A line of text. A line is considered either a line feed ('\n') or carriage return ('\r') or both if
crlfRequired
. - Throws:
IOException
-
readUntil
public static String readUntil(String port, char delimiter, boolean includeDelimiter) throws IOException Read from a serial port until a delimiter character is encountered.- Parameters:
port
- The previously configured serial port to use.delimiter
- The delimiter to read until.includeDelimiter
- IfincludeDelimiter
istrue
, the delimiter will be included in the return value. Otherwise it will be discarded.- Returns:
- Returns a String containing all characters read until the delimiter was reached, and
including the delimiter if
includeDelimiter
istrue
. - Throws:
IOException
-
readUntil
public static String readUntil(String port, char delimiter, boolean includeDelimiter, int timeout) throws IOException Read from a serial port until a delimiter character is encountered.- Parameters:
port
- The previously configured serial port to use.delimiter
- The delimiter to read until.includeDelimiter
- IfincludeDelimiter
istrue
, the delimiter will be included in the return value. Otherwise it will be discarded.timeout
- read timeout in milliseconds- Returns:
- Returns a String containing all characters read until the delimiter was reached, and
including the delimiter if
includeDelimiter
istrue
. - Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
public static void write(String port, String toWrite, int timeout, String encoding) throws IOException Write a String,toWrite
, to a serial port.- Parameters:
port
- The previously configured serial port to use.toWrite
- The String to write.timeout
- The duration to wait, in milliseconds, before timing out.- Throws:
IOException
-
writeBytes
- Throws:
IOException
-
writeBytes
Write a byte[],toWrite
, to a serial port.- Parameters:
port
- The previously configured serial port to use.toWrite
- The byte[] to write.timeout
- The duration to wait, in milliseconds, before timing out.- Throws:
IOException
-