Skip to content

Commit

Permalink
Pad serial numbers to 32 character for passing to pyUSB
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicgs authored and ktemkin committed Dec 14, 2018
1 parent f3d4506 commit eeb44ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libgreat/host/pygreat/comms_backends/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def __init__(self, **device_identifiers):
to a more specific board by serial number.
"""

# Zero pad serial numbers to 32 characters to match those
# provided by the USB descriptors
if 'serial_number' in device_identifiers and len(device_identifiers['serial_number']) < 32:
device_identifiers['serial_number'] = device_identifiers['serial_number'].zfill(32)

# Connect to the first available device.
try:
self.device = usb.core.find(**device_identifiers)
Expand Down

0 comments on commit eeb44ab

Please sign in to comment.