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 68af9813d6
commit 011fc23c21
1 changed files with 4 additions and 4 deletions

View File

@ -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"))