FengChendian / serial_port_win32

A flutter SerialPort library using win32 API.
BSD 3-Clause "New" or "Revised" License
30 stars 8 forks source link

cannot read data #26

Closed dalmuri closed 10 months ago

dalmuri commented 10 months ago

I just used the example code(just edited baudrate to 9600 for my device). Sending has no problem, but receiving don't work. I checked my device sent data to the app.

When I used readBytesOnce function, it read empty list.

Can anyone tell me why receiving didn't work? Does the example code works for you?

FengChendian commented 10 months ago

Maybe due to async stream. Some people can not read data. I guessed that it's due to asynchronous data race. So I think that I should let people manage async data by themselves. And I will rewrite receive code in next version, exposing base read API without stream and removing all async read stream structure in endless loop.

FengChendian commented 10 months ago

I have removed readBytesOnce function and tried to fix readBytesOnListen purge bugs.

Please try readBytesOnListen function of version 1.1.0:

      port.readBytesOnListen(16, (value) {
        data = String.fromCharCodes(value);
        print(data);
      });
FengChendian commented 10 months ago

I have test new code using ESP32. I should solve this bug. So I will close this issue.

If the problem persists, please go to collection #27 . I will track it.