-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Modified to reset and close the Stream Deck on panic or termination signal #57
Merged
+59
−24
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't just try to reset the device once after opening it? After
closeDevice
we're terminating deckmaster anyway, as we return an error below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resetting the device puts it back (at least visually) to it's power-on state, with the Elgato logo. If we don't reset before closing it, The screen is left showing what it had before the close, which might have stuff like a frozen clock or CPU/Memory widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I suggest resetting it once after opening and removing the
closeDevice
calls except the deferred one in line 204. This should have the same effect then: if we encounter any error during initialization (lines 174, 181, 189) we would have already reset the device and can just return the error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that what needs to be done is a close of the device (
dev.Close()
) more than a reset of the device. Ifdev.Close()
is not called, then the Stream Deck will need to be unplugged and replugged. In order for this to work, IinitDevice()
will need to return dev (rather than nil) along with the error so that main can close the device.The code would then look like
Sound OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, but instead of closing the device and then shutting down again, maybe we could just try to close the device and re-open it inside Deckmaster, if we encounter an error during initialization? That would prevent the user from having to re-plug the device or restart Deckmaster. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be what you're getting at, but in my case, when the device is in a bad state (pretty much when
dev.Close()
is not called), it stays in that bad state until I re-plug the device.In using deckmaster so far (which is only for a few days), those initialization operations (get firmware version, reset, set brightness) have never failed, but that doesn't mean they won't ever fail. What I'm trying to say is that I probably don't care too much how this is handled here, but at least we should
dev.Close()
so that there's less chance of needed a re-plug at this point.As for a retry of initialization, I suppose that's possible, but I personally don't think it's necessary. At initialization time, it would be pretty obvious if things are not working, and the user could start troubleshooting. If it's hardware failure, we probably don't want to keep retrying "known good" things that are suddenly failing.
I've pushed the change modeled on what I said above, but I'll change it to whatever you feel is best here since I don't feel too strongly about how things fail at initialization time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, starting to understand the situation a little better now!