Hanmatek HM3xxP PSU control library and CLI
Unifying library and CLI for the popular and low-cost digital lab power supplies HM305P and
HM310P.
The library provides an (almost) complete, easy to use interface to all known functions of the device. This project is different to the below mentioned ones, in that it provides a minimal, but complete interface to the device and also keeps the dependencies low.
This project is based on the work done in https://github.com/notkevinjohn/HM310P, which uses the
minimalmodbus library for device communication. Other related projects were providing
useful register definition and hints:
- https://github.com/JackDoan/hm305_ctrl/tree/master/hm305
- https://github.com/hobbyquaker/hanmatek-hm310p
- https://sigrok.org/wiki/ETommens_eTM-xxxxP_Series#Protocol
Installation
pip install hanmatek-psu
If users are in the plugdev user group, Hanmatek devices are accessible via /dev/ttyUSBx without
privileges. Adding the following udev rule will create a symlink /dev/ttyHM3xxP when a Hanmatek
PSU device is plugged in via USB. This symlink is used by default by the hanmatek-cli to find
devices:
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="ttyHM3xxP", MODE="0666", GROUP="plugdev"' | sudo tee "/etc/udev/rules.d/99-hanmatek.rules" > /dev/null
Usage
CLI Usage
hanmatek-cli -h
hanmatek-cli --discover # find devices
hanmatek-cli # show default device info
hanmatek-cli --device /dev/ttyUSB0 # specific device
hanmatek-cli voltage:set 3.0 # set voltage
hanmatek-cli current:set 0.1 # set current limit
hanmatek-cli output on
hanmatek-cli current # read current
hanmatek-cli power # read power
hanmatek-cli output off
hanmatek-cli --list # list all commands/registers
Library Usage
from hanmatek import HM3xxP
device = HM3xxP("/dev/ttyHM3xxP")
print(device.info())
device.write("voltage:set", 3.0)
device.write("current:set", 3.0)
device.write("output", True)
print(device.read("current"))
print(device.read("power"))
device.write("output", False)
Development
The following tools are used to provide clean and quality software, and made available through a
tox configuration: flake8 for linting, black for code formatting and checking, mypy for
type checking and pytest for unit tests. Use as:
pip install tox
tox -a # show test environments
tox # run all
tox -e test # run unit tests
tox -e lint # run lint
tox -e type # run type checker
(we're using pyproject-flake8, so that the flake8
configuration can live in pyproject.toml - within tox we then run pflake8 instead of
flake8.)
Metadata
Release files for hanmatek-psu 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hanmatek_psu-1.1.2.tar.gz | 7.2 kB | Without provenance | Details for hanmatek_psu-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hanmatek_psu-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for hanmatek_psu-1.1.2-py3-none-any.whl |
Total release size: 15.8 kB
Release files / hanmatek_psu-1.1.2.tar.gz
| Download URL | hanmatek_psu-1.1.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6344bcfc6a4f420ae926cff026471d302c44680fc73043be4f3671babf6fcd67
|
|
BLAKE2b-256 checksum How to use checksums |
19e18879e9a701f15daea2d27960ab84fba6060d3794273069e04c4462b459b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.4.109+
|
Release files / hanmatek_psu-1.1.2-py3-none-any.whl
| Download URL | hanmatek_psu-1.1.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e5f2a4403d25a2c30cd3ea1d10339b6ef796d70a022c37f8556db757ed6152f
|
|
BLAKE2b-256 checksum How to use checksums |
40d0e1132071b01cdf2d965f55034c4af900458a79bbd80a02990ec1d1538408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.4.109+
|
Security for hanmatek-psu 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.