Registry / devops / ppk2-api

ppk2-api

JSON →
library0.9.2pypypi✓ verified 85d ago

The ppk2-api is a Python library providing an API for Nordic Semiconductor's Power Profiler Kit II (PPK 2). It enables programmatic control and data acquisition from the PPK 2 device, facilitating power consumption measurements and analysis for embedded development. The current version is 0.9.2, with active development and frequent releases (e.g., v0.9.0, v0.9.1, v0.9.2 in quick succession, aiming for v1.0.0).

pip install ppk2-api
INSTALL
IMPORT
SIG · PPK2-API
P
ppk2-api
devopspythonv0.9.2
Install
1.6s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PPK2_API
from power_profiler import PPK2_API
from ppk2_api import PPK2
PowerProfiler
from power_profiler import PowerProfiler
from ppk2_api import PPK2
ppk2_api
import ppk2_api
from ppk2_api import PPK2

This quickstart demonstrates how to discover a PPK2 device, set it to ampere meter mode, start a measurement, wait for a period, and then stop it. It also shows how to retrieve some sample data. Note that actual data streaming involves more continuous polling with `ppk2.get_data()` in a loop.

from ppk2_api import PPK2, PPK2_Port, PPK2_Mode def main(): try: # Discover and connect to the PPK2 device ppk2 = PPK2.discover() print(f"Connected to PPK2: {ppk2.get_device_id()}") # Set mode to ampere meter and connect to channel 0 ppk2.set_mode(PPK2_Mode.AMPERE_METER) ppk2.connect_to_port(PPK2_Port.PORT_0) ppk2.start_measurement() print("Measuring for 5 seconds...") # In a real application, you'd typically stream data # For simplicity, we'll just wait and then stop. # Data streaming would involve a loop and calling ppk2.get_data() import time time.sleep(5) ppk2.stop_measurement() print("Measurement stopped.") # Example of getting some data (note: real streaming is more complex) data = ppk2.get_data(num_samples=1000) if data: print(f"Average current: {sum(data['current'])/len(data['current']):.2f} mA") print(f"Average voltage: {sum(data['voltage'])/len(data['voltage']):.2f} V") else: print("No data collected or available in this simple example.") except Exception as e: print(f"An error occurred: {e}") finally: # Ensure the device is properly closed if 'ppk2' in locals() and ppk2.is_connected(): ppk2.close() print("PPK2 connection closed.") if __name__ == "__main__": main()
Debug
Known issues
breakingThe internal concurrency mechanism was changed from `multiprocessing` to `threading` in version 0.9.1. Applications relying on specific process isolation or resource handling behaviors introduced by multiprocessing should review their implementation.
fix
Review concurrent code that interacts with ppk2-api. Adapt to threading model for internal operations. Consider explicit process management if isolation is critical for your application logic.
affects: >=0.9.1
gotchaPrior to version 0.9.0, current measurements could be incorrect due to 'incorrect spike filtering'. Data collected with older versions may be unreliable.
fix
Always use version 0.9.0 or newer for accurate current measurements. Re-run experiments if data was collected using affected versions.
affects: <0.9.0
gotchaThe `PPK2.discover()` method may raise a `NoPPK2FoundException` if no device is connected or detectable. Ensure the PPK2 device is properly connected and recognized by the operating system.
fix
Wrap `PPK2.discover()` in a `try...except NoPPK2FoundException` block. Verify the PPK2 is powered on and connected. Check USB drivers and permissions. Ensure no other application is using the device.
affects: All versions
Upgrade
Version history
0.9.2latest on PyPI · released Jun 9, 2023
Audit
Dependencies
pyserialrequiredProvides serial communication with the PPK2 device. The library uses pySerial internally.
Agent activity
8 hits · last 30 days
node
8
Resources
ppk2-api — pip install ppk2-api · libregistry