Skip to content

Linux: better error handling when USB permissions problem #2

@doegox

Description

@doegox

On Linux, if someone forgets to install or update his /etc/udev/rules.d/99-newae.rules to include the ballisticgel VID:PID (hey what did you expect? ;) ), the python script fails with:

ValueError: The device has no langid

The error is not really helpful for someone to understand the root of the problem and the solution.
Example:

--- a/ballisticgel/naeusb.py
+++ b/ballisticgel/naeusb.py
@@ -109,7 +109,10 @@ class NAEUSB(object):
         """
 
         devlist = self.get_possible_devices(idProduct)
-        snlist = [d.serial_number + " (" + d.product + ")\n" for d in devlist]
+        try:
+            snlist = [d.serial_number + " (" + d.product + ")\n" for d in devlist]
+        except ValueError:
+            raise IOError("Check permissions to access the USB device")
         snlist = "".join(snlist)
 
$ 
python ballisticgel.py 
 CW521 Ballistic Gel Example Script 
  by NewAE Technology Inc
 This script will continue until you exit with Ctrl-C
Traceback (most recent call last):
  File "ballisticgel.py", line 306, in <module>
    cw521.con()
  File "ballisticgel.py", line 51, in con
    self.usb.con(idProduct=[usb_pid])
  File "/home/qb/00hardware_guilde/haqerspace/tools/chipshouter/ChipSHOUTER/ChipSHOUTER-ballisticgel/ballisticgel/naeusb.py", line 115, in con
    raise IOError("Check permissions to access the USB device")
IOError: Check permissions to access the USB device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions