Class Serial
- java.lang.Object
- 
- com.pi4j.jni.Serial
 
- 
 public class Serial extends Object THIS IS CURRENTLY A NO-IMPL STUB. THIS IS WHERE A NEW SERIAL LIBRARY IMPLEMENTATION IS PLANNED.
- 
- 
Field SummaryFields Modifier and Type Field Description static intBAUD_RATE_110static intBAUD_RATE_115200static intBAUD_RATE_1200static intBAUD_RATE_134static intBAUD_RATE_150static intBAUD_RATE_1800static intBAUD_RATE_19200static intBAUD_RATE_200static intBAUD_RATE_230400static intBAUD_RATE_2400static intBAUD_RATE_300static intBAUD_RATE_38400static intBAUD_RATE_4800static intBAUD_RATE_50static intBAUD_RATE_57600static intBAUD_RATE_600static intBAUD_RATE_75static intBAUD_RATE_9600static intDATA_BITS_5static intDATA_BITS_6static intDATA_BITS_7static intDATA_BITS_8static StringDEFAULT_COM_PORTThe default hardware COM port provided via the Raspberry Pi GPIO header.static StringFIRST_USB_COM_PORTstatic intFLOW_CONTROL_HARDWAREstatic intFLOW_CONTROL_NONEstatic intFLOW_CONTROL_SOFTWAREstatic intPARITY_EVENstatic intPARITY_MARKstatic intPARITY_NONEstatic intPARITY_ODDstatic intPARITY_SPACEstatic StringSECOND_USB_COM_PORTstatic intSTOP_BITS_1static intSTOP_BITS_2
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static intavailable(int fd)Returns the number of characters available for reading, or -1 for any error condition, in which case errno will be set appropriately.static voidclose(int fd)Closes the serial port/device identified by the file descriptor.static voiddiscardAll(int fd)Discards all data in the serial transmit and receive buffers.static voiddiscardInput(int fd)Discards all data in the serial receive and transmit buffer.static voiddiscardOutput(int fd)Discards all data in the serial transmit buffer.static voidflush(int fd)Forces (drains) all data in transmit buffers.static booleangetCD(int fd)Get the CD (carrier-detect) pin state.static booleangetCTS(int fd)Get the CST (clear-to-send) pin state.static booleangetDSR(int fd)Get the DSR (data-set-ready) pin state.static booleangetDTR(int fd)Get the DTR (data-terminal-ready) pin state.static booleangetRI(int fd)Get the RI (ring-indicator) pin state.static booleangetRTS(int fd)Get the RTS (request-to-send) pin state.static intopen(String device, int baud)This opens and initializes the serial device and sets the communication parameters.static intopen(String device, int baud, int dataBits)This opens and initializes the serial device and sets the communication parameters.static intopen(String device, int baud, int dataBits, int parity)This opens and initializes the serial port/device and sets the communication parameters.static intopen(String device, int baud, int dataBits, int parity, int stopBits)This opens and initializes the serial port/device and sets the communication parameters.static intopen(String device, int baud, int dataBits, int parity, int stopBits, int flowControl)This opens and initializes the serial port/device and sets the communication parameters.static byte[]read(int fd)Reads all available bytes from the serial port/device.static byte[]read(int fd, int length)Reads a length of bytes from the port/serial device.static voidread(int fd, int length, OutputStream stream)Reads a length bytes from the serial port/device into a provided OutputStream.static voidread(int fd, int length, ByteBuffer buffer)Reads a length bytes from the serial port/device into a provided ByteBuffer.static CharBufferread(int fd, int length, Charset charset)Reads a length of bytes from the port/serial device.static voidread(int fd, int length, Charset charset, Writer writer)Reads a length bytes from the serial port/device into a provided Writer.static voidread(int fd, int length, Collection<ByteBuffer> collection)Reads a length of bytes from the serial port/device into a provided collection of ByteBuffer objects.static voidread(int fd, OutputStream stream)Reads all available bytes from the serial device into a provided OutputStream.static voidread(int fd, ByteBuffer buffer)Reads all available bytes from the serial device into a provided ByteBuffer.static CharBufferread(int fd, Charset charset)Reads all available bytes from the port/serial device.static voidread(int fd, Charset charset, Writer writer)Reads all available bytes from the serial port/device into a provided Writer.static voidread(int fd, Collection<ByteBuffer> collection)Reads all available bytes from the serial port/device into a provided collection of ByteBuffer objects.static voidsendBreak(int fd)Send a BREAK signal to connected device for at least 0.25 seconds, and not more than 0.5 secondsstatic voidsendBreak(int fd, int duration)Send a BREAK signal to connected device.static voidsetBreak(int fd, boolean enabled)Send a constant BREAK signal to connected device.static voidsetDTR(int fd, boolean enabled)Control the DTR (data-terminal-ready) pin state.static voidsetRTS(int fd, boolean enabled)Control the RTS (request-to-send) pin state.static voidwrite(int fd, byte... data)Sends one of more bytes to the serial device identified by the given file descriptor.static voidwrite(int fd, byte[]... data)Sends one of more bytes arrays to the serial device identified by the given file descriptor.static voidwrite(int fd, byte[] data, int offset, int length)Sends an array of bytes to the serial port/device identified by the given file descriptor.static voidwrite(int fd, char... data)Sends an array of ASCII characters to the serial port/device identified by the given file descriptor.static voidwrite(int fd, InputStream input)Read content from an input stream of data and write it to the serial port transmit buffer.static voidwrite(int fd, CharSequence... data)Sends one or more ASCII string objects to the serial port/device identified by the given file descriptor.static voidwrite(int fd, ByteBuffer... data)Read the content of byte buffer and write the data to the serial port transmit buffer.static voidwrite(int fd, CharBuffer... data)Sends one or more ASCII CharBuffers to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Charset charset, char... data)Sends an array of characters to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Charset charset, char[] data, int offset, int length)Sends an array of characters to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Charset charset, CharSequence... data)Sends one or more string objects to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Charset charset, CharBuffer... data)Sends one or more CharBuffers to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Charset charset, Collection<? extends CharSequence> data)Sends a collection of string objects to the serial port/device identified by the given file descriptor.static voidwrite(int fd, Collection<? extends CharSequence> data)Sends a collection of ASCII string objects to the serial port/device identified by the given file descriptor.static voidwriteln(int fd, CharSequence... data)Sends one or more ASCII string objects each appended with a line terminator (CR+LF) to the serial port/device.static voidwriteln(int fd, Charset charset, CharSequence... data)Sends one or more string objects each appended with a line terminator (CR+LF) to the serial port/device.static voidwriteln(int fd, Charset charset, Collection<? extends CharSequence> data)Sends a collection of string objects each appended with a line terminator (CR+LF) to the serial port/device.static voidwriteln(int fd, Collection<? extends CharSequence> data)Sends a collection of ASCII string objects each appended with a line terminator (CR+LF) to the serial port/device.
 
