Skip to content

Commit 730b162

Browse files
committed
DebugProbe: aggregator first checks for full unique ID match.
- Also updated and clarified docs for DebugProbe methods get_all_connected_probes() and get_probe_with_id().
1 parent dcc416c commit 730b162

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

pyocd/probe/aggregator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def get_all_connected_probes(unique_id=None):
5151
klasses, unique_id, is_explicit = DebugProbeAggregator._get_probe_classes(unique_id)
5252

5353
probes = []
54+
55+
# First look for a match against the full ID, as this can be more efficient for certain probes.
56+
if unique_id is not None:
57+
for cls in klasses:
58+
probe = cls.get_probe_with_id(unique_id, is_explicit)
59+
if probe is not None:
60+
return [probe]
61+
62+
# No full match, so ask probe classes for probes.
5463
for cls in klasses:
5564
probes += cls.get_all_connected_probes(unique_id, is_explicit)
5665

pyocd/probe/debug_probe.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ class Capability(Enum):
6363
def get_all_connected_probes(cls, unique_id=None, is_explicit=False):
6464
"""! @brief Returns a list of DebugProbe instances.
6565
66+
To filter the list of returned probes, the `unique_id` parameter may be set to a string with a full or
67+
partial unique ID (canonically the serial number). Alternatively, the probe class may simply return all
68+
available probes and let the caller handle filtering.
69+
6670
@param cls The class instance.
67-
@param unique_id Optional unique ID value on which probes are being filtered. May be
68-
used by the probe to optimize retreiving the probe list.
69-
@param is_explicit Whether the probe type was explicitly specified in the unique ID. This
71+
@param unique_id String. Optional partial unique ID value used to filter available probes. May be used by the
72+
probe to optimize retreiving the probe list; there is no requirement to filter the results.
73+
@param is_explicit Boolean. Whether the probe type was explicitly specified in the unique ID. This
7074
can be used, for instance, to specially interpret the unique ID as an IP address or
7175
domain name when the probe class was specifically requested but not for general lists
7276
of available probes.
@@ -78,12 +82,11 @@ def get_all_connected_probes(cls, unique_id=None, is_explicit=False):
7882
def get_probe_with_id(cls, unique_id, is_explicit=False):
7983
"""! @brief Returns a DebugProbe instance for a probe with the given unique ID.
8084
81-
If no probe is connected with a matching unique ID, then None will be returned.
85+
If no probe is connected with a fully matching unique ID, then None will be returned.
8286
8387
@param cls The class instance.
84-
@param unique_id Optional unique ID value on which probes are being filtered. May be
85-
used by the probe to optimize retreiving the probe list.
86-
@param is_explicit Whether the probe type was explicitly specified in the unique ID.
88+
@param unique_id Unique ID string to match against probes' full unique ID. No partial matches are allowed.
89+
@param is_explicit Boolean. Whether the probe type was explicitly specified in the unique ID.
8790
@return DebugProbe instance, or None
8891
"""
8992
raise NotImplementedError()

0 commit comments

Comments
 (0)