1
0

switch to struct for reading

This commit is contained in:
2026-02-21 14:53:29 +01:00
parent 426cfad689
commit 21bd3700bc
2 changed files with 71 additions and 142 deletions

11
xrd.py
View File

@@ -108,7 +108,7 @@ def process_command(tef: TEF6686, data: bytes, state: dict, conn: socket.socket)
for freq in range(state["scan_start"], state["scan_stop"] + state["scan_step"], state["scan_step"]):
tef.FM_Tune_To(2, freq) # Auto mutes, less commands sent
time.sleep(0.0064)
_, level, *_ = tef.FM_Get_Quality_Data()
_, level, *_ = d if (d := tef.FM_Get_Quality_Data()) else (None, None)
if level is None: continue
conn.sendall(str(freq * 10).encode() + b" = " + str(level // 10).encode() + b", ")
conn.sendall(b"\n")
@@ -121,8 +121,9 @@ def process_command(tef: TEF6686, data: bytes, state: dict, conn: socket.socket)
def send_signal_status(tef: TEF6686, conn: socket.socket, state: dict):
_, _, stereo, _ = d if (d := tef.FM_Get_Processing_Status()) else (None, None, 1000, None)
status, level, usn, wam, _, bandwidth, _ = tef.FM_Get_Quality_Data()
if status is None or level is None or wam is None or usn is None or bandwidth is None: return
res = tef.FM_Get_Quality_Data()
if res is None: return
_, level, usn, wam, _, bandwidth, *_ = res
level = level / 10
@@ -135,7 +136,9 @@ def send_signal_status(tef: TEF6686, conn: socket.socket, state: dict):
conn.sendall(data)
def send_rds_data(tef: TEF6686, conn: socket.socket):
status, A, B, C, D, dec_error = tef.FM_Get_RDS_Data__decoder()
res = tef.FM_Get_RDS_Data__decoder()
if res is None: return
status, A, B, C, D, dec_error = res
if status is None or A is None or B is None or C is None or D is None or dec_error is None: return # Fucking hate pyright
if (status & (1 << 9) == 0) or (status & (1 << 15) == 0): return