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

How to reopen a closed/faulty connection with BufferedAsyncSerial #12

Open
RicardoM17 opened this issue Feb 20, 2024 · 1 comment
Open

Comments

@RicardoM17
Copy link

Hey!
I'm adding your library to my project but I am having some issues. I want to reliable reconnect to a device if the connection has been lost.

Right now I'm checking if !serial_.isOpen() and if so I'm calling serial_.open. This works fine. Then as testing I'm disconnecting the USB cable which means that now we have serial_.errorStatus() == true. Then I want to replug the connector and for the connection to resume however the obvious choicse of close() and then open doesn't work as expected as it seems that the errorStatus() is not being properly cleared.

If I don't try to close, and just continuously try to open the connection I see that the open() call returns without any error, the port is open and without any error, but then at the next iteration of the loop it has an error once again. I believe that the thread isn't properly handled in this scenario and a new one is created and destroyed everytime.

The only way that I have gotten this to work is by resetting the connection with:

serial_.~BufferedAsyncSerial();
new (&serial_) BufferedAsyncSerial();

But this seems a workaround that shouldn't be needed. Do you have a solution for this @fedetft ?

Thank you very much in advance.

@RicardoM17
Copy link
Author

@fedetft any clues? I'm currently debugging this and I could offer a fix or explanation for future users but I could also use some help from your side.

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

1 participant