UsbSerial icon indicating copy to clipboard operation
UsbSerial copied to clipboard

Write for async write function finishes

Open efreibe opened this issue 5 years ago • 4 comments

Hello,

I'm trying to open the usb port, send data and close it. But I realized that not all the data is transferred to destination.

I suspect that I send a close command while the driver is writing and my data is truncated.

How can I listen to know when all buffer was totally written to the port?

Thank you

efreibe avatar Apr 24 '19 23:04 efreibe

Yes, I'm doing that, I've created a thread and I'm making calls to syncWrite

I simply created the issue because it will be helpful for other people making async requests to get a notification when the write operation is done.

I'm using flutter and the easy way to send a success message back to the channel is waiting for a notification from write async method. But I managed to do it in other way.

You can close it, it's not a blocking issue.

efreibe avatar Apr 26 '19 17:04 efreibe

@efreibe Like a JS promise with "then" added at the end to handle the result of the operation? I guess it could be added because it is a nice idea.

felHR85 avatar Apr 26 '19 17:04 felHR85

Good to hear that. It will give more control to the write process.

efreibe avatar Apr 27 '19 02:04 efreibe