Package com.pi4j.jni

Class Serial


  • public class Serial
    extends Object
    THIS IS CURRENTLY A NO-IMPL STUB. THIS IS WHERE A NEW SERIAL LIBRARY IMPLEMENTATION IS PLANNED.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      static void close​(int fd)
      Closes the serial port/device identified by the file descriptor.
      static void discardAll​(int fd)
      Discards all data in the serial transmit and receive buffers.
      static void discardInput​(int fd)
      Discards all data in the serial receive and transmit buffer.
      static void discardOutput​(int fd)
      Discards all data in the serial transmit buffer.
      static void flush​(int fd)
      Forces (drains) all data in transmit buffers.
      static boolean getCD​(int fd)
      Get the CD (carrier-detect) pin state.
      static boolean getCTS​(int fd)
      Get the CST (clear-to-send) pin state.
      static boolean getDSR​(int fd)
      Get the DSR (data-set-ready) pin state.
      static boolean getDTR​(int fd)
      Get the DTR (data-terminal-ready) pin state.
      static boolean getRI​(int fd)
      Get the RI (ring-indicator) pin state.
      static boolean getRTS​(int fd)
      Get the RTS (request-to-send) pin state.
      static int open​(String device, int baud)
      This opens and initializes the serial device and sets the communication parameters.
      static int open​(String device, int baud, int dataBits)
      This opens and initializes the serial device and sets the communication parameters.
      static int open​(String device, int baud, int dataBits, int parity)
      This opens and initializes the serial port/device and sets the communication parameters.
      static int open​(String device, int baud, int dataBits, int parity, int stopBits)
      This opens and initializes the serial port/device and sets the communication parameters.
      static int open​(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 void read​(int fd, int length, OutputStream stream)
      Reads a length bytes from the serial port/device into a provided OutputStream.
      static void read​(int fd, int length, ByteBuffer buffer)
      Reads a length bytes from the serial port/device into a provided ByteBuffer.
      static CharBuffer read​(int fd, int length, Charset charset)
      Reads a length of bytes from the port/serial device.
      static void read​(int fd, int length, Charset charset, Writer writer)
      Reads a length bytes from the serial port/device into a provided Writer.
      static void read​(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 void read​(int fd, OutputStream stream)
      Reads all available bytes from the serial device into a provided OutputStream.
      static void read​(int fd, ByteBuffer buffer)
      Reads all available bytes from the serial device into a provided ByteBuffer.
      static CharBuffer read​(int fd, Charset charset)
      Reads all available bytes from the port/serial device.
      static void read​(int fd, Charset charset, Writer writer)
      Reads all available bytes from the serial port/device into a provided Writer.
      static void read​(int fd, Collection<ByteBuffer> collection)
      Reads all available bytes from the serial port/device into a provided collection of ByteBuffer objects.
      static void sendBreak​(int fd)
      Send a BREAK signal to connected device for at least 0.25 seconds, and not more than 0.5 seconds
      static void sendBreak​(int fd, int duration)
      Send a BREAK signal to connected device.
      static void setBreak​(int fd, boolean enabled)
      Send a constant BREAK signal to connected device.
      static void setDTR​(int fd, boolean enabled)
      Control the DTR (data-terminal-ready) pin state.
      static void setRTS​(int fd, boolean enabled)
      Control the RTS (request-to-send) pin state.
      static void write​(int fd, byte... data)
      Sends one of more bytes to the serial device identified by the given file descriptor.
      static void write​(int fd, byte[]... data)
      Sends one of more bytes arrays to the serial device identified by the given file descriptor.
      static void write​(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 void write​(int fd, char... data)
      Sends an array of ASCII characters to the serial port/device identified by the given file descriptor.
      static void write​(int fd, InputStream input)
      Read content from an input stream of data and write it to the serial port transmit buffer.
      static void write​(int fd, CharSequence... data)
      Sends one or more ASCII string objects to the serial port/device identified by the given file descriptor.
      static void write​(int fd, ByteBuffer... data)
      Read the content of byte buffer and write the data to the serial port transmit buffer.
      static void write​(int fd, CharBuffer... data)
      Sends one or more ASCII CharBuffers to the serial port/device identified by the given file descriptor.
      static void write​(int fd, Charset charset, char... data)
      Sends an array of characters to the serial port/device identified by the given file descriptor.
      static void write​(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 void write​(int fd, Charset charset, CharSequence... data)
      Sends one or more string objects to the serial port/device identified by the given file descriptor.
      static void write​(int fd, Charset charset, CharBuffer... data)
      Sends one or more CharBuffers to the serial port/device identified by the given file descriptor.
      static void write​(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 void write​(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 void writeln​(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 void writeln​(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 void writeln​(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 void writeln​(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

      • BAUD_RATE_50

        public static int BAUD_RATE_50
      • BAUD_RATE_75

        public static int BAUD_RATE_75
      • BAUD_RATE_110

        public static int BAUD_RATE_110
      • BAUD_RATE_134

        public static int BAUD_RATE_134
      • BAUD_RATE_150

        public static int BAUD_RATE_150
      • BAUD_RATE_200

        public static int BAUD_RATE_200
      • BAUD_RATE_300

        public static int BAUD_RATE_300
      • BAUD_RATE_600

        public static int BAUD_RATE_600
      • BAUD_RATE_1200

        public static int BAUD_RATE_1200
      • BAUD_RATE_1800

        public static int BAUD_RATE_1800
      • BAUD_RATE_2400

        public static int BAUD_RATE_2400
      • BAUD_RATE_4800

        public static int BAUD_RATE_4800
      • BAUD_RATE_9600

        public static int BAUD_RATE_9600
      • BAUD_RATE_19200

        public static int BAUD_RATE_19200
      • BAUD_RATE_38400

        public static int BAUD_RATE_38400
      • BAUD_RATE_57600

        public static int BAUD_RATE_57600
      • BAUD_RATE_115200

        public static int BAUD_RATE_115200
      • BAUD_RATE_230400

        public static int BAUD_RATE_230400
      • PARITY_NONE

        public static int PARITY_NONE
      • PARITY_ODD

        public static int PARITY_ODD
      • PARITY_EVEN

        public static int PARITY_EVEN
      • PARITY_MARK

        public static int PARITY_MARK
      • PARITY_SPACE

        public static int PARITY_SPACE
      • DATA_BITS_5

        public static int DATA_BITS_5
      • DATA_BITS_6

        public static int DATA_BITS_6
      • DATA_BITS_7

        public static int DATA_BITS_7
      • DATA_BITS_8

        public static int DATA_BITS_8
      • STOP_BITS_1

        public static int STOP_BITS_1
      • STOP_BITS_2

        public static int STOP_BITS_2
      • FLOW_CONTROL_NONE

        public static int FLOW_CONTROL_NONE
      • FLOW_CONTROL_HARDWARE

        public static int FLOW_CONTROL_HARDWARE
      • FLOW_CONTROL_SOFTWARE

        public static int FLOW_CONTROL_SOFTWARE
    • Method Detail

      • open

        public 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
      • open

        public 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
      • open

        public 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
      • open

        public 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
      • open

        public 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
      • close

        public static void close​(int fd)
                          throws IOException

        Closes the serial port/device identified by the file descriptor.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • discardInput

        public static void discardInput​(int fd)
                                 throws IOException

        Discards all data in the serial receive and transmit buffer.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • discardOutput

        public static void discardOutput​(int fd)
                                  throws IOException

        Discards all data in the serial transmit buffer.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • discardAll

        public static void discardAll​(int fd)
                               throws IOException

        Discards all data in the serial transmit and receive buffers.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • flush

        public static void flush​(int fd)
                          throws IOException

        Forces (drains) all data in transmit buffers.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • sendBreak

        public static void sendBreak​(int fd,
                                     int duration)
                              throws IOException

        Send 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
      • sendBreak

        public static void sendBreak​(int fd)
                              throws IOException

        Send 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
      • setBreak

        public static void setBreak​(int fd,
                                    boolean enabled)
                             throws IOException

        Send 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
      • setRTS

        public static void setRTS​(int fd,
                                  boolean enabled)
                           throws IOException

        Control 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
      • setDTR

        public static void setDTR​(int fd,
                                  boolean enabled)
                           throws IOException

        Control 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
      • getRTS

        public static boolean getRTS​(int fd)
                              throws IOException

        Get the RTS (request-to-send) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • getDTR

        public static boolean getDTR​(int fd)
                              throws IOException

        Get the DTR (data-terminal-ready) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • getCTS

        public static boolean getCTS​(int fd)
                              throws IOException

        Get the CST (clear-to-send) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • getDSR

        public static boolean getDSR​(int fd)
                              throws IOException

        Get the DSR (data-set-ready) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • getRI

        public static boolean getRI​(int fd)
                             throws IOException

        Get the RI (ring-indicator) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • getCD

        public static boolean getCD​(int fd)
                             throws IOException

        Get the CD (carrier-detect) pin state.

        Parameters:
        fd - The file descriptor of the serial port/device.
        Throws:
        IOException
      • available

        public 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
      • read

        public static byte[] read​(int fd)
                           throws IOException

        Reads 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
      • read

        public static byte[] read​(int fd,
                                  int length)
                           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.
        Returns:
        Returns a byte array with the data read from the serial port.
        Throws:
        IOException
      • read

        public static void read​(int fd,
                                ByteBuffer buffer)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                int length,
                                ByteBuffer buffer)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                OutputStream stream)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                int length,
                                OutputStream stream)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                Collection<ByteBuffer> collection)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                int length,
                                Collection<ByteBuffer> collection)
                         throws IOException

        Reads 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
      • read

        public 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
      • read

        public 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
      • read

        public static void read​(int fd,
                                Charset charset,
                                Writer writer)
                         throws IOException

        Reads 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
      • read

        public static void read​(int fd,
                                int length,
                                Charset charset,
                                Writer writer)
                         throws IOException

        Reads 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
      • write

        public static void write​(int fd,
                                 byte[] data,
                                 int offset,
                                 int length)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 byte... data)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 byte[]... data)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 ByteBuffer... data)
                          throws IOException
        Read 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
      • write

        public static void write​(int fd,
                                 InputStream input)
                          throws IOException
        Read 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
      • write

        public static void write​(int fd,
                                 Charset charset,
                                 char[] data,
                                 int offset,
                                 int length)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 Charset charset,
                                 char... data)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 char... data)
                          throws IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 Charset charset,
                                 CharBuffer... data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 CharBuffer... data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 Charset charset,
                                 CharSequence... data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 CharSequence... data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 Charset charset,
                                 Collection<? extends CharSequence> data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • write

        public static void write​(int fd,
                                 Collection<? extends CharSequence> data)
                          throws IllegalStateException,
                                 IOException

        Sends 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
      • writeln

        public static void writeln​(int fd,
                                   Charset charset,
                                   CharSequence... data)
                            throws IllegalStateException,
                                   IOException

        Sends 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
      • writeln

        public static void writeln​(int fd,
                                   CharSequence... data)
                            throws IllegalStateException,
                                   IOException

        Sends 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
      • writeln

        public static void writeln​(int fd,
                                   Charset charset,
                                   Collection<? extends CharSequence> data)
                            throws IllegalStateException,
                                   IOException

        Sends 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
      • writeln

        public static void writeln​(int fd,
                                   Collection<? extends CharSequence> data)
                            throws IllegalStateException,
                                   IOException

        Sends 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