Serial class Null safety

Serial wrapper functions for Linux userspace termios tty devices.

c-periphery Serial documentation.

Constructors

Serial(String path, Baudrate baudrate)
Opens the tty device at the specified path (e.g. "/dev/ttyUSB0"), with the specified baudrate, and the defaults of 8 data bits, no parity, 1 stop bit, software flow control (xonxoff) off, hardware flow control (rtscts) off.
Serial.advanced(String path, Baudrate baudrate, DataBits databits, Parity parity, StopBits stopbits, bool xonxoff, bool rtsct)
Opens the tty device at the specified path (e.g. "/dev/ttyUSB0"), with the specified baudrate, databits, parity, stopbits, software flow control (xonxoff), and hardware flow control (rtsct) settings. [...]

Properties

baudrate Baudrate
final
databits DataBits
final
hashCode int
The hash code for this object. [...]
read-only, inherited
parity Parity
final
path String
final
rtsct bool
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
stopbits StopBits
final
xonxoff bool
final

Methods

dispose() → void
Releases all native resources.
flush() → void
Flushes the write buffer of the serial port (i.e. force its write immediately).
getBaudrate() Baudrate
Returns the baudrate. See baudrate2Int for converting the result to an integer.
getDataBits() DataBits
Returns the number of data bits. See databits2Int for converting the result to an integer.
getErrno() int
Returns the libc errno of the last failure that occurred.
getInputWaiting() int
Gets the number of bytes waiting to be read from the serial port.
getOutputWaiting() int
Gets the number of bytes waiting to be written to the serial port.
getParity() Parity
Returns the parity property.
getRTSCTS() bool
Returns if the RTS/CTS (request to send/ clear to send) flow control is enabled or disabled.
getSerialFD() int
Returns the file descriptor (for the underlying tty device) of the Serial handle.
getSerialInfo() String
Returns a string representation of the Serial handle.
getStopBits() StopBits
Returns the number of stop bits. See stopbits2Int for converting the result to an integer.
getVMIN() int
Gets the termios VMIN settings, respectively, of the underlying tty device. VMIN specifies the minimum number of bytes returned from a blocking read. VTIME specifies the timeout in seconds of a blocking read. When both VMIN and VTIME settings are configured, VTIME acts as an interbyte timeout that restarts on every byte received, and a blocking read will block until either VMIN bytes are read or the VTIME timeout expires after the last byte read. See the termios man page for more information. vmin can be between 0 and 255. vtime can be between 0 and 25.5 seconds, with a resolution of 0.1 seconds.
getVTIME() double
Gets the termios VTIME settings, respectively, of the underlying tty device. VMIN specifies the minimum number of bytes returned from a blocking read. VTIME specifies the timeout in seconds of a blocking read. When both VMIN and VTIME settings are configured, VTIME acts as an interbyte timeout that restarts on every byte received, and a blocking read will block until either VMIN bytes are read or the VTIME timeout expires after the last byte read. See the termios man page for more information. vmin can be between 0 and 255. vtime can be between 0 and 25.5 seconds, with a resolution of 0.1 seconds.
getXONXOFF() bool
Returns if the setXONXOFF protocol is enabled or disabled.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
poll(int timeout) bool
Polls for data available for reading from the serial port. [...]
read(int len, int timeout) SerialReadEvent
Reads up to len number of bytes from the serial port with the specified millisecond timeout. [...]
setBaudrate(Baudrate baudrate) → void
Sets the baudrate.
setDataBits(DataBits databits) → void
Sets the number of databits.
setParity(Parity parity) → void
Sets the parity.
setRTSCTS(bool flag) → void
flag enables, or disables the RTSCTS flow control.
setStopBits(StopBits stopbits) → void
Sets the number of stopbits.
setVMIN(int vmin) → void
Sets the termios VMIN settings, respectively, of the underlying tty device. VMIN specifies the minimum number of bytes returned from a blocking read. VTIME specifies the timeout in seconds of a blocking read. When both VMIN and VTIME settings are configured, VTIME acts as an interbyte timeout that restarts on every byte received, and a blocking read will block until either VMIN bytes are read or the VTIME timeout expires after the last byte read. See the termios man page for more information. vmin can be between 0 and 255. vtime can be between 0 and 25.5 seconds, with a resolution of 0.1 seconds.
setVTIME(double vtime) → void
Sets the termios VTIME settings, respectively, of the underlying tty device. VMIN specifies the minimum number of bytes returned from a blocking read. VTIME specifies the timeout in seconds of a blocking read. When both VMIN and VTIME settings are configured, VTIME acts as an interbyte timeout that restarts on every byte received, and a blocking read will block until either VMIN bytes are read or the VTIME timeout expires after the last byte read. See the termios man page for more information. vmin can be between 0 and 255. vtime can be between 0 and 25.5 seconds, with a resolution of 0.1 seconds.
setXONXOFF(bool flag) → void
flag enables, or disables the setXONXOFF protocol.
toString() String
A string representation of this object. [...]
inherited
write(List<int> list) int
Writes a list of bytes to the serial port. Returns the number of bytes written on success,
writeString(String data) int
Writes a string as list of UTF8 aware bytes to the serial port. Returns the number of bytes written on succes

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

baudrate2Int(Baudrate baudrate) int
Converts a baudrate enum to an int value;
databits2Int(DataBits databits) int
Converts a databits enum to an int value;
getSerialErrorCode(int value) SerialErrorCode
Converts the native error code value to SerialErrorCode.
stopbits2Int(StopBits stopbits) int
Converts a stopbits enum to an int value;