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

Can flutter_serial_communication connect to two serial ports? #3

Open
Huangshier opened this issue Jun 2, 2023 · 2 comments
Open

Comments

@Huangshier
Copy link

@OverRide
void initState() {
super.initState();

_spTestSmq
    .getSerialMessageListener()
    .receiveBroadcastStream()
    .listen((eventSmq) {
  String tmpString = ascii.decode(eventSmq);
  _showText("${DateTime.now()}>>Rx: $eventSmq string:  $tmpString\r\n");
});

_spTestSmq
    .getDeviceConnectionListener()
    .receiveBroadcastStream()
    .listen((eventSmq) {
  setState(() {
    isConnectedSmq = eventSmq;
  });
});

_spTest
    .getSerialMessageListener()
    .receiveBroadcastStream()
    .listen((event) {
  String hexString = toReadable(event);
  _showText("${DateTime.now()}>>Rx: $event Hex: $hexString\r\n");
});

_spTest
    .getDeviceConnectionListener()
    .receiveBroadcastStream()
    .listen((event) {
  setState(() {
    isConnected = event;
  });
});

}
When I connect to _spTestSmq, isConnected is true instead of isConnectedSmq, and isConnectedSmq has no response. When receiving data, it displays _showText("${DateTime.now()}>>Rx: $event Hex: $hexString\r\n") instead of _showText("${DateTime.now()}>>Rx: $eventSmq string: $tmpString\r\n"). Is my method wrong?

@farellsujanto
Copy link
Owner

Sorry but currently the library only supports one connection at a time, will create the feature on my free time

@Huangshier
Copy link
Author

I see, thank you. I hope to see this feature soon!

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

2 participants