- 
- 
- 
Field Detail- 
DEFAULT_COM_PORTpublic static final String DEFAULT_COM_PORT The default hardware COM port provided via the Raspberry Pi GPIO header.- See Also:
- open(String,int), Constant Field Values
 
 - 
FIRST_USB_COM_PORTpublic static final String FIRST_USB_COM_PORT - See Also:
- Constant Field Values
 
 - 
SECOND_USB_COM_PORTpublic static final String SECOND_USB_COM_PORT - See Also:
- Constant Field Values
 
 - 
BAUD_RATE_50public static int BAUD_RATE_50 
 - 
BAUD_RATE_75public static int BAUD_RATE_75 
 - 
BAUD_RATE_110public static int BAUD_RATE_110 
 - 
BAUD_RATE_134public static int BAUD_RATE_134 
 - 
BAUD_RATE_150public static int BAUD_RATE_150 
 - 
BAUD_RATE_200public static int BAUD_RATE_200 
 - 
BAUD_RATE_300public static int BAUD_RATE_300 
 - 
BAUD_RATE_600public static int BAUD_RATE_600 
 - 
BAUD_RATE_1200public static int BAUD_RATE_1200 
 - 
BAUD_RATE_1800public static int BAUD_RATE_1800 
 - 
BAUD_RATE_2400public static int BAUD_RATE_2400 
 - 
