Add modem-config-dump

This script will dump the config of the modem (ublox l2)
to /tmp/config/ublox-tobyl2.conf on boot

BugzID: 56305
This commit is contained in:
Alexandre Bard 2019-03-29 11:38:49 +01:00
parent 56295e2ed0
commit c001bc907f
3 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,51 @@
#!/usr/bin/env python3
import serial
import os
import time
CONF_PATH = '/tmp/config/'
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=0.5)
while True:
try:
ser.read()
break
except Exception:
pass
os.makedirs(CONF_PATH, exist_ok=True)
config_file = open(CONF_PATH + '/ublox-tobyl2.conf', 'w')
def read_config(cmd, label=''):
while True:
try:
ser.flushInput()
ser.write(cmd)
ser.write(b'\r')
s = ser.read_until(b'OK')
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"))
read_config(b'AT+CGMI', 'Manufacturer identification');
read_config(b'AT+GMI', 'Manufacturer identification');
read_config(b'AT+CGMM', 'Model identification');
read_config(b'AT+GMM', 'Model identification');
read_config(b'AT+CGMR', 'Firmware version identification');
read_config(b'AT+GMR', 'Firmware version identification');
config_file.write('-' * 80 + '\n' * 2)
read_config(b'AT+UCGDFLT?', 'Initial EPS bearer / PDP context');
read_config(b'AT+UBMCONF?', 'Boot mode configuration, 1 = router, 2 = bridge')
read_config(b'AT+UUSBCONF?', 'USB profiles configuration')

View File

@ -0,0 +1,12 @@
[Unit]
Before=ModemManager.service
After=ublox-config.service
[Service]
Type=oneshot
ExecStart=/usr/bin/modem-config-dump
[Install]
WantedBy=ModemManager.service

View File

@ -0,0 +1,38 @@
SUMMARY = "Dump of the modem config"
DESCRIPTION = "Dump the config of the modem for debugging purposes"
AUTHOR = "Alexandre Bard"
SECTION = "connectivity"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
PR = "r2"
RDEPENDS_${PN}="python3-pyserial"
inherit systemd
SRC_URI = " \
file://modem-config-dump.service \
file://modem-config-dump.py \
"
S = "${WORKDIR}"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SYSTEMD_SERVICE_${PN} = "modem-config-dump.service"
SYSTEMD_AUTO_ENABLE ?= "enable"
FILES_${PN}_append = " \
/lib \
/usr \
"
do_install () {
install -d ${D}${systemd_unitdir}/system/
install -m 0644 modem-config-dump.service ${D}${systemd_unitdir}/system/
install -d ${D}/usr/bin
install -m 0755 modem-config-dump.py ${D}/usr/bin/modem-config-dump
}