A base class for creating binary parsing and packing classes
Project description
Dataclass for go to and from binary data
It follows dataclass pattern with typehinting as the binary format. Temperature with one unsigned byte:
class Temperature(BinmapDataclass):
temp: unsignedchar = 0
t = Temperature()
t.temp = 22
print(bytes(t))
b'\x16'
t2 = Temperature(b'\x20')
print(t2.temp)
32
Temperature and humidity consisting of one signed byte for temperature and one unsiged byte for humidity:
class TempHum(BinmapDataclass):
temp: signedchar = 0
hum: unsignedchar = 0
th = TempHum()
th.temp = -10
th.humidity = 60
print(bytes(th))
b'\xfc<'
th2 = TempHum(b'\xea\x41')
print(th2.temp)
-22
print(th2.hum)
65
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for binmap-1.0.1.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27aa35af4f6ec993bdfac3bdfe1ef8ccc87d0b853afb8f051df49baa2ec19a5a |
|
MD5 | e935fccb0ba6c43cfe0951e9603ce204 |
|
BLAKE2b-256 | 30d40d27dcf5c1771dcffc67170df175604c96a63b05082bcafbe66ae90b14c3 |