BAUD_RATE_4800public static int BAUD_RATE_4800 
 - 
BAUD_RATE_9600public static int BAUD_RATE_9600 
 - 
BAUD_RATE_19200public static int BAUD_RATE_19200 
 - 
BAUD_RATE_38400public static int BAUD_RATE_38400 
 - 
BAUD_RATE_57600public static int BAUD_RATE_57600 
 - 
BAUD_RATE_115200public static int BAUD_RATE_115200 
 - 
BAUD_RATE_230400public static int BAUD_RATE_230400 
 - 
PARITY_NONEpublic static int PARITY_NONE 
 - 
PARITY_ODDpublic static int PARITY_ODD 
 - 
PARITY_EVENpublic static int PARITY_EVEN 
 - 
PARITY_MARKpublic static int PARITY_MARK 
 - 
PARITY_SPACEpublic static int PARITY_SPACE 
 - 
DATA_BITS_5public static int DATA_BITS_5 
 - 
DATA_BITS_6public static int DATA_BITS_6 
 - 
DATA_BITS_7public static int DATA_BITS_7 
 - 
DATA_BITS_8public static int DATA_BITS_8 
 - 
STOP_BITS_1public static int STOP_BITS_1 
 - 
STOP_BITS_2public static int STOP_BITS_2 
 - 
FLOW_CONTROL_NONEpublic static int FLOW_CONTROL_NONE 
 - 
FLOW_CONTROL_HARDWAREpublic static int FLOW_CONTROL_HARDWARE 
 - 
FLOW_CONTROL_SOFTWAREpublic static int FLOW_CONTROL_SOFTWARE 
 
- 
 - 
Method Detail- 
openpublic static int open(String device, int baud, int dataBits, int parity, int stopBits, int flowControl) throws IOException This opens and initializes the serial port/device and sets the communication parameters. It sets the port into raw mode (character at a time and no translations). (ATTENTION: the 'device' argument can only be a maximum of 128 characters.) - Parameters:
- device- The device address of the serial port to access. You can use constant 'DEFAULT_COM_PORT' if you wish to access the default serial port provided via the GPIO header.
- baud- The baud rate to use with the serial port. (Custom baud rate are not supported)
- dataBits- The data bits to use for serial communication. (5,6,7,8)
- parity- The parity setting to use for serial communication. (None, Event, Odd, Mark, Space)
- stopBits- The stop bits to use for serial communication. (1,2)
- flowControl- The stop bits to use for serial communication. (none, hardware, software)
- Returns:
- The return value is the file descriptor or a negative value for any error. An IOException will be thrown for all error conditions.
- Throws:
- IOException
- See Also:
- DEFAULT_COM_PORT
 
 - 
openpublic static int open(String device, int baud, int dataBits, int parity, int stopBits) throws IOException This opens and initializes the serial port/device and sets the communication parameters. It sets the port into raw mode (character at a time and no translations). The following default serial communications parameters are applied using this overloaded method instance: flow control = FLOW_CONTROL_NONE (ATTENTION: the 'device' argument can only be a maximum of 128 characters.) - Parameters:
- device- The device address of the serial port to access. You can use constant 'DEFAULT_COM_PORT' if you wish to access the default serial port provided via the GPIO header.
- baud- The baud rate to use with the serial port. (Custom baud rate are not supported)
- dataBits- The data bits to use for serial communication. (5,6,7,8)
- parity- The parity setting to use for serial communication. (None, Event, Odd, Mark, Space)
- stopBits- The stop bits to use for serial communication. (1,2)
- Returns:
- The return value is the file descriptor or a negative value for any error. An IOException will be thrown for all error conditions.
- Throws:
- IOException
- See Also:
- DEFAULT_COM_PORT,- FLOW_CONTROL_NONE
 
 - 
