Git Product home page Git Product logo

serial_port_flutter's Introduction

A Flutter plugin integrated with Android-SerialPort-API.

This plugin works only for Android devices.

Usage

List devices

Future<List<Device>> findDevices() async {
  return await FlutterSerialPort.listDevices();
}

Create SerialPort for certain device

Device theDevice = Device("deviceName", "/your/device/path");
int baudrate = 9600;
Serial serialPort = await FlutterSerialPort.createSerialPort(theDevice, baudrate);

Open/Close device

bool openResult = await serialPort.open();
print(serialPort.isConnected) // true
bool closeResult = await serialPort.close();
print(serialPort.isConnected) // false

Read/Write data from/to device

// Listen to `receiveStream`
serialPort.receiveStream.listen((recv) {
  print("Receive: $recv");
});

serialPort.write(Uint8List.fromList("Write some data".codeUnits));

Example

Check out the example.

Issues

Build failed on Android

If you bump into a issue like below.

Change the android:label in AndroidManifest.xml.

Check out this commit fix: ๐Ÿ› Fix Android build failed issue

App crashed on Android x86

This is all about Android permission problem. Please check out Issue #4.

serial_port_flutter's People

Contributors

bbsonlin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.