modem-config-dump: Move config to /run and improve failure handling

BugzID: 56305
This commit is contained in:
Alexandre Bard 2019-04-01 12:22:03 +02:00
parent b968842975
commit 66fe76d92f
1 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import serial
import os import os
import time import time
CONF_PATH = '/tmp/config/' CONF_PATH = '/run/modem'
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=0.5) ser = serial.Serial('/dev/ttyACM0', 115200, timeout=0.5)
while True: while True:
try: try:
@ -15,7 +15,7 @@ while True:
os.makedirs(CONF_PATH, exist_ok=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=''): def read_config(cmd, label=''):
while True: while True:
@ -24,14 +24,14 @@ def read_config(cmd, label=''):
ser.write(cmd) ser.write(cmd)
ser.write(b'\r') ser.write(b'\r')
s = ser.read_until(b'OK') s = ser.read_until(b'OK')
if(len(s.decode('utf-8')) < 4): # Avoid empty response just after reset
continue
break break
except Exception as e: except Exception as e:
print("Exception : " + str(e)) print("Exception : " + str(e))
time.sleep(1) time.sleep(1)
continue continue
#if(len(s.decode('utf-8') < 1)):
config_file.write(label + '\n') config_file.write(label + '\n')
config_file.write(s.decode('utf-8').strip("OK")) config_file.write(s.decode('utf-8').strip("OK"))