openpublic static int open(String device, int baud, int dataBits, int parity) throws IOException This opens and initializes the serial port/device and sets the communication parameters. It sets the port into raw mode (character at a time and no translations). The following default serial communications parameters are applied using this overloaded method instance: stop bits = STOP_BITS_1 flow control = FLOW_CONTROL_NONE (ATTENTION: the 'device' argument can only be a maximum of 128 characters.) - Parameters:
- device- The device address of the serial port to access. You can use constant 'DEFAULT_COM_PORT' if you wish to access the default serial port provided via the GPIO header.
- baud- The baud rate to use with the serial port. (Custom baud rate are not supported)
- dataBits- The data bits to use for serial communication. (5,6,7,8)
- Returns:
- The return value is the file descriptor or a negative value for any error. An IOException will be thrown for all error conditions.
- Throws:
- IOException
- See Also:
- DEFAULT_COM_PORT,- STOP_BITS_1,- FLOW_CONTROL_NONE
 
 - 
openpublic static int open(String device, int baud, int dataBits) throws IOException This opens and initializes the serial device and sets the communication parameters. It sets the port into raw mode (character at a time and no translations). The following default serial communications parameters are applied using this overloaded method instance: parity = PARITY_NONE stop bits = STOP_BITS_1 flow control = FLOW_CONTROL_NONE (ATTENTION: the 'device' argument can only be a maximum of 128 characters.) - Parameters:
- device- The device address of the serial port to access. You can use constant 'DEFAULT_COM_PORT' if you wish to access the default serial port provided via the GPIO header.
- baud- The baud rate to use with the serial port. (Custom baud rate are not supported)
- dataBits- The data bits to use for serial communication. (5,6,7,8)
- Returns:
- The return value is the file descriptor or a negative value for any error. An IOException will be thrown for all error conditions.
- Throws:
- IOException
- See Also:
- DEFAULT_COM_PORT,- PARITY_NONE,- STOP_BITS_1,- FLOW_CONTROL_NONE
 
 - 
openpublic static int open(String device, int baud) throws IOException This opens and initializes the serial device and sets the communication parameters. It sets the port into raw mode (character at a time and no translations). The following default serial communications parameters are applied using this overloaded method instance: data bits = DATA_BITS_8 parity = PARITY_NONE stop bits = STOP_BITS_1 flow control = FLOW_CONTROL_NONE (ATTENTION: the 'device' argument can only be a maximum of 128 characters.) - Parameters:
- device- The device address of the serial port to access. You can use constant 'DEFAULT_COM_PORT' if you wish to access the default serial port provided via the GPIO header.
- baud- The baud rate to use with the serial port. (Custom baud rate are not supported)
- Returns:
- The return value is the file descriptor or a negative value for any error. An IOException will be thrown for all error conditions.
- Throws:
- IOException
- See Also:
- DEFAULT_COM_PORT,- DATA_BITS_8,- PARITY_NONE,- STOP_BITS_1,- FLOW_CONTROL_NONE
 
 - 
closepublic static void close(int fd) throws IOExceptionCloses the serial port/device identified by the file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
discardInputpublic static void discardInput(int fd) throws IOExceptionDiscards all data in the serial receive and transmit buffer. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
discardOutputpublic static void discardOutput(int fd) throws IOExceptionDiscards all data in the serial transmit buffer. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
discardAllpublic static void discardAll(int fd) throws IOExceptionDiscards all data in the serial transmit and receive buffers. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
flushpublic static void flush(int fd) throws IOExceptionForces (drains) all data in transmit buffers. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
sendBreakpublic static void sendBreak(int fd, int duration) throws IOExceptionSend a BREAK signal to connected device. - Parameters:
- fd- The file descriptor of the serial port/device.
- duration- The length of time (milliseconds) to send the BREAK signal
- Throws:
- IOException
 
 - 
sendBreakpublic static void sendBreak(int fd) throws IOExceptionSend a BREAK signal to connected device for at least 0.25 seconds, and not more than 0.5 seconds - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
setBreakpublic static void setBreak(int fd, boolean enabled) throws IOExceptionSend a constant BREAK signal to connected device. (Turn break on/off) When enabled this will send a steady stream of zero bits. When enabled, no (other) data transmitting is possible. - Parameters:
- fd- The file descriptor of the serial port/device.
- enabled- The enable or disable state to control the BREAK signal
- Throws:
- IOException
 
 - 
