Power management USB Hubs can be used to mitigate the overcharged mobile device batteries (e.g. mobile automation),
in order to automate this process a python based serial interface wrapper was introduced
on top of the serial command line of the Cambrionix Power Management USB Hubs in order to:
- Expose the serial command line interface as an API using an XML-RPC server.
- Use an XML-RPC client to access those methods remotely.
- Automate the USB Hub port state (e.g. Ansible, Jenkins), schedule when your mobile devices will
wakeup
to charge.
Cambrionix Power Management USB serial interface wrapper.
Supports the following Universal Series:
- PPxx
- Uxx
- ThunderSync
- Install the Cambrionix Power Management USB Hub on the host machine.
- Install Python tox on the host machine.
- Move inside the project root folder and start the interactive interpreter:
tox -e ipython
In [1]: from cambrionix import Cambrionix
In [2]: # Set port 1 to SYNC (activate) state
In [3]: with Cambrionix('DO02DM7Y') as c:
c.set_mode('S', 1)
c.show_state(1)
- Start and register all the power hub methods through the
cbrxxmlrpc
server:
python -m cambrionix.tools.cbrxxmlrpc --serial-port DO02DM7Y \
--rpc-host 127.0.0.1 \
--rpc-port 8999
- Use an XML-RPC client to access those methods remotely.
- Automate the power hub port state using the
port_handler
script (e.g cronjob):
python -m cambrionix.tools.port_handler --help
Requires an .ini
configuration file, check the configuration file format in: tools/cambrionix.ini
.
- Unit testing is supported only for
Python2.x
due to serial_mock - Source code is being written to support
Python2.x
andPython3.x
(without any guarantee).