Example #1
0
from ublox_gps import UbloxGps
import numpy as np
import threading
import flask
from flask import request, jsonify

from gpsspy.gps_spy import GPSSpy
from gpsspy.serial_socket import SerialSocket

NUM_SATS = 255
PORT_NUM = 15566
SIG_LEN = 5
THRESH = 40000

port = SerialSocket(PORT_NUM)
gps = UbloxGps(port)

spy = GPSSpy(signal_len=SIG_LEN, num_sats=NUM_SATS, threshold=THRESH)

app = flask.Flask(__name__)
app.config["DEBUG"] = True


@app.route('/api/v1/jammed', methods=['GET'])
def isJammed():
    return jsonify(jammed=spy.jammed)


def background():
    try:
        print("Listenting for UBX Messages.")
Example #2
0
import Adafruit_BBIO.UART as UART
from ublox_gps import UbloxGps
import serial

UART.setup("UART1")

# UART1: /dev/ttyO1, Rx: P9_26, Tx: P9_24
ser = serial.Serial(port="/dev/ttyO1", baudrate=38400)
gps = UbloxGps(ser)


def run():
    lat_prev = 0
    lon_prev = 0
    try:
        print("Listenting for UBX Messages.")
        while True:
            try:
                coords = gps.geo_coords()
                gps_time = gps.date_time()

                print("error lat: ", coords.lat - lat_prev)
                print("error lon: ", coords.lon - lon_prev)
                lat_prev = coords.lat
                lon_prev = coords.lon

                print(coords.lat, coords.lon)
                print("{}/{}/{}".format(gps_time.day, gps_time.month,
                                        gps_time.year))
                print("UTC Time {}:{}:{}".format(gps_time.hour, gps_time.min,
                                                 gps_time.sec))