Skip to content

Commit ab7c42f

Browse files
committed
ISSUE-214: Raise ValueError if invalid channel mask passed.
1 parent 20eb26a commit ab7c42f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pylink/jlink.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5267,7 +5267,7 @@ def power_trace_configure(self, channels, freq, ref, always):
52675267
52685268
Args:
52695269
self (JLink): the ``JLink`` instance.
5270-
channels (list[int]): list specifying which channels to capture on (0-7).
5270+
channels (list[int]): list specifying which channels to capture on (0 - 7).
52715271
freq (int): sampling frequency (in Hertz).
52725272
ref (JLinkPowerTraceRef): reference value to stored on capture.
52735273
always (bool): ``True`` to capture data even while CPU halted, otherwise ``False``.
@@ -5277,6 +5277,7 @@ def power_trace_configure(self, channels, freq, ref, always):
52775277
52785278
Raises:
52795279
JLinkException: on error
5280+
ValueError: invalid channels specified
52805281
"""
52815282
if isinstance(channels, list):
52825283
channel_mask = 0x00
@@ -5285,6 +5286,9 @@ def power_trace_configure(self, channels, freq, ref, always):
52855286
else:
52865287
channel_mask = channels
52875288

5289+
if channel_mask > 0xFF:
5290+
raise ValueError("Channels must be in range 0 - 7")
5291+
52885292
setup = structs.JLinkPowerTraceSetup()
52895293
setup.ChannelMask = channel_mask
52905294
setup.SampleFreq = int(freq)
@@ -5386,6 +5390,7 @@ def power_trace_get_channel_capabilities(self, channels):
53865390
53875391
Raises:
53885392
JLinkException: on error
5393+
ValueError: invalid channels specified
53895394
"""
53905395
if isinstance(channels, list):
53915396
channel_mask = 0x00
@@ -5394,6 +5399,9 @@ def power_trace_get_channel_capabilities(self, channels):
53945399
else:
53955400
channel_mask = channels
53965401

5402+
if channel_mask > 0xFF:
5403+
raise ValueError("Channels must be in range 0 - 7")
5404+
53975405
channel_caps = structs.JLinkPowerTraceChannelCaps()
53985406
caps = structs.JLinkPowerTraceCaps()
53995407
caps.ChannelMask = channel_mask

0 commit comments

Comments
 (0)