-
Notifications
You must be signed in to change notification settings - Fork 53
snagrecover: improve logging on USB access errors #75
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
base: main
Are you sure you want to change the base?
Conversation
4cd9975 to
9f72262
Compare
rgantois
left a comment
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.
Thanks for the contribution! I've requested a few changes.
When an USB Device can't be accessed, snagrecover prints a generic error message stating to check presence and access right. Improve this by testing if the USB error is a permission error. If so log an error message and some hints on how to solve it. Signed-off-by: François Foltete <[email protected]>
9f72262 to
74a6591
Compare
|
Hi Romain :) ! Finally took some time to work on this PR, tell me if it looks good for you. |
rgantois
left a comment
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.
Hi François! Thanks for the corrections! There are still a couple of things to straighten out and then we should be good to merge :)
| return dev | ||
| try: | ||
| # check for device access error on last retry | ||
| if ready_check(dev, raise_access_err=(i == retries)): |
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.
ready_check doesn't necessarily support the raise_access_err argument, so this could break.
Since the access rights permissions check is a generic operation, it would be better to separate it from ready_check, which can be customized for different USB protocols. You can define a separate function for it e.g. permissions_check, and call it directly from get_usb.
| "The following udev rule grants access to the USB device:" | ||
| ) | ||
| logger.error( | ||
| f'SUBSYSTEM=="usb", ATTRS{{idVendor}}=="{dev.idProduct:04x}", ATTRS{{idProduct}}=="{dev.idVendor:04x}", MODE="0660", TAG+="uaccess"' |
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 missed this during the first review, but idProduct and idVendor are swapped here.
| ) | ||
| elif sys.platform == "win32": | ||
| logger.error( | ||
| f"Please check that the 'libusb-win32' driver is bound to this USB device ID: {dev.idProduct:04x}:{dev.idVendor:04x}" |
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.
Oh, and idProduct and idVendor are also swapped here.
When an USB Device can't be accessed, snagrecover prints a generic error message stating to check presence
and access right.
Improve this by testing if the USB error is a permission error. If so log an error message and some hints
on how to solve it.