usbserial
usbserial copied to clipboard
Write files in pendrive
Is it possible to use this lib to save files to a pendrive?
I tried doing this:
final bytes = <int>[];
await yt.videos.streamsClient.get(audioStream).listen((chunk) {
bytesReceived += chunk.length;
bytes.addAll(chunk);
}, onDone: () async{
MyLog.log('Done onDone');
}, onError: (error) async{
MyLog.log('Done error: $error');
}).asFuture();
final devices = await UsbSerial.listDevices();
final port = await devices.first.create();
final openResult = await port?.open();
if ( !(openResult ?? false)) {
MyLog.log("Failed to open");
return;
}
port?.inputStream?.listen((Uint8List event) {
MyLog.log('Event close');
port.close();
});
await port?.write(Uint8List.fromList(bytes));
But I get the error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(UsbSerialPortAdapter, Not an Serial device., null, null)
Hi, what exactly are you trying to achieve? What system are you working on (android / ios / web / linux / ...)
If the device you want to write to is mounted, the package path_provider might be a better choice.
If you really want to use this package, you would have to handle all the low level stuff, which is normally done by the operating system.
Hi, what exactly are you trying to achieve? What system are you working on (android / ios / web / linux / ...)
If the device you want to write to is mounted, the package path_provider might be a better choice.
If you really want to use this package, you would have to handle all the low level stuff, which is normally done by the operating system.
No, path provider dont returning external directories: https://stackoverflow.com/questions/77739716/write-file-in-flash-drive-android-only
To give your users the possibility to choose the location file_picker is another idea.
To give your users the possibility to choose the location file_picker is another idea.
It's not working either lol, I explained it better on stack overflow, but in file_picker, when you select the path inside the pendrive it only returns "/"
This doesn't sound like a supported serial device.