setRTSpublic static void setRTS(int fd, boolean enabled) throws IOExceptionControl the RTS (request-to-send) pin state. When enabled this will set the RTS pin to the HIGH state. - Parameters:
- fd- The file descriptor of the serial port/device.
- enabled- The enable or disable state to control the RTS pin state.
- Throws:
- IOException
 
 - 
setDTRpublic static void setDTR(int fd, boolean enabled) throws IOExceptionControl the DTR (data-terminal-ready) pin state. When enabled this will set the DTR pin to the HIGH state. - Parameters:
- fd- The file descriptor of the serial port/device.
- enabled- The enable or disable state to control the RTS pin state.
- Throws:
- IOException
 
 - 
getRTSpublic static boolean getRTS(int fd) throws IOExceptionGet the RTS (request-to-send) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
getDTRpublic static boolean getDTR(int fd) throws IOExceptionGet the DTR (data-terminal-ready) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
getCTSpublic static boolean getCTS(int fd) throws IOExceptionGet the CST (clear-to-send) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
getDSRpublic static boolean getDSR(int fd) throws IOExceptionGet the DSR (data-set-ready) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
getRIpublic static boolean getRI(int fd) throws IOExceptionGet the RI (ring-indicator) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
getCDpublic static boolean getCD(int fd) throws IOExceptionGet the CD (carrier-detect) pin state. - Parameters:
- fd- The file descriptor of the serial port/device.
- Throws:
- IOException
 
 - 
availablepublic static int available(int fd) Returns the number of characters available for reading, or -1 for any error condition, in which case errno will be set appropriately.- Parameters:
- fd- The file descriptor of the serial port/device.
- Returns:
- Returns the number of characters available for reading, or -1 for any error
 
 - 
readpublic static byte[] read(int fd) throws IOExceptionReads all available bytes from the serial port/device. - Parameters:
- fd- The file descriptor of the serial port/device.
- Returns:
- Returns a byte array with the data read from the serial port.
- Throws:
- IOException
 
 - 
readpublic static byte[] read(int fd, int length) throws IOExceptionReads a length of bytes from the port/serial device. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- Returns:
- Returns a byte array with the data read from the serial port.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, ByteBuffer buffer) throws IOExceptionReads all available bytes from the serial device into a provided ByteBuffer. - Parameters:
- fd- The file descriptor of the serial port/device.
- buffer- The ByteBuffer object to write to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, int length, ByteBuffer buffer) throws IOExceptionReads a length bytes from the serial port/device into a provided ByteBuffer. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- buffer- The ByteBuffer object to write to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, OutputStream stream) throws IOExceptionReads all available bytes from the serial device into a provided OutputStream. - Parameters:
- fd- The file descriptor of the serial port/device.
- stream- The OutputStream object to write to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, int length, OutputStream stream) throws IOExceptionReads a length bytes from the serial port/device into a provided OutputStream. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- stream- The OutputStream object to write to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, Collection<ByteBuffer> collection) throws IOExceptionReads all available bytes from the serial port/device into a provided collection of ByteBuffer objects. - Parameters:
- fd- The file descriptor of the serial port/device.
- collection- The collection of CharSequence objects to append to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, int length, Collection<ByteBuffer> collection) throws IOExceptionReads a length of bytes from the serial port/device into a provided collection of ByteBuffer objects. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- collection- The collection of CharSequence objects to append to.
- Throws:
- IOException
 
 - 
readpublic static CharBuffer read(int fd, Charset charset) throws IOException Reads all available bytes from the port/serial device. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- Returns:
- Returns a character set with the data read from the serial port.
- Throws:
- IOException
 
 - 
readpublic static CharBuffer read(int fd, int length, Charset charset) throws IOException Reads a length of bytes from the port/serial device. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- Returns:
- Returns a character set with the data read from the serial port.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, Charset charset, Writer writer) throws IOExceptionReads all available bytes from the serial port/device into a provided Writer. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- writer- The Writer object to write to.
- Throws:
- IOException
 
 - 
