Skip to content
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

USB Serial port not listening on connect #70

Open
manishbuttan opened this issue Oct 16, 2022 · 3 comments
Open

USB Serial port not listening on connect #70

manishbuttan opened this issue Oct 16, 2022 · 3 comments

Comments

@manishbuttan
Copy link

No description provided.

@manishbuttan
Copy link
Author

Hi, when I open the port in flutter to my USB serial port, it opens fine. But the port won't listen for incoming messages. If I close the port in the app and open it from Tera Term and close it, then open it again in the app, the communcation works fine and the incoming messages are working.

What is the proper way of opening the port and starting communication with the serial port without opening it externally?

Platform : Windows. Flutter.

if (!port.openReadWrite()) {
print("Port not opened: ${SerialPort.lastError}");
}

try {
serialPortReader = SerialPortReader(port);
serialPortReader.stream.listen((data) {
String message = String.fromCharCodes(data);
_processUSBData(message);
});
} catch (e) {
print(SerialPort.lastError);
}

@BluesCool
Copy link

Hello,Did you solve this problem, I also encountered.

@micheljung
Copy link

micheljung commented Apr 21, 2024

You weren't setting up the port correctly, see https://stackoverflow.com/questions/77384956/read-serial-port-in-flutter-dart/78360666#78360666

From the documentation:

For each setting in a port configuration, a special value of -1 can be used, which will cause that setting to be left alone when the configuration is applied by SerialPort.config setter.

When a new configuration is created, all of its settings are initially set to the special -1 value.

You should always configure all settings before using a port. There are no default settings applied by the library. When you open a port, it may have default settings from the OS or driver, or the settings left over by the last program to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants