-
Notifications
You must be signed in to change notification settings - Fork 31
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
Bugfix/handle hidapi exceptions in sendReport #55
base: master
Are you sure you want to change the base?
Bugfix/handle hidapi exceptions in sendReport #55
Conversation
Thanks for the pull request, i added some remarks :) |
Hey @flok - sorry, I am not seeing the remarks. Where can I find them? |
Btw, this fixes #48. |
You should see them in this thread at the top as a review from me |
@@ -114,6 +114,7 @@ def init(self) -> None: | |||
self.battery = DSBattery() | |||
self.conType = self.determineConnectionType() # determine USB or BT connection | |||
self.ds_thread = True | |||
self.connected = True |
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.
Is this variable really needed? you only set it 3 times but never compare any value to it?
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.
Hey @flok - this is intended to be used externally to indicated the controller is connected.
As an example, here is how I am using it in my project. https://github.com/dalethomas81/ArfBotOS/blob/main/Controller/DualSenseServer.py#L380
Is there another way to know if it is connected? I am open to alternative approaches.
except IOError: | ||
self.connected = False | ||
break | ||
|
||
except AttributeError: | ||
self.connected = False | ||
break |
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.
In my understanding you could also just break when a exception is thrown and the class variable connected is not needed
You are right, my bad. Mostly working with gitlab now a days and forgot to press the button. You should be able to see it now |
No worries! I did respond to your review. Can you let me know if that is satisfactory? Thank you. |
Handle an exception generated by hidapi in the
sendReport
thread. This exception is thrown when no controller is connected. Since the exception is not handled, the thread ends, and the service needs to be restarted to recover. By handling these exceptions, the service becomes fault tolerant and is able to recover automatically.Connected
property to indicate when the device is not connected.