-
Notifications
You must be signed in to change notification settings - Fork 113
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
java.lang.InterruptedException on close invocation #104
Comments
Hi, |
i have same problem my code is like this final port = usbDevice.create();
if (await port.open()) {
debugPrint("connection success");
port.setPortParameters(
9600, UsbPort.DATABITS_8, UsbPort.STOPBITS_1, UsbPort.PARITY_NONE);
debugPrint("port parameter: ${port.toString()}");
final anser = <int>[];
Timer? timeoutTimer;
bool success = false;
final completer = Completer<void>();
late final StreamSubscription<Uint8List> sub;
sub = port.inputStream!.listen((event) {
anser.addAll(event);
debugPrint("event: $event, anser: $anser");
if (response.isEmpty ||
(response.isNotEmpty && anser.containsAll(response))) {
debugPrint("success");
sub.cancel();
success = true;
if (timeoutTimer != null) timeoutTimer.cancel();
completer.complete();
}
});
await port.write(dataSend);
timeoutTimer = Timer(Duration(milliseconds: timeOut), () {
if (!success) {
debugPrint('Timeout: Did not find the required data within 3 seconds');
sub.cancel(); //cancel Stream
completer.complete(); // finish Completer
}
});
await completer.future;
// all task finished.
port.close(); // exception is here
}
|
Does your android device work with the CH34xSerialDevice when using the example app? What does the error look like? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I try to close connection with
port.close();
I get the following error in console:there is something that I'm doing wrong?
Thank you
The text was updated successfully, but these errors were encountered: