项目作者: matzesoft

项目描述 :
Dart implementation of the Wiring Pi serial library.
高级语言: Dart
项目地址: git://github.com/matzesoft/wiring_pi_serial.git
创建时间: 2021-02-07T21:19:05Z
项目社区:https://github.com/matzesoft/wiring_pi_serial

开源协议:MIT License

下载


Wiring Pi Serial

Dart implementation of the Wiring Pi serial library.

I mainly created this package for one of my own projects, so I haven’t done a lot of testing yet. But I still hope this makes the creation of your flutter-pi app (or whatever you create) easier.

Installing Wiring Pi

Visit this guide to install the Wiring Pi library on your Raspberry Pi. If your are using a Raspberry Pi 4B you might also check this post.

The library (.so file) should be located under /usr/lib/libwiringPi.so.

Using the package

The first thing todo is to create the SerialDevice. It takes the path to the device (default: /dev/serial0) and the baud rate of the connection (default: 9600). Afterwards call the setup method.

  1. final serialDevice = SerialDevice();
  2. serialDevice.setup();

The SerialDevice is now setup and ready to use. You can use all the commands mentioned in the Wiring Pi documentation, except the serialPrintf method.

  1. device.sendByte(0x69);
  2. device.sendString("Hello Serial Device!");
  3. final values = device.getValues();
  4. for (int i = 0; i < values.length; i++) {
  5. print("Value at $i: ${values[i]}");
  6. }
  7. device.closePort();

If any of the methods fails a SerialException will be throwen.