Skip to content

Commit e993ffa

Browse files
authored
Merge pull request #1128 from newbrain/NoBackendFixPP
Fix for missing usb backend in picoprobe
2 parents 9a6bab0 + 1b062eb commit e993ffa

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pyocd/probe/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ def show_no_libusb_warning():
3333
"""! @brief Logs a warning about missing libusb library only the first time it is called."""
3434
global did_show_no_libusb_warning
3535
if not did_show_no_libusb_warning:
36-
LOG.warning("STLink and CMSIS-DAPv2 probes are not supported because no libusb library was found.")
36+
LOG.warning("STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found.")
3737
did_show_no_libusb_warning = True
38-
38+
3939
def should_show_libusb_device_error(vidpid):
4040
"""! @brief Returns whether a debug warning should be shown for the given VID/PID pair.
41-
41+
4242
The first time a given VID/PID is passed to this function, the result will be True. Any
4343
subsequent times, False will be returned for the same VID/PID pair.
44-
44+
4545
@param vidpi A bi-tuple of USB VID and PID, in that order.
4646
"""
4747
should_log = vidpid not in libusb_error_device_set

pyocd/probe/picoprobe.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from typing import List
2727

2828
from .debug_probe import DebugProbe
29+
from .common import show_no_libusb_warning
2930
from ..core import exceptions
3031
from ..core.options import OptionInfo
3132
from ..core.plugin import Plugin
@@ -104,8 +105,12 @@ def close(self):
104105
@classmethod
105106
def enumerate_picoprobes(cls, uid=None) -> List["PicoLink"]:
106107
"""! @brief Find and return all Picoprobes """
107-
# Use a custom matcher to make sure the probe is a Picoprobe and accessible.
108-
return [PicoLink(probe) for probe in core.find(find_all=True, custom_match=FindPicoprobe(uid))]
108+
try:
109+
# Use a custom matcher to make sure the probe is a Picoprobe and accessible.
110+
return [PicoLink(probe) for probe in core.find(find_all=True, custom_match=FindPicoprobe(uid))]
111+
except core.NoBackendError:
112+
show_no_libusb_warning()
113+
return []
109114

110115
def q_read_bits(self, bits):
111116
"""! @brief Queue a read request for 'bits' bits to the probe """

0 commit comments

Comments
 (0)