SerialDevice class
A wrapper around the package:libserialport
library.
- Check DelegateSerialPort.allPorts for a list of all available ports.
- Call init to open the port
- Use write to write bytes to the port. Strings are not supported
- Listen to stream to get incoming data
- Call dispose to close the port
Constructors
- SerialDevice({required String portName, required Duration readInterval, required BurtLogger logger, int baudRate = 9600})
- Opens a new serial connection with the given port name and baud rate.
- SerialDevice.fromPort(SerialPortInterface _port, {required Duration readInterval, required BurtLogger logger})
- Opens a serial connection on the given port.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isOpen → bool
-
Whether the port is open (ie, the device is connected).
no setter
- logger → BurtLogger
-
The logger to use
final
- portName → String
-
The name of the port to connect to.
no setter
- readInterval → Duration
-
How often to read from the port.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
Uint8List> -
All incoming bytes coming from the port.
no setter
Methods
-
closeStream(
) → Future< void> - Closes the stream so it cannot be listened to.
-
dispose(
) → Future< void> -
Closes the connection to the device.
override
-
init(
) → Future< bool> -
Initializes the connection to the device.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDisconnect(
) → Future< void> -
A callback to run when the program has disconnected from the Dashboard.
inherited
-
readBytes(
[int? count]) → Uint8List -
Reads bytes from the port. If
count
is provided, only reads that number of bytes. -
startListening(
) → void - Starts listening to data sent over the serial port via stream.
-
stopListening(
) → void - Stops listening to the serial port.
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
Uint8List data) → void - Writes data to the port.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited