usbserial icon indicating copy to clipboard operation
usbserial copied to clipboard

Write files in pendrive

Open Bestfastfire opened this issue 1 year ago • 4 comments

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)

Bestfastfire avatar Dec 31 '23 15:12 Bestfastfire

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.

rockerer avatar Feb 05 '24 21:02 rockerer

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

Bestfastfire avatar Feb 05 '24 22:02 Bestfastfire

To give your users the possibility to choose the location file_picker is another idea.

rockerer avatar Feb 06 '24 07:02 rockerer

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 "/"

Bestfastfire avatar Feb 06 '24 10:02 Bestfastfire

This doesn't sound like a supported serial device.

altera2015 avatar Jul 12 '24 14:07 altera2015