https://github.com/matzeema/wiring_pi_serial
Dart implementation of the Wiring Pi serial library.
https://github.com/matzeema/wiring_pi_serial
dart ffi uart wiring-pi
Last synced: about 2 months ago
JSON representation
Dart implementation of the Wiring Pi serial library.
- Host: GitHub
- URL: https://github.com/matzeema/wiring_pi_serial
- Owner: matzeema
- License: mit
- Created: 2021-02-07T21:19:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T19:23:19.000Z (over 4 years ago)
- Last Synced: 2025-02-08T16:39:40.169Z (4 months ago)
- Topics: dart, ffi, uart, wiring-pi
- Language: Dart
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](http://wiringpi.com/download-and-install/) to install the Wiring Pi library on your Raspberry Pi. If your are using a Raspberry Pi 4B you might also check this [post](http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/).
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.
```dart
final serialDevice = SerialDevice();
serialDevice.setup();
```The `SerialDevice` is now setup and ready to use. You can use all the commands mentioned in the [Wiring Pi documentation](http://wiringpi.com/reference/serial-library/), except the `serialPrintf` method.
```dart
device.sendByte(0x69);
device.sendString("Hello Serial Device!");final values = device.getValues();
for (int i = 0; i < values.length; i++) {
print("Value at $i: ${values[i]}");
}device.closePort();
```If any of the methods fails a `SerialException` will be throwen.