From 66fe76d92f728985b31e8584275711010e30d27a Mon Sep 17 00:00:00 2001 From: Alexandre Bard Date: Mon, 1 Apr 2019 12:22:03 +0200 Subject: [PATCH] modem-config-dump: Move config to /run and improve failure handling BugzID: 56305 --- .../modem-config-dump/files/modem-config-dump.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes-connectivity/modem-config-dump/files/modem-config-dump.py b/recipes-connectivity/modem-config-dump/files/modem-config-dump.py index b7ead86..4b8f42a 100755 --- a/recipes-connectivity/modem-config-dump/files/modem-config-dump.py +++ b/recipes-connectivity/modem-config-dump/files/modem-config-dump.py @@ -4,7 +4,7 @@ import serial import os import time -CONF_PATH = '/tmp/config/' +CONF_PATH = '/run/modem' ser = serial.Serial('/dev/ttyACM0', 115200, timeout=0.5) while True: try: @@ -15,7 +15,7 @@ while True: os.makedirs(CONF_PATH, exist_ok=True) -config_file = open(CONF_PATH + '/ublox-tobyl2.conf', 'w') +config_file = open(CONF_PATH + '/modem-at.config', 'w') def read_config(cmd, label=''): while True: @@ -24,14 +24,14 @@ def read_config(cmd, label=''): ser.write(cmd) ser.write(b'\r') s = ser.read_until(b'OK') + if(len(s.decode('utf-8')) < 4): # Avoid empty response just after reset + continue break except Exception as e: print("Exception : " + str(e)) time.sleep(1) continue - #if(len(s.decode('utf-8') < 1)): - config_file.write(label + '\n') config_file.write(s.decode('utf-8').strip("OK"))