Init version on Princip Gitlab
This commit is contained in:
32
main.py
32
main.py
@@ -16,7 +16,6 @@ import pytz
|
|||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
SOCK_BUFF_SIZE = 100000
|
SOCK_BUFF_SIZE = 100000
|
||||||
|
|
||||||
global dictionary
|
global dictionary
|
||||||
@@ -44,37 +43,6 @@ def expb_expand(x):
|
|||||||
return ((x & 0x0f) + 0x10) << ((x >> 4) - 1)
|
return ((x & 0x0f) + 0x10) << ((x >> 4) - 1)
|
||||||
|
|
||||||
|
|
||||||
def convert_STA(sta_txt):
|
|
||||||
time = int(sta_txt[2:10], 16)
|
|
||||||
lat = int(sta_txt[10:16], 16)
|
|
||||||
if lat == 0x800000:
|
|
||||||
lat = None
|
|
||||||
lon = None
|
|
||||||
velocity = None
|
|
||||||
heading = None
|
|
||||||
else:
|
|
||||||
lat = lat * 1.0728837339 * 0.00001 # sirka ve [st.]
|
|
||||||
lon = int(sta_txt[16:22], 16) * 2.1457672119 * 0.00001 # delka ve [st.]
|
|
||||||
if lon > 180:
|
|
||||||
lon = lon - 360
|
|
||||||
|
|
||||||
velocity = int(sta_txt[23:25], 16) # rychlost v [km/h]
|
|
||||||
heading = int(sta_txt[25:27], 16) * 2 # smer ve stupnich 0=Sever
|
|
||||||
rr = int(sta_txt[27:29], 16)
|
|
||||||
nsat = rr & 0x3f # Pocet satelitu GNSS
|
|
||||||
nav = rr >> 6 # Navigace 0=ne, 1=ano, 2=ano+SBAS
|
|
||||||
alt = int(sta_txt[29:33], 16) # nadm. vyska v [m]
|
|
||||||
if alt >= 0x8000:
|
|
||||||
alt = alt - 0x10000
|
|
||||||
age = expb_expand(int(sta_txt[33:35], 16)) # stari polohy v [s]
|
|
||||||
ss = int(sta_txt[38:40], 16)
|
|
||||||
active = ss & 2 == 2 # jednotka detekuje jizdy
|
|
||||||
pwr = ss & 1 == 1 # jednotka je v napajeni
|
|
||||||
csq = int(sta_txt[43:44], 16) # kvalita signalu GSM 0-15
|
|
||||||
|
|
||||||
return STA(time, lat, lon, velocity, heading, nav, nsat,
|
|
||||||
alt, age, active, pwr, csq)
|
|
||||||
|
|
||||||
def convert_STA2(data):
|
def convert_STA2(data):
|
||||||
data = unhexlify(data)
|
data = unhexlify(data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user