modem-config-dump: Move config to /run and improve failure handling
BugzID: 56305
This commit is contained in:
parent
b968842975
commit
66fe76d92f
|
|
@ -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"))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue