Commit 2fc95665 authored by Yann Garcia's avatar Yann Garcia
Browse files

Reset modem when upper_tester terminates

parent c2f86612
Loading
Loading
Loading
Loading
+10 −2
Changes for upper_tester/__main__.py: 10 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,9 @@
@brief    Command-line entry point: python3.13 -m upper_tester --device /dev/quectel_at --port 12100
@details  Opens the modem, sends `ATE0` once (disable command echo so lines can be told
          apart from responses), and serves the upper-tester TCP protocol (see server.py)
          until interrupted.
          until interrupted (Ctrl-C), at which point the modem is reset (AT+CFUN=1,1)
          before the device is closed, so it isn't left in whatever state the last
          in-flight AT command left it in.
"""
import argparse
import asyncio
@@ -54,7 +56,13 @@ def main() -> None:
    try:
        asyncio.run(run())
    except KeyboardInterrupt:
        pass
        log = logging.getLogger("ut")
        log.info("Ctrl-C received: resetting the modem before exit")
        try:
            ok, text = modem.execute("AT+CFUN=1,1")
            log.info("AT+CFUN=1,1 -> %s %r", ok, text)
        except OSError as e:
            log.error("modem reset on exit failed: %s", e)
    finally:
        modem.close()