项目作者: jpnurmi

项目描述 :
Serial Port for Dart
高级语言: Dart
项目地址: git://github.com/jpnurmi/libserialport.dart.git
创建时间: 2020-08-04T22:01:33Z
项目社区:https://github.com/jpnurmi/libserialport.dart

开源协议:Other

下载


Dart FFI bindings to libserialport

pub
CI
license: LGPL3+

TIP: See also flutter_libserialport for automatic building and deploying of libserialport.

This Dart package is based on libserialport,
which is a minimal C-library created by the sigrok project, and
released under the LGPL3+ license.

Supported platforms:

  • Linux
  • macOS
  • Windows
  • Android

This package uses dart:ffi to call
libserialport‘s C APIs, which implies that libserialport must be bundled to or deployed
with the host application. It can be tedious to build and deploy libserialport on all target
platforms, but in case you are building a Flutter app instead of a pure Dart app, there is
a ready-made drop-in solution called flutter_libserialport
that utilizes Flutter’s build system to build and deploy libserialport on all supported platforms:

Usage

  1. import 'package:libserialport/libserialport.dart';
  2. final name = SerialPort.availablePorts.first;
  3. final port = SerialPort(name);
  4. if (!port.openReadWrite()) {
  5. print(SerialPort.lastError);
  6. exit(-1);
  7. }
  8. port.write(/* ... */);
  9. final reader = SerialPortReader(port);
  10. reader.stream.listen((data) {
  11. print('received: $data');
  12. });

To use this package, add libserialport as a dependency in your pubspec.yaml file.