Skip to content
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

Add support for integer serial number in device URL #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyftdi/ftdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ def __init__(self):
def create_from_url(cls, url: str) -> 'Ftdi':
"""Create an Ftdi instance from an URL

URL scheme: ftdi://[vendor[:product[:index|:serial]]]/interface
URL scheme: ftdi://[vendor[:product[:index]]]/interface
URL scheme: ftdi://[vendor[:product[::serial]]]/interface
URL scheme: ftdi://[vendor[:product[:bus:address]]]/interface

:param url: FTDI device selector
:return: a fresh, open Ftdi instance
Expand Down
4 changes: 3 additions & 1 deletion pyftdi/usbtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def enumerate_candidates(cls, urlparts: SplitResult,
bus = None
address = None
locators = specifiers[2:]
if len(locators) > 1:
if len(locators) > 1 and locators[0]:
try:
bus = int(locators[0], 16)
address = int(locators[1], 16)
Expand All @@ -427,6 +427,8 @@ def enumerate_candidates(cls, urlparts: SplitResult,
idx = devidx-1
except ValueError:
sernum = locators[0]
if locators and len(locators) > 1:
sernum = locators[1]
candidates = []
vendors = [vendor] if vendor else set(vdict.values())
vps = set()
Expand Down