libserialport
0.3.0+1, released 4 years ago by an unverified publisher
Dart FFI bindings to libserialport for accessing serial ports.
What it does
Provides Dart FFI bindings to the C library libserialport, enabling applications to list available serial ports, open them, read from and write to them.
AI-written summary of version 0.3.0+1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to communicate with hardware devices over serial ports in a Dart or Flutter application.
- You want stream-based reading capabilities from serial interfaces.
Skip it when
- You are not prepared to bundle or deploy the native libserialport C library with your target application.
- You only need high-level networking protocols instead of direct hardware serial communication.
Strengths
- Direct and efficient FFI bindings to libserialport.
- Provides streams for easy asynchronous reading of incoming serial data.
Weaknesses
- Requires bundling native binaries on the target host platform.
- Requires additional tooling or wrapper packages (like flutter_libserialport) for automated building and deployment on Flutter.
Setup
- Kind
- FFI (native library)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 2
Requires libserialport to be bundled or deployed with the host application. For Flutter apps, using flutter_libserialport is recommended as a drop-in solution to handle native builds.
import 'package:libserialport/libserialport.dart';
final name = SerialPort.availablePorts.first;
final port = SerialPort(name);
if (!port.openReadWrite()) {
print(SerialPort.lastError);
exit(-1);
}
port.write(/* ... */);
final reader = SerialPortReader(port);
reader.stream.listen((data) {
print('received: $data');
});Alternatives
Packages that do the same job and could replace libserialport.
- dart_periphery
Dart FFI bindings for Linux peripheral I/O (GPIO, I2C, SPI, etc.).
83Compare - flserial
A high-performance, asynchronous serial port plugin for Flutter using Dart FFI and Native Assets.
63Compare - stdlibc
FFI bindings to the GNU C Library on Linux and the BSD C Library on macOS
50Compare - serial_port_win32
A SerialPort library using win32 API for connecting real devices via serial port on Windows.
64Compare
Works with
Packages commonly used together with libserialport: ones it builds on, ones built on it, and its own family.
- ffilibserialport depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- dyliblibserialport depends on itResolves file names and paths of dynamic libraries across platforms.
- flutter_libserialportBuilt on libserialportA simple wrapper around libserialport for Flutter build and deployment.