Python library for working with the PD Buddy Sink Serial Console Configuration Interface
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Clara Hobbs 9e59a07d20 Update PID to match firmware 7 anos atrás
pdbuddy Update PID to match firmware 7 anos atrás
test_pdbuddy Test the Sink class 7 anos atrás
.gitignore Initial commit 7 anos atrás
LICENSE Added a simple PD Buddy Sink configuration library 7 anos atrás
README.rst Mention how to check that identify is working 7 anos atrás
setup.py Testing info in README, wider Python compatibility 7 anos atrás

README.rst

pd-buddy-python
===============

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

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, flags=SinkFlags.NONE, v=5000, i=3000)
>>> print(pdbs.get_cfg())
status: valid
flags: (none)
v: 5.00 V
i: 3.00 A

Locally manipulate a SinkConfig object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

>>> cfg = pdbs.get_cfg()
>>> cfg.v = 20000
>>> cfg.i = 2250
>>> cfg.flags |= pdbuddy.SinkFlags.GIVEBACK
>>> cfg
SinkConfig(status=SinkStatus.VALID, flags=SinkFlags.GIVEBACK, v=20000, i=2250)

Write the SinkConfig object to flash
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

>>> pdbs.set_tmpcfg(cfg)
>>> pdbs.write()
>>> pdbs.get_cfg()
SinkConfig(status=SinkStatus.VALID, flags=SinkFlags.GIVEBACK, v=20000, i=2250)

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.