#!/usr/bin/env python3 """SMS step 2: run the assembler from the main loop and initialise it at startup.""" W = "/home/viktor/ogd77rel/uv_src/OpenGD77_MDUV380_DM1701_20260130/MDUV380_firmware/application" p = W + "/source/applicationMain.c" s = open(p).read() if "smsTick" in s: print("already wired into the main loop") raise SystemExit(0) # include anchor = None for cand in ['#include "functions/voicePrompts.h"\n', '#include "functions/settings.h"\n', '#include "functions/ticks.h"\n']: if cand in s: anchor = cand break assert anchor, "no suitable include anchor in applicationMain.c" s = s.replace(anchor, anchor + '#include "functions/sms.h"\n', 1) # drain the received bursts once per main loop pass, next to the other periodic work a = "\t\tvoxTick();\n" assert a in s, "voxTick anchor missing" s = s.replace(a, a + "\t\tsmsTick();// turn received data bursts into messages\n", 1) # initialise alongside the other subsystems init_anchor = None for cand in ["\tbatteryUpdate();\n", "\tvoxInit();\n"]: if cand in s: init_anchor = cand break assert init_anchor, "no init anchor found" s = s.replace(init_anchor, init_anchor + "\tsmsInit();\n", 1) open(p, "w").write(s) print("applicationMain.c: smsInit() + smsTick() wired in")