-
Notifications
You must be signed in to change notification settings - Fork 16
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
Create new SerialPort object when System.OperationException occurs #335
Conversation
Recreate SerialPort object when Meadow is reset and the SerialPort connection is lost.
@doingnz thanks for sending the PR. I'll be playing with it this weekend and will reply back on Monday. |
I did some initial testing on Mac and I'm not seeing the reconnect, so think I may be doing something wrong. @doingnz could you outline, in the PR description, the detailed steps required to test the change. |
I have added testing steps to description. Note only tested on Windows. You may want to enable VS2022 to break on System.OperationCanceledException to confirm this exception is raised on a MAC or other supported platforms. When you press Reset button on Meadow, then the lower driver layers for the SerialPort should raise an exception as the USB connection was lost. |
There may be other unintended consequences of this change on the CLI when using the
|
If I comment out the exception handler, then Someone more familiar with the CLI would need to give some thought on where is the best place to create a new SerialPort object after the connection is lost when the USB disconnects on Meadow restart. |
@doingnz thanks again for the PR, but just wanted to let you know that we've been working on v2 of the CLI (https://github.com/WildernessLabs/Meadow.CLI/tree/develop/Source/v2 ) so the team's focus is in getting that ready and stable for public consumption. If you have the time/cycles please grab the v2-alpha from the latest CI off After downloading the zip file and extracting it, be sure to uninstall the current CLI 1st, then: The commands will change for that release. So for flashing use: then the usual D. |
Recreate SerialPort object when Meadow is reset and the SerialPort connection is lost.
This change feels like a hack, however simple testing shows it works. With this change, I can do
meadow listen
and then reset the Meadow by pressing the physical Reset button or I can Publish a new app from the cloud and listen reconnects when the Meadow restarts after outputting a message.Long term might be better to pass in a
SerialPortFactory
rather than aSerialPort
given SerialPort.Close() or SerialPort.Dispose() amount to the same thing forcing one to do a new SerialPort(...)Testing was only done on Windows, need to test on other supported platforms.
Testing Steps - Local Hardware Reset.
meadow listen
and confirm trace output displayed from running applicationmeadow listen
OTA publish
meadow listen
and confirm trace output displayed from running applicationmeadow listen