Skip to content

Commit

Permalink
Merge pull request #1117 from flit/bugfix/picoprobe_uid
Browse files Browse the repository at this point in the history
Picoprobe: fix for uid being specified with no available Picoprobes.
  • Loading branch information
flit authored Mar 10, 2021
2 parents b033744 + 5548e26 commit f940a93
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pyocd/probe/picoprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import platform
import errno
import logging
from typing import List

from .debug_probe import DebugProbe
from ..core import exceptions
Expand Down Expand Up @@ -101,13 +102,10 @@ def close(self):
self._rd_ep = None

@classmethod
def enumerate_picoprobes(cls, uid=None):
def enumerate_picoprobes(cls, uid=None) -> List["PicoLink"]:
"""! @brief Find and return all Picoprobes """
# Use a custom matcher to make sure the probe is a Picoprobe and accessible.
if uid is None:
return [PicoLink(probe) for probe in core.find(find_all=True, custom_match=FindPicoprobe(uid))]
else:
return PicoLink(core.find(custom_match=FindPicoprobe(uid)))
return [PicoLink(probe) for probe in core.find(find_all=True, custom_match=FindPicoprobe(uid))]

def q_read_bits(self, bits):
"""! @brief Queue a read request for 'bits' bits to the probe """
Expand Down Expand Up @@ -336,9 +334,9 @@ def get_all_connected_probes(cls, unique_id=None, is_explicit=False):

@ classmethod
def get_probe_with_id(cls, unique_id, is_explicit=False):
probe = PicoLink.enumerate_picoprobes(unique_id)
if probe is not None:
return cls(probe)
probes = PicoLink.enumerate_picoprobes(unique_id)
if probes:
return cls(probes[0])

def __init__(self, picolink):
super(Picoprobe, self).__init__()
Expand Down

0 comments on commit f940a93

Please sign in to comment.