Python library for working with the PD Buddy Sink Serial Console Configuration Interface
Features
Provides a Pythonic interface to the PD Buddy Sink shell commands
Configuration is represented as a SinkConfig object
SinkConfig objects can be manipulated locally and written to the device with one method call
Allows control of whether or not the output is enabled
Provides a Pythonic interface for reading advertised PDOs
Provides functions for testing if the power supply follows the Power Rules
Includes a script for testing if a PD Buddy Sink is correctly functioning
Examples
Open the first PD Buddy Sink device and read its configuration
>>> import pdbuddy >>> pdbs = pdbuddy.Sink(list(pdbuddy.Sink.get_devices())[0]) >>> pdbs.get_cfg() SinkConfig(status=<SinkStatus.VALID: 2>, flags=<SinkFlags.NONE: 0>, v=5000, vmin=None, vmax=None, i=3000, idim=<SinkDimension.CURRENT: 1>) >>> print(pdbs.get_cfg()) status: valid flags: (none) v: 5.000 V i: 3.00 A
Locally manipulate a SinkConfig object
>>> cfg = pdbs.get_cfg() >>> cfg = cfg._replace(v=20000, i=2250) >>> cfg = cfg._replace(flags=cfg.flags | pdbuddy.SinkFlags.GIVEBACK) >>> cfg SinkConfig(status=<SinkStatus.VALID: 2>, flags=<SinkFlags.GIVEBACK: 1>, v=20000, vmin=None, vmax=None, i=2250, idim=<SinkDimension.CURRENT: 1>)
Write the SinkConfig object to flash
>>> pdbs.set_tmpcfg(cfg) >>> pdbs.write() >>> pdbs.get_cfg() SinkConfig(status=<SinkStatus.VALID: 2>, flags=<SinkFlags.GIVEBACK: 1>, v=20000, vmin=None, vmax=None, i=2250, idim=<SinkDimension.CURRENT: 1>)
Requirements
Python 2.7, >= 3.3
pySerial >= 3.0
aenum >= 2.0 (if using Python < 3.6)
Testing
To run the unit tests, run:
$ python setup.py test
This will test the Sink class only if a PD Buddy Sink is plugged in and in setup mode, so make sure that’s the case if you’re testing any changes to the Sink class. Also, make sure the Status LED is blinking quickly when the tests are run, since that’s the only real way to test the identify command. Be aware that the Sink’s configuration will get clobbered by the tests.
Metadata
Release files for pd-buddy-python 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pd-buddy-python-0.5.1.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pd_buddy_python-0.5.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 23.9 kB
Release files / pd-buddy-python-0.5.1.tar.gz
| Download URL | pd-buddy-python-0.5.1.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63841d2518ae9cd4836137461a3e31fd0de07606a92ab65dc7ef549bcc2f6871
|
|
BLAKE2b-256 checksum How to use checksums |
a138c1faee95d5fda6e56449a804ae75b74cbc4a95570a401fb3900152ac4a61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pd_buddy_python-0.5.1-py2.py3-none-any.whl
| Download URL | pd_buddy_python-0.5.1-py2.py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
82b49409a16ae449a96c6af89a88c4076a30ef24031d3e59280f2a3b0995938c
|
|
BLAKE2b-256 checksum How to use checksums |
901abdb928aa6b42362927835b8a77306f6787aed48fe7bb209af3fce5714e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |