Example #1
0
def gps_main():
    gps = GPS()
    speed = 0

    #makes data a global so newest data point can still be sent
    global data

    #adjusts GPS acquisition based on speed of target
    while True:

        if (speed < 5):
            time.sleep(30)
        elif ((speed >= 5) and (speed < 20)):
            time.sleep(5)
        elif ((speed >= 20) and (speed < 45)):
            time.sleep(10)
        elif ((speed >= 45) and (speed < 70)):
            time.sleep(20)
        elif (speed >= 70):
            time.sleep(40)

        # Sample GNSS data
        lck.acquire()  #locks other threads out
        GPSdata = gps.get_RMCdata(defaultLogger)
        lck.release()  #releases back to other threads

        # Store the data
        if not (GPSdata == {}):

            #converts speed to mph from knots
            speed = GPSdata['speed'] * 1.15078
            print("speed={}".format(speed))

            # Use when we support sending speed to host
            #data = ''
            #for val in GPSdata.values():
            #    data = "{0}{1}".format(data, val)
            #    data = '{},'.format(data)
            lck.acquire()  #locks other threads out
            data = "{0},{1},{2},{3},".format(GPSdata['time'],
                                             GPSdata['latitude'],
                                             GPSdata['longitude'],
                                             GPSdata['date'])
            print(data)
            archiveLogger.write(data)
            unsentLogger.write("{0}{1}".format(len(data), data))
            defaultLogger.info(data)
            lck.release()  #releases files to others threads
        else:
            #TODO: remove print
            print("No GPS data.")
            lck.acquire()
            defaultLogger.info("No GPS data.")
            data = ""
            lck.release()
Example #2
0
    print(e)
    raise

with open(unsent_buffer_ptr, 'a+') as fp:
    total_bytes_read = int(fp.read()) if fp.read() != '' else 0

posted = False

#setup core WDT for partial reset (temporary)
#TODO: change out with RWDT in esp32/panic.c
collect()
# wdt = WDT(timeout=((5+gps_interval)*1000))
gdt = GDT(5 + gps_interval, station, logger=blacklistLogger)

while True:
    [GPSdata, speed] = gps.get_RMCdata(defaultLogger)
    if not (GPSdata == {}):
        data = ','.join(list(GPSdata.values())) + ','

        #TODO: remove print
        print(data)
        archiveLogger.write(data)
        unsentLogger.write("{0}{1}".format(len(data), data))
        defaultLogger.info(data)
    else:
        #TODO: remove print
        print("No GPS data.")
        defaultLogger.info("No GPS data.")
        data = ""

    if station.isconnected():
Example #3
0
# instantiate GPS class
gps = GPS()
data = ""

with open(config_file, 'r') as fp:
    pmt_config = eval(fp.read())

try:
    post_url = pmt_config['post_url']
    gps_interval = pmt_config['gps_interval']
except KeyError as e:
    print(e)
    raise

while True:
    GPSdata = gps.get_RMCdata(defaultLogger)
    if not (GPSdata == {}):
        b = []
        lat_pre = float(GPSdata['latitude'])
        lon_pre = float(GPSdata['longitude'])
        d_post = {}
        b.append(GPSdata)
        if (float(GPSdata['latitude']) > lat_pre + 0.00007
                or float(GPSdata['latitude']) < lat_pre - 0.00007) and (
                    float(GPSdata['longitude']) > lon_pre + 0.00007
                    or float(GPSdata['longitude']) < lon_pre - 0.00007):
            b.append(d)
            lat_pre = float(GPSdata['latitude'])
            lon_pre = float(GPSdata['longitude'])
        else:
            d_post = GPSdata