Commit 3bf21f07 authored by Petr Černohouz's avatar Petr Černohouz
Browse files

Proof-of-concept

parent 20dbbff5
Pipeline #41988 failed with stages
in 52 seconds
Time,Lat,Long,RSRP,SINR Rx[0],RSRQ,RSSI,IP Thrpt DL,MCC,MNC,LAC,Cell Id,PCI,DL EARFCN,Bandwidth,QPSK Rate,16-QAM Rate,64-QAM Rate,256-QAM Rate,Carrier Aggregation DL
04.10.2018 00:06:35,,,-86,16.8,-10.5,-67,24253,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:36,,,-86,17.2,-9.8,-67,23439,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:37,,,-86,17.2,-10.2,-56,23295,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:38,,,-87,18.0,-10.0,-68,23162,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:39,,,-87,18.2,-10.0,-57,22963,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:40,,,-87,18.8,-10.3,-59,22963,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:41,,,-87,17.6,-9.9,-57,23472,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:42,,,-87,18.0,-9.6,-68,23761,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:43,,,-87,18.4,-9.7,-68,23118,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:44,,,-87,18.4,-10.6,-59,23561,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:45,,,-87,18.6,-9.6,-57,23749,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:46,,,-87,18.4,-9.7,-60,22797,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:47,,,-87,17.6,-10.0,-57,23727,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:48,,,-86,17.6,-9.1,-56,23151,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:49,,,-86,18.2,-10.1,-66,22919,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:50,,,-86,18.0,-9.7,-57,23539,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:51,,,-87,17.6,-9.8,-56,23361,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:52,,,-87,19.0,-9.9,-67,23450,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:53,,,-87,18.6,-10.2,-62,22808,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:54,,,-87,18.4,-9.6,-56,23472,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:55,,,-86,16.8,-9.9,-59,23372,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:56,,,-86,17.6,-9.3,-68,19940,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:57,,,-86,17.6,-9.7,-66,19198,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:58,,,-87,18.2,-10.3,-56,22830,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:06:59,,,-86,17.0,-9.6,-56,22919,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:07:00,,,-86,17.8,-10.1,-68,23162,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:07:01,,,-86,18.0,-10.6,-68,23428,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:07:02,,,-86,18.0,-10.2,-57,23273,230,01,8250,207626508,393,0,10,,,,
04.10.2018 00:07:03,,,-86,17.0,-9.5,-56,23350,230,01,8250,207626508,393,0,10,,,,
#!/bin/bash
DOWNLOAD_SOURCE=http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04.1-server-arm64.template
IFACE=wwan0
wget -O /dev/null -o /dev/null $DOWNLOAD_SOURCE &
PID=$!
trap "kill $PID 2> /dev/null" EXIT
echo "Time,Lat,Long,RSRP,SINR Rx[0],RSRQ,RSSI,IP Thrpt DL,MCC,MNC,LAC,Cell Id,PCI,DL EARFCN,Bandwidth,QPSK Rate,16-QAM Rate,64-QAM Rate,256-QAM Rate,Carrier Aggregation DL"
OLD_COUNT=$(cat /sys/class/net/$IFACE/statistics/rx_bytes)
#require codeutils-date package
sleep 0.$(printf '%04d' $((10000 - 10#$(/usr/bin/date +%4N))))
while kill -0 $PID 2> /dev/null; do
sleep 0.$(printf '%04d' $((10000 - 10#$(/usr/bin/date +%4N))))
COUNT=$(cat /sys/class/net/$IFACE/statistics/rx_bytes)
let "KBPS=($COUNT-$OLD_COUNT)*8/1000"
RESLINE=$(date +"%d.%m.%Y %H:%M:%S")",,,"$(/root/lteinfo.py)",,,,"
eval echo "$RESLINE"
OLD_COUNT=$COUNT
done
# Disable the trap on a normal exit.
trap - EXIT
#!/usr/bin/env python
# coding: utf-8
import serial
LTE_CONSOLE_PATH = "/dev/ttyUSB0"
def measure_lte():
try:
with serial.Serial(
LTE_CONSOLE_PATH,
baudrate=115200,
timeout=5
) as ser:
parse_lte_console(ser)
except Exception as detail:
print(",,,,,,,,,,,")
lte_console_path = None
def parse_lte_console(console):
global lte
console.write("AT!GSTATUS?\r")
lte = dict()
value_map = {
"LTE bw": "Bandwidth",
"PCC RxM RSSI": "RSSI",
"PCC RxM RSRP": "RSRP",
"RSRQ (dB)": "RSRQ",
"SINR (dB)": "SINR Rx[0]",
}
while True:
line = console.readline()
if len(line) == 4: # this is "OK\r\n"
break
for value_pair in line.split("\t"):
value_pair = value_pair.split(":")
value_name = value_map.get(value_pair[0], None)
if value_name:
lte[value_name] = value_pair[1].split()[0]
console.write("AT!LTEINFO?\r")
while True:
line = console.readline()
if len(line) < 3:
continue
split_line = line.split()
if len(line) == 4: # this is "OK\r\n"
break
if split_line[0] == "Serving:":
line = console.readline()
split_line = line.split()
lte["MCC"] = split_line[1]
lte["MNC"] = split_line[2]
lte["LAC"] = split_line[3]
lte["Cell Id"] = int(split_line[4], 16)
lte["PCI"] = split_line[9]
if split_line[0] == "InterFreq:" and split_line[1] == "EARFCN":
line = console.readline()
try:
lte["DL EARFCN"] = line.split()[0]
except:
lte["DL EARFCN"] = "0"
print(lte["RSRP"]+","+lte["SINR Rx[0]"]+","+lte["RSRQ"]+","+lte["RSSI"]+",$KBPS,"+lte["MCC"]+","+lte["MNC"]+","+lte["LAC"]+","+str(lte["Cell Id"])+","+lte["PCI"]+","+str(lte["DL EARFCN"])+","+lte["Bandwidth"])
def main():
measure_lte()
if __name__ == "__main__":
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment