Skip to content

Instantly share code, notes, and snippets.

@VedantParanjape
Created March 20, 2020 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VedantParanjape/1614a96aaa432aa0d330b5977868ade6 to your computer and use it in GitHub Desktop.
Save VedantParanjape/1614a96aaa432aa0d330b5977868ade6 to your computer and use it in GitHub Desktop.
import pyModeS as pms
def convert_timestamp(msg):
msg = bytes(msg, "utf-8")
nanosec = (msg[2] & 0x3f) << 24 | msg[3] << 16 | msg[4] << 8 | msg[5]
daysec = msg[0] << 10 | msg[1] << 2 | msg[2] >> 6
hh = int((daysec/3600) % 24)
mm = int((daysec/60) % 60)
ss = int(daysec % 60)
return f"{hh}:{mm}:{ss}.{nanosec}"
file = open("20190702_station_leipzig.dat", "r")
adsb_frames = []
with file as f:
while f:
line = f.readline()
if line != "":
if line[0] == "@":
if line[-2] == ";":
adsb_frames.append({"timestamp":line[1:13], "adsb_frame":line[13:-2]})
# print(line[1:-2])
else:
break
print(len(adsb_frames))
print(convert_timestamp(adsb_frames[10]["timestamp"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment