harp-protocol
The Harp Protocol is a binary communication protocol created to facilitate and unify the interaction between different devices. It was designed with efficiency and ease of parsing in mind.
For more detail please check the official Harp Tech documentation.
harp-protocol provides the building blocks: message framing and the typed register/payload DSL. Each register builds its frames with format and decodes them with parse.
import numpy as np
from harp.protocol import HarpMessage, RegisterU16
class WhoAmI(RegisterU16):
address = 0
frame = WhoAmI.format(np.uint16(1216)) # build a Write frame
value = WhoAmI.parse(HarpMessage.parse(frame)) # -> np.uint16(1216)
Register value types
parse returns numpy scalars rather than plain int or float, so a value carries the width its register declares. A Python int has no width and no upper bound, so it cannot distinguish a U8 from a U32, nor detect a value leaving the register range.
np.uint16(65535) + 1 # RuntimeWarning: overflow encountered in scalar add
65535 + 1 # 65536, wider than the register can hold
Numpy scalars behave like plain Python numbers in arithmetic, comparison, and formatting. Use int() or float() where a built-in type is required.
Read an address no schema describes
A register class is normally declared with its address, as above, or generated from a device.yml. Calling a register base with an address instead builds a one-off register for that address, which is how a payload outside any schema is read and written:
from harp.protocol import RegisterU8Array, RegisterU16
uid = RegisterU8Array(0x10, length=16) # R_UID, named by no schema
tag = RegisterU8Array(0x11, length=16) # R_TAG, the firmware git hash
version = RegisterU16(0x08) # any address, as a scalar
The result is an ordinary register, so it goes through read and write on a device exactly as a declared one does. length is keyword-only for the array form, and it is the element count rather than a byte count. An already-addressed register rejects the call, so WhoAmI(44) raises rather than quietly producing a register at another address.
It carries no transport or device logic. See harp-device for the device layer.
harp-protocol is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Metadata
Release files for harp-protocol 0.5.0
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 | |
|---|---|---|---|---|
| harp_protocol-0.5.0.tar.gz | 29.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harp_protocol-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.5 kB
Release files / harp_protocol-0.5.0.tar.gz
| Download URL | harp_protocol-0.5.0.tar.gz |
|---|---|
| Size | 29.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1109c82e4766ae579cec150da125540343dac9c33e8ac171b69f22b3485b1b75
|
|
BLAKE2b-256 checksum How to use checksums |
6d7d48e9ba2d0b8182966a1cc8bba573201ef5256c57b2a172c32e071f34a087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / harp_protocol-0.5.0-py3-none-any.whl
| Download URL | harp_protocol-0.5.0-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f06d3c69e31c5a5ac5d530006ad003ebf5e552de5eed521a83fb85526d68a152
|
|
BLAKE2b-256 checksum How to use checksums |
0e309c92a60a89fbc0360a456201931cfa8002e15c6cbb4a6b252e478eb3f834
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for harp-protocol 0.5.0
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.