readpublic static void read(int fd, int length, Charset charset, Writer writer) throws IOExceptionReads a length bytes from the serial port/device into a provided Writer. - Parameters:
- fd- The file descriptor of the serial port/device.
- length- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- writer- The Writer object to write to.
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, byte[] data, int offset, int length) throws IOExceptionSends an array of bytes to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- A ByteBuffer of data to be transmitted.
- offset- The starting index (inclusive) in the array to send from.
- length- The number of bytes from the byte array to transmit to the serial port.
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, byte... data) throws IOExceptionSends one of more bytes to the serial device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more bytes (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, byte[]... data) throws IOExceptionSends one of more bytes arrays to the serial device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more byte arrays of data to be transmitted. (variable-length-argument)
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, ByteBuffer... data) throws IOExceptionRead the content of byte buffer and write the data to the serial port transmit buffer. (The buffer is read from the current position up to the 'limit' value, not the 'capacity'. You may need to rewind() or flip() the byte buffer if you have just written to it.)- Parameters:
- fd- The file descriptor of the serial port/device.
- data- A ByteBuffer of data to be transmitted.
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, InputStream input) throws IOExceptionRead content from an input stream of data and write it to the serial port transmit buffer.- Parameters:
- fd- The file descriptor of the serial port/device.
- input- An InputStream of data to be transmitted
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, Charset charset, char[] data, int offset, int length) throws IOExceptionSends an array of characters to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- An array of chars to be decoded into bytes and transmitted.
- offset- The starting index (inclusive) in the array to send from.
- length- The number of characters from the char array to transmit to the serial port.
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, Charset charset, char... data) throws IOExceptionSends an array of characters to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- One or more characters (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, char... data) throws IOExceptionSends an array of ASCII characters to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more ASCII characters (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IOException
 
 - 
writepublic static void write(int fd, Charset charset, CharBuffer... data) throws IllegalStateException, IOExceptionSends one or more CharBuffers to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- One or more CharBuffers (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writepublic static void write(int fd, CharBuffer... data) throws IllegalStateException, IOExceptionSends one or more ASCII CharBuffers to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more ASCII CharBuffers (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writepublic static void write(int fd, Charset charset, CharSequence... data) throws IllegalStateException, IOExceptionSends one or more string objects to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- One or more string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writepublic static void write(int fd, CharSequence... data) throws IllegalStateException, IOExceptionSends one or more ASCII string objects to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more ASCII string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writepublic static void write(int fd, Charset charset, Collection<? extends CharSequence> data) throws IllegalStateException, IOExceptionSends a collection of string objects to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- A collection of string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writepublic static void write(int fd, Collection<? extends CharSequence> data) throws IllegalStateException, IOExceptionSends a collection of ASCII string objects to the serial port/device identified by the given file descriptor. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- A collection of string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writelnpublic static void writeln(int fd, Charset charset, CharSequence... data) throws IllegalStateException, IOExceptionSends one or more string objects each appended with a line terminator (CR+LF) to the serial port/device. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- One or more string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writelnpublic static void writeln(int fd, CharSequence... data) throws IllegalStateException, IOExceptionSends one or more ASCII string objects each appended with a line terminator (CR+LF) to the serial port/device. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- One or more ASCII string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writelnpublic static void writeln(int fd, Charset charset, Collection<? extends CharSequence> data) throws IllegalStateException, IOExceptionSends a collection of string objects each appended with a line terminator (CR+LF) to the serial port/device. - Parameters:
- fd- The file descriptor of the serial port/device.
- charset- The character set to use for encoding/decoding bytes to/from text characters
- data- A collection of string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 - 
writelnpublic static void writeln(int fd, Collection<? extends CharSequence> data) throws IllegalStateException, IOExceptionSends a collection of ASCII string objects each appended with a line terminator (CR+LF) to the serial port/device. - Parameters:
- fd- The file descriptor of the serial port/device.
- data- A collection of ASCII string objects (or an array) of data to be transmitted. (variable-length-argument)
- Throws:
- IllegalStateException
- IOException
 
 
- 
 
-