this actually works!
All checks were successful
Rust/sat-rs/pipeline/head This commit looks good

This commit is contained in:
2024-05-25 13:46:14 +02:00
parent a6d9bee5df
commit 2eaa78dfbc
5 changed files with 152 additions and 91 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python3
import enum
from socket import AF_INET, SOCK_DGRAM, socket
from pydantic import BaseModel
import msgpack
@ -9,10 +11,26 @@ TEST_PERSON = {
}
class Devices(str, enum.Enum):
MGT = "Mgt"
MGM = "Mgm"
class SwitchState(str, enum.Enum):
OFF = "Off"
ON = "On"
UNKNOWN = "Unknown"
FAULTY = "Faulty"
class SwitchMap(BaseModel):
valid: bool
switch_map: dict[Devices, SwitchState]
def msg_pack_unloading(recv_back: bytes):
unpacked = msgpack.unpackb(recv_back)
print(f"unpacked: {unpacked}")
# human_test = {:x for x in unpacked}
loaded_back = msgpack.loads(recv_back)
print(loaded_back)
@ -25,7 +43,8 @@ def main():
_ = server_socket.sendto(msg_pack_stuff, target_address)
recv_back = server_socket.recv(4096)
print(f"recv back: {recv_back}")
pass
switch_map = SwitchMap.model_validate_json(recv_back)
print(f"switch map: {switch_map}")
if __name__ == "__main__":

View File

@ -1 +1,2 @@
msgpack==1.0.8
pydantic==2.7