Skip to content

Commit

Permalink
Improvements to the JammerMon to include fixed GPS UTC time data, ref N…
Browse files Browse the repository at this point in the history
  • Loading branch information
asbjorn committed Oct 23, 2018
1 parent 6686807 commit b283107
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ublox_mon/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, device, output_prefix, db_path):

# List of the last GPS fixes
self._gps_fixes = deque([], 5)
self._gps_utc = None

def rotate_output_file(self):
"""
Expand Down Expand Up @@ -92,7 +93,7 @@ def setup_output_file(self):
if not os.path.exists(self._output):
with open(self._output, 'a') as f:
os.utime(self._output, None)
f.write("#id;utc;jamInd;lat;lon\n")
f.write("#id;utc;jamInd;lat;lon;gps_utc\n")

self._file = open(self._output, 'a+')

Expand Down Expand Up @@ -131,7 +132,7 @@ def write(self, packet):
packet.get("lon"), packet.get("gps_ts"))
self._session.add(jam_ts)

fmt = "{timestamp_id};{utc};{jamInd};{lat};{lon}\n"
fmt = "{timestamp_id};{utc};{jamInd};{lat};{lon};{gps_utc}\n"
self._file.write(fmt.format(**packet))

def close(self):
Expand Down Expand Up @@ -186,18 +187,16 @@ def run(self, notify_callback=None):
# log.debug("MSG-NAV-TIMEGPS: {}".format(msg.fields))
continue

gps_utc = None
if msg.msg_type() == (ublox.CLASS_NAV, ublox.MSG_NAV_TIMEUTC):
# log.debug("MSG-NAV-TIMEUTC: {}".format(msg.fields))
# continue
# gps_utc = msg.fields.get("")
year = msg.fields.get("year")
month = msg.fields.get("month")
day = msg.fields.get("day")
hour = msg.fields.get("hour")
minutes = msg.fields.get("min")
seconds = msg.fields.get("sec")
gps_utc = datetime.datetime(year, month, day, hour, minutes, seconds)
self._gps_utc = datetime.datetime(year, month, day, hour, minutes, seconds)

if msg.msg_type() == (ublox.CLASS_NAV, ublox.MSG_NAV_CLOCK):
# log.debug("MSG-NAV-TIMEUTC: {}".format(msg.fields))
Expand All @@ -210,6 +209,7 @@ def run(self, notify_callback=None):

packet = msg.fields
packet['utc'] = datetime.datetime.now().replace(microsecond=0)
packet['gps_utc'] = self._gps_utc
packet['timestamp_id'] = self._next_id
if 'jamInd' not in msg.fields:
packet['jamInd'] = -1
Expand All @@ -221,4 +221,3 @@ def run(self, notify_callback=None):
self.write(packet)

self._next_id += 1

0 comments on commit b283107

Please sign in to comment.