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

[ISSUE-214] Add Support for Power Tracing #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hkpeprah
Copy link
Contributor

@hkpeprah hkpeprah commented Dec 2, 2024

[ISSUE-214] Add Support for Power Tracing

Overview

This PR adds support to PyLink for using the Power Trace API. Example usage:

import time

import pylink
import pylink.enums


if __name__ == "__main__":
    jl = pylink.JLink()
    jl.open()

    try:
        channels = jl.power_trace_get_channels()
        print(f"{channels=}")

        channel_caps = jl.power_trace_get_channel_capabilities(channels)
        print(f"{channel_caps=}")

        freq = jl.power_trace_configure(channels, channel_caps.max_sample_freq / 10, pylink.enums.JLinkPowerTraceRef.TIME, True)
        print(f"{freq=}")

        jl.power_trace_start()
        time.sleep(0.1)

        num_items = jl.power_trace_get_num_items()
        print(f"{num_items=}")

        items = jl.power_trace_read(num_items)
        print(f"{items=}")

        jl.power_trace_flush()
        jl.power_trace_stop()
    finally:
        jl.close()

Summary of Changes

  1. Updated pylink/__main__.py to handle old and new six with with_metaclass.
  2. Added power trace enums.
  3. Added power trace API methods.
  4. Added power trace structures.
  5. Updated unit tests.

This patch adds support to PyLink for using the Power Trace API.
Comment on lines +5281 to +5286
if isinstance(channels, list):
channel_mask = 0x00
for channel in channels:
channel_mask |= (1 << channel)
else:
channel_mask = channels

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test the channel values are in the range of 0-7?

@diggit
Copy link

diggit commented Dec 4, 2024

Hi,
I can confirm it works with my J-Link Base Compact.

My observations (not relevant to pylink):

channels=[0]
channel_caps=JLinkPowerTraceChannelCaps(SampleFreq=1000Hz, MinDiv=1)
  • 1 kHz maximum sample rate
  • 1 mA resolution, but the quantization step seems to be much larger, possibly around 12 mA (observed only values: 5, 17, 43, 56, 69, 82 - not an extensive test)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants