-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can send or write command, but cannot read data from Serial Port? #25
Comments
Have same issue too. I believe there is something blocking read from port. When running Putty, I can see the messages written and response by program. |
Are you sure that the data stream isn't disturbed by other code? |
Can you give me a small project which can reproduce the bug? |
Hi @FengChendian , thank you for reaching out. I am a flutter noob so my coding structure isnt perfect.
|
I will test your code tomorrow. But intuitively I think your code may be causing some problems. In SerialPort, I use singleton mode like: return _cache.putIfAbsent(
portName,
() => SerialPort._internal(
portName,
TEXT('\\\\.\\$portName'),
BaudRate: BaudRate,
Parity: Parity,
StopBits: StopBits,
ByteSize: ByteSize,
ReadIntervalTimeout: ReadIntervalTimeout,
ReadTotalTimeoutConstant: ReadTotalTimeoutConstant,
ReadTotalTimeoutMultiplier: ReadTotalTimeoutMultiplier,
openNow: openNow,
)); When you use So I guess ValueNotifier just change port name. But If you have time, you can create a new instance of actual serial port name to test, without ValueNotifier. I will finish test later. |
Hi @FengChendian, After program is closed, I open Putty, it only shows "AT" command not those after it, seen in debug console.
|
@Sunshine88888
I will test your code on ESP32 with AT firmware. But I think that some programs truncated the data before flutter get it. it's more likely due to read function blocking without data. |
@FengChendian , thank you for investigating. Good that the code works on your side. Putty is opened and closed only when the Flutter app is not running. I am unable to connect with Putty terminal when Flutter app is running, good to prove I am talking to same port. I have tried to isolate by find programs using the modem dll. I will try to find any other program/Windows which might be inteferring with the read of data. I might try rebuilding flutter. |
Some people also report bugs that cannot read data. There are also some who are able to read and write data correctly. Maybe it's due to different system/flutter version or hardware. But... I don't know. If you can help to find the bug it is much appreciated And this library depends on win32 package and FFI package. Error message can't be reached directly 😢 , although the code is based on Microsoft Serial Docs and translated from Microsoft C++ Example. |
@Sunshine88888 By the way, can your modem process '\0' or '\n' terminator correctly? Maybe AT command has been sent, but 'AT\0', 'AT\0\n', 'AT\n' and 'AT' has different response. In you code, you send 'AT\n\0'. Putty should send 'AT\r\n' or 'AT\r'. |
I've change the other package library |
I also encountered this problem, it can be sent normally, but not received, I wrote the plug-in in a tool class.
|
你的代码看起来应该没有问题,应该和之前的无法读取数据的bug是同一种,但没找到问题在哪,只知道基本都是出在AT指令和模块交互时,不知道是dartVM因为某种原因截断了消息导致size不匹配还是根本没收到。 当然最离谱的是,有的人能收到有的人收不到消息,看起来像VM的问题。。。。。 你和什么设备通信?这个库的代码我用STM32的USB Device VCP和ESP32的USB CDC/JTAG接口以及虚拟串口服务在USB 2.0 FS, Windows 11, Rog16下测试过发uint8数据流是没问题的,但AT指令之类的,以及包含\r\n这种Windows换行符的我没测试过。 |
我的系统是win11,用的是2个PL2303芯片的USB串口 |
2303挺常用,看起来问题应该出在read函数或者依赖的win32库上。 能否再问点详细的问题
|
HI, I already change the package. |
I have confirmed that Because I have removed the stage of purge com in read function and tested it using ESP32. I think I have fixed this bug in version 1.1.0 |
No description provided.
The text was updated successfully, but these errors were encountered: