rpi_serial 0.1.0 copy "rpi_serial: ^0.1.0" to clipboard
rpi_serial: ^0.1.0 copied to clipboard

rpi_serial is a Dart package for using serial communication on the Raspberry Pi.

example/example.dart

import 'dart:math';
import 'dart:async';
import 'package:rpi_serial/rpi_serial.dart';
import 'basic_device.dart';

main() async {
  final serial_connection = RpiSerial();
  await testSensor(BasicSerialDevice(serial_connection));
  serial_connection.dispose();
}

// Sends a random number between [0-9] to the serial port, and reads the incoming character.
// Place a jumper between the TX and RX pins to read the characters
testSensor(BasicSerialDevice device) async {
  print(
      "Entering endless loop mode. Please connect a cable between the rx and tx pins.");
  while (true) {
    device.writeChar(Random().nextInt(10).toString());
    print(device.readChar());
    await Future.delayed(Duration(milliseconds: 500));
  }
}
4
likes
35
pub points
10%
popularity

Publisher

unverified uploader

rpi_serial is a Dart package for using serial communication on the Raspberry Pi.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

path

More

Packages that depend on rpi_serial