diff --git a/calibrate.py b/calibrate.py new file mode 100644 index 0000000..a95b02c --- /dev/null +++ b/calibrate.py @@ -0,0 +1,17 @@ +from driver import protocol, tef +import os, time + +DEVICE = os.getenv("DEV") or "COM6" +CLOCK_ENV = os.getenv("CLK", "").strip().lower() or "dp" +if CLOCK_ENV == "dp": CLOCK = 12000000 # DP-666 +elif CLOCK_ENV == "x": CLOCK = 9216000 +else: CLOCK = int(CLOCK_ENV) + +p = protocol.I2CPCClient(DEVICE) + +with tef.TEF6686(p) as tf: + tf.init(clock=CLOCK) + tf.AUDIO_Set_WaveGen(5, 0, 0, 400) + tf.AUDIO_Set_Input(240) + tf.AUDIO_Set_Mute(False) + while True: time.sleep(0.1) \ No newline at end of file diff --git a/xrd.py b/xrd.py index e7b26c5..012919a 100644 --- a/xrd.py +++ b/xrd.py @@ -25,10 +25,14 @@ DEVICE = os.getenv("DEV") or "COM6" FREQ_NOT_ALLOWED_RANGE = [] PASSWORD = os.getenv("PW") or "test" -CLOCK = 12000000 # DP-666 + +CLOCK_ENV = os.getenv("CLK", "").strip().lower() or "dp" +if CLOCK_ENV == "dp": CLOCK = 12000000 # DP-666 +elif CLOCK_ENV == "x": CLOCK = 9216000 +else: CLOCK = int(CLOCK_ENV) SALT_LENGTH = 16 -SS_UPDATE_INTERVAL = 0.115 +SS_UPDATE_INTERVAL = 0.095 RDS_UPDATE_INTERVAL = 0.086 def freq_allowed(freq: int): @@ -59,7 +63,7 @@ def authenticate(conn: socket.socket): while True: try: - data = conn.recv(1024) + data = conn.recv(len(expected_hash)) if not data: return False if data.strip() == expected_hash.strip(): return True except BlockingIOError: @@ -280,4 +284,6 @@ def run_server(): run_periodic(tef, conn, state) time.sleep(0.025) -if __name__ == "__main__": run_server() \ No newline at end of file +if __name__ == "__main__": + try: run_server() + except Exception: pass \ No newline at end of file