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();
}
serialport
for certain device
create 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.
Comments are closed.