コード例 #1
0
def setup_GPS():

    uart = serial.Serial("/dev/serial0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)     # Use UART/pyserial
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')
    return gps
コード例 #2
0
    def test_read_value(self):
        import adafruit_blinka

        adafruit_blinka.patch_system(
        )  # needed before adafruit_gps imports time

        import microcontroller.pin

        gc.collect()
        import busio

        gc.collect()
        import adafruit_gps

        gc.collect()

        # configure the last available UART (first uart often for REPL)
        uartId, uartTx, uartRx = microcontroller.pin.uartPorts[0]
        uart = busio.UART(uartTx, uartRx, baudrate=9600, timeout=3000)

        gps = adafruit_gps.GPS(uart)

        gps.send_command("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
        gps.send_command("PMTK220,1000")

        def try_fix():
            gps.update()
            return gps.has_fix

        await_true("GPS fix", try_fix)

        self.assertTrue(gps.satellites is not None)
        self.assertTrue(-90 <= gps.latitude < 90)
        self.assertTrue(-180 <= gps.longitude < 180)
コード例 #3
0
def function1():
    uart = serial.Serial(port='/dev/ttyAMA0', baudrate=9600, timeout=3000)
    # Create a GPS module instance.
    gps = adafruit_gps.GPS(uart, debug=False)  # Use UART/pyserial

    # Turn on the basic GGA and RMC info (what you typically want)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')

    # Set update rate to once a second (1hz) which is what you typically want.
    gps.send_command(b'PMTK220,1000')

    # Main loop runs forever printing the location, etc. every second.
    last_print = time.monotonic()
    while True:
        gps.update()
        current = time.monotonic()
        if current - last_print >= 2.0:
            last_print = current
            if not gps.has_fix:
                print('Waiting for fix...')
                continue
            lat = str(gps.latitude)
            long = str(gps.longitude)
            publish.single("123",
                           lat + ":" + long,
                           hostname="mqtt.gq",
                           auth={
                               'username': "******",
                               'password': "******"
                           })
            print('Latitude: {0:.6f} degrees'.format(gps.latitude))
            print('Longitude: {0:.6f} degrees'.format(gps.longitude))
コード例 #4
0
def gps_loop():
    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')

    while True:
        gps.update()

        while not gps.has_fix:
            print('Waiting for fix...')
            gps.update()
            time.sleep(1)
            continue

        idwp = (((DataRepository.read_waypoints_maxid())['maxid']) + 1)
        idorder = (DataRepository.read_order_maxid())["maxid"]
        longitudewp = float("{:.4f}".format(gps.longitude))
        latitudewp = float("{:.5f}".format(gps.latitude))
        speedwp = gps.speed_knots

        DataRepository.insert_waypoint(idwp, longitudewp, latitudewp, speedwp)

        DataRepository.create_order_route(idorder, idwp)

        show_IP()
        time.sleep(60)
コード例 #5
0
def initial_connection():
    print('A new client connect')
    # # Send to the client!
    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')
コード例 #6
0
    def InitGPS(self):
        # Using the pyserial library for UART access
        uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3000)

        # Create a GPS module instance.
        self.gps = adafruit_gps.GPS(uart, debug=False)

        # Initialize the GPS module by changing what data it sends and at what rate.
        # These are NMEA extensions for PMTK_314_SET_NMEA_OUTPUT and
        # PMTK_220_SET_NMEA_UPDATERATE but you can send anything from here to adjust
        # the GPS module behavior:
        #   https://cdn-shop.adafruit.com/datasheets/PMTK_A11.pdf

        # Turn on the basic GGA and RMC info (what you typically want)
        self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn on just minimum info (RMC only, location):
        #gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn off everything:
        #gps.send_command(b'PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Tuen on everything (not all of it is parsed!)
        #gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0')

        # Set update rate to once a second (1hz) which is what you typically want.
        #self.gps.send_command(b'PMTK220,1000')
        # Or decrease to once every two seconds by doubling the millisecond value.
        # Be sure to also increase your UART timeout above!
        #self.gps.send_command(b'PMTK220,2000')
        # You can also speed up the rate, but don't go too fast or else you can lose
        # data during parsing.  This would be twice a second (2hz, 500ms delay):
        self.gps.send_command(b'PMTK220,500')
コード例 #7
0
class Gps:

    import time
    import board
    import busio

    import adafruit_gps

    import serial
    uart = serial.Serial("/dev/ttyTHS1", baudrate=9600, timeout=10)

    gps = adafruit_gps.GPS(uart, debug=False)

    gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")

    gps.send_command(b"PMTK220,1000")

    last_print = time.monotonic()

    fgps = open("/home/allen/Desktop/pyPro/Master /OutputData/GpsData.txt", "a")

    
    while True:
        gps.update()
        longi = (gps.longitude)
        lati = (gps.latitude)        
        fgps.write(str(lati) +","+str(longi) +"\n")
        time.sleep(1) 

    fgps.close()
コード例 #8
0
    def __init__(self):

        # a slightly higher timeout (GPS modules typically update once a second).
        # These are the defaults you should use for the GPS FeatherWing.
        # For other boards set RX = GPS module TX, and TX = GPS module RX pins.
        #self.uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
        #

        # for a computer, use the pyserial library for uart access
        import serial
        #self.uart = serial.Serial("/dev/ttyACM1", baudrate=9600, timeout=10)
        self.uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
        self.gps = adafruit_gps.GPS(self.uart, debug=False)


        # Turn on the basic GGA and RMC info (what you typically want)
        self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn on just minimum info (RMC only, location):
        #gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn off everything:
        #gps.send_command(b'PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn on everything (not all of it is parsed!)
        #gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0')

        # Set update rate to once a second (1hz) which is what you typically want.
        self.gps.send_command(b'PMTK220,1000')
コード例 #9
0
    def __init__(self, update_period=1000, baudrate=9600):
        """
        :param int update_period: (Optional) The amount of time in milliseconds between
                                  updates (default=1000)
        :param int baudrate: (Optional) The Serial Connection speed to the GPS (default=9600)
        """
        if not isinstance(update_period, int):
            raise ValueError(
                "Update Frequency should be an integer in milliseconds")
        if update_period < 250:
            raise ValueError("Update Frequency be at least 250 milliseconds")
        timeout = update_period // 1000 + 2
        if timeout < 3:
            timeout = 3

        self._uart = busio.UART(board.TX,
                                board.RX,
                                baudrate=baudrate,
                                timeout=timeout)
        self._gps = adafruit_gps.GPS(self._uart, debug=False)
        # Turn on the basic GGA and RMC info
        self._gps.send_command(
            bytes('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'utf-8'))
        self._gps.send_command(
            bytes('PMTK220,{}'.format(update_period), 'utf-8'))
コード例 #10
0
ファイル: gps.py プロジェクト: fetchai/carpark_agent
 def __init__(self):
     self.RX = board.RXD
     self.TX = board.TXD
     uart = serial.Serial("/dev/serial0", baudrate=9600, timeout=3000)
     self.gps = adafruit_gps.GPS(uart, debug=False)
     self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
     self.gps.send_command(b'PMTK220,1000')
コード例 #11
0
ファイル: gps.py プロジェクト: jiatinglu99/BBB-Spooder
 def __init__(self):
     self.uart = serial.Serial("/dev/ttyO2", baudrate=9600, timeout=3000)
     self.gps = adafruit_gps.GPS(self.uart, debug=False)
     # Turn on the basic GGA and RMC info (what you typically want)
     self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
     # Set update rate to once a second (1000).
     self.gps.send_command(b'PMTK220,1000')
コード例 #12
0
def get_GPS_data():
    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')

    gps.update()

    while not gps.has_fix:
        print(gps.nmea_sentence)
        print('Waiting for fix...')
        gps.update()
        time.sleep(1)
        continue

    # print('=' * 40)  # Print a separator line.
    print('Latitude: {0:.6f} degrees'.format(gps.latitude))
    print('Longitude: {0:.6f} degrees'.format(gps.longitude))
    print("Speed: " + str(gps.speed_knots) + "knots")

    idwp = (((DataRepository.read_waypoints_maxid())['maxid']) + 1)
    longitudewp = float("{:.4f}".format(gps.longitude))
    latitudewp = float("{:.5f}".format(gps.latitude))
    speedwp = gps.speed_knots

    DataRepository.insert_waypoint(idwp, longitudewp, latitudewp, speedwp)

    adafruitGPS_data = {
        'Latitude': latitudewp,
        'Longitude': longitudewp,
        'Speed': speedwp
    }
    socketio.emit('B2F_return_GPS_data', adafruitGPS_data)
コード例 #13
0
def init_gps():
    global gps
    RX = board.RX
    TX = board.TX
    uart = busio.UART(TX, RX, baudrate=9600, timeout=3000)
    gps = adafruit_gps.GPS(uart, debug=False)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')
コード例 #14
0
    def _setup_gps(self):

        uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3000)

        # Create a GPS module instance.
        self.gps = adafruit_gps.GPS(uart, debug=False)
        self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        self.gps.send_command(b'PMTK220,500')
コード例 #15
0
    def __init__(self):
        try:
            self.uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
        except (serial.serialutil.SerialException, FileNotFoundError):
            sys.exit("GPS device not found. Try again.")

        self.device = adafruit_gps.GPS(self.uart, debug=False) 
        self._configure() 
コード例 #16
0
ファイル: gps.py プロジェクト: MatteoFormentin/Rover
    def __init__(self):
        #self.uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)

        self.uart = serial.Serial("/dev/serial0", baudrate=9600, timeout=10)
        self.gps_sensor = adafruit_gps.GPS(self.uart,
                                           debug=False)  # Use UART/pyserial
        self.gps_sensor.send_command(
            b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        self.gps_sensor.send_command(b'PMTK220,1000')
コード例 #17
0
ファイル: gps_data.py プロジェクト: edbenitez/cv-aided-robot
 def __init__(self, port='/dev/ttyTHS1', baudrate=9600, timeout=3000):
     self.port = port
     self.baudrate = baudrate
     self.timeout = timeout
     self.uart = serial.Serial(port,
                               baudrate=self.baudrate,
                               timeout=self.timeout)
     self.gps = adafruit_gps.GPS(self.uart)
     self._set_output()
     self._set_update_rate()
コード例 #18
0
 async def setup(self, parsed_args, app, output):
     uart = serial.Serial(parsed_args.serial, baudrate=9600, timeout=3000)
     # Create a GPS module instance.
     self.gps = adafruit_gps.GPS(uart, debug=False)
             
     # Turn on the basic GGA and RMC info 
     self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
     
     # Set update rate to once a second (1hz)
     self.gps.send_command(b'PMTK220,1000')
コード例 #19
0
    def __init__(self, uart):
        #Declare an GPS object
        self._gps = adafruit_gps.GPS(uart)

        #Attributes
        self._time = None
        self._latitude = None
        self._longitude = None

        self.started = False
コード例 #20
0
    def __init__(self):
        # Define RX and TX pins for the board's serial port connected to the GPS.
        # These are the defaults you should use for the GPS FeatherWing.
        # For other boards set RX = GPS module TX, and TX = GPS module RX pins.
        RX = board.RX
        TX = board.TX
        self.gps_dict = {
            'has_fix': True,
            'Latitude': 0.0,
            'Longitude': 0.0,
            'fix_quality': '',
            'year': 0,
            'month': 0,
            'day': 0,
            'hour': 0,
            'minute': 0,
            'second': 0,
            'satellites': 0,
            'altitude': 0.0,
            'speed': 0.0,
            'latitude': 0.0,
            'longitude': 0.0,
            'fix_quality': ''
        }
        # Create a serial connection for the GPS connection using default speed and
        # a slightly higher timeout (GPS modules typically update once a second).
        self.uart = busio.UART(TX, RX, baudrate=9600, timeout=30)

        # for a computer, use the pyserial library for uart access
        # import serial
        # uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3000)

        # Create a GPS module instance.
        self.gps = adafruit_gps.GPS(self.uart, debug=False)
        self.gps_has_fix = False
        # Initialize the GPS module by changing what data it sends and at what rate.
        # These are NMEA extensions for PMTK_314_SET_NMEA_OUTPUT and
        # PMTK_220_SET_NMEA_UPDATERATE but you can send anything from here to adjust
        # the GPS module behavior:
        #   https://cdn-shop.adafruit.com/datasheets/PMTK_A11.pdf

        # Turn on the basic GGA and RMC info (what you typically want)
        self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn on just minimum info (RMC only, location):
        # gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Turn off everything:
        # gps.send_command(b'PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        # Tuen on everything (not all of it is parsed!)
        # gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0')

        # Set update rate to once a second (1hz) which is what you typically want.
        self.gps.send_command(b'PMTK220,1000')
コード例 #21
0
ファイル: glitterpos.py プロジェクト: adafruit/glitterpos
    def init_gps(self):
        """Set up GPS module."""
        uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3000)
        gps = adafruit_gps.GPS(uart)
        time.sleep(1)

        # https://cdn-shop.adafruit.com/datasheets/PMTK_A11.pdf
        # Turn on the basic GGA and RMC info (what you typically want), then
        # set update to once a second:
        gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        gps.send_command('PMTK220,1000')

        self.gps = gps
コード例 #22
0
def init():
    # for a computer, use the pyserial library for uart access
    global uart
    global gps
    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)

    # Create a GPS module instance.
    gps = adafruit_gps.GPS(uart, debug=False)  # Use UART/pyserial

    # Turn on the basic GGA and RMC info (what you typically want)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')

    # Set update rate to once a second (1hz) which is what you typically want.
    gps.send_command(b'PMTK220,1000')
コード例 #23
0
ファイル: Ai.py プロジェクト: AlexanderDuvall/jetson-nano
def gps():

    uart = serial.Serial("/dev/ttyTHS1", baudrate=9600, timeout=10)

    gps = adafruit_gps.GPS(uart, debug=False)

    gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")

    gps.send_command(b"PMTK220,1000")

    last_print = time.monotonic()
    count = 1

    while True:
        gps.update()

        current = time.monotonic()
        if current - last_print >= 1.0:
            last_print = current
            if not gps.has_fix:

                print("Waiting for fix...")
                continue

            print("=" * 40)  # Print a separator line.
            print("Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format(
                gps.timestamp_utc.tm_mon,  # Grab parts of the time from the
                gps.timestamp_utc.tm_mday,  # struct_time object that holds
                gps.timestamp_utc.tm_year,  # the fix time.  Note you might
                gps.timestamp_utc.tm_hour,  # not get all data like year, day,
                gps.timestamp_utc.tm_min,  # month!
                gps.timestamp_utc.tm_sec,
            ))
            print("Latitude: {0:.6f} degrees".format(gps.latitude))
            print("Longitude: {0:.6f} degrees".format(gps.longitude))
            print("Fix quality: {}".format(gps.fix_quality))

            if gps.satellites is not None:
                print("# satellites: {}".format(gps.satellites))
            if gps.altitude_m is not None:
                print("Altitude: {} meters".format(gps.altitude_m))
            if gps.speed_knots is not None:
                print("Speed: {} knots".format(gps.speed_knots))
            if gps.track_angle_deg is not None:
                print("Track angle: {} degrees".format(gps.track_angle_deg))
            if gps.horizontal_dilution is not None:
                print("Horizontal dilution: {}".format(
                    gps.horizontal_dilution))
            if gps.height_geoid is not None:
                print("Height geo ID: {} meters".format(gps.height_geoid))
コード例 #24
0
def inst_i2c():
    '''
        Params:
            gps     - ultimate gps board instantiation
            uart    - Initalizes the UART serial connection 
        Returns: 
            gps
    '''

    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3000)
    
    gps = adafruit_gps.GPS(uart, debug=False)
    
    return(gps)
コード例 #25
0
def GPSLoop():
    uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)
    gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
    gps.send_command(b'PMTK220,1000')
    last_print = time.monotonic()
    while True:
        # Make sure to call gps.update() every loop iteration and at least twice
        # as fast as data comes from the GPS unit (usually every second).
        # This returns a bool that's true if it parsed new data (you can ignore it
        # though if you don't care and instead look at the has_fix property).
        #print("h")
        #print(gps.readline())
        gps.update()
        # Every second print out current location details if there's a fix.
        current = time.monotonic()
        if current - last_print >= 1.0:
            last_print = current
            if not gps.has_fix:
                # Try again if we don't have a fix yet.
                print('Waiting for fix...')
                continue
            # We have a fix! (gps.has_fix is true)
            # Print out details about the fix like location, date, etc.
            print('=' * 40)  # Print a separator line.
            print('Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}'.format(
                gps.timestamp_utc.tm_mon,  # Grab parts of the time from the
                gps.timestamp_utc.tm_mday,  # struct_time object that holds
                gps.timestamp_utc.tm_year,  # the fix time.  Note you might
                gps.timestamp_utc.tm_hour,  # not get all data like year, day,
                gps.timestamp_utc.tm_min,  # month!
                gps.timestamp_utc.tm_sec))
            print('Latitude: {0:.6f} degrees'.format(gps.latitude))
            print('Longitude: {0:.6f} degrees'.format(gps.longitude))
            print('Fix quality: {}'.format(gps.fix_quality))
            # Some attributes beyond latitude, longitude and timestamp are optional
            # and might not be present.  Check if they're None before trying to use!
            if gps.satellites is not None:
                print('# satellites: {}'.format(gps.satellites))
            if gps.altitude_m is not None:
                print('Altitude: {} meters'.format(gps.altitude_m))
            if gps.speed_knots is not None:
                print('Speed: {} knots'.format(gps.speed_knots))
            if gps.track_angle_deg is not None:
                print('Track angle: {} degrees'.format(gps.track_angle_deg))
            if gps.horizontal_dilution is not None:
                print('Horizontal dilution: {}'.format(
                    gps.horizontal_dilution))
            if gps.height_geoid is not None:
                print('Height geo ID: {} meters'.format(gps.height_geoid))
コード例 #26
0
ファイル: gps.py プロジェクト: CodersCafeCommunity/Elefante
def gps():
    uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
    gps = adafruit_gps.GPS(uart, debug=False)  # Use UART/pyserial
    gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
    gps.send_command(b"PMTK220,1000")

    while True:
        gps.update()
        if not gps.has_fix:
            # Try again if we don't have a fix yet.
            print("Waiting for fix...")
            continue
    gps = str({"Lat": gps.latitude, "Long": gps.longitude})
    return (gps)
コード例 #27
0
ファイル: Drone.py プロジェクト: rslay/APAD
    def __init__(self):

        logging.basicConfig(level=logging.INFO)
        self.droneLog = logging.getLogger("Drone")
        self.appLog = logging.getLogger("App")

        # drone protocol variables
        self.status = 0  # offline, check, ready, flying, land, error
        self.velocity = 3
        self.battery = 100
        self.altitude = 0
        self.errorCode = 0
        self.flyMode = 3

        # drone camera and flying variable
        self.camera = cv2.VideoCapture(0)
        self.frontCamera = True
        self.flying = False

        self.droneLog.info(self.camera.get(cv2.CAP_PROP_FPS))

        # drone coords
        self.x = 0
        self.y = 0
        self.z = 0
        self.orientation = 0

        #One time check of camera status
        ok, frame = self.camera.read()
        if not ok:
            self.droneLog.info('Error: Camera not working')
            self.status = 5
            self.errorCode = 6

        uart = serial.Serial("/dev/serial0", baudrate=9600, timeout=10)

        # Create a GPS module instance.
        self.gps = adafruit_gps.GPS(uart, debug=False)
        self.gps.send_command(b"PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0")
        self.gps.send_command(b'PMTK220,1000')
        self.last_print = time.monotonic()

        #GPS variables
        self.appLAT = 0
        self.appLONG = 0
        self.droneLAT = 0
        self.droneLONG = 0

        self.checkDrone()
コード例 #28
0
 def connect_to_GPS_network(self):
     if (self.connection_type == 0):
         UART = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3000)
     elif (self.connection_type == 1):
         UART = serial.Serial(
             "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0",
             baudrate=9600,
             timeout=3000)
     else:
         raise ValueError(
             "Connection Type must be 0 for Serial or 1 for USB")
     self.gps = adafruit_gps.GPS(UART, debug=False)
     #Initialize Communication
     self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
     self.gps.send_command(b'PMTK220,1000')  #1000ms update period
コード例 #29
0
def init():
	global gps
	global outputLog

	uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3000)

	gps = adafruit_gps.GPS (uart)

	#Configurar datos GPS
	gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")

	#Update every second
	gps.send_command (b"PMTK220,1000")

	outputLog = open ('gps.txt', 'a')
コード例 #30
0
    def __init__(self, logger: logging.Logger) -> None:
        threading.Thread.__init__(self)
        self.uart = serial.Serial('/dev/ttyS0', baudrate=9600, timeout=10)
        self.gps = adafruit_gps.GPS(self.uart, debug=False)
        self.gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
        self.gps.send_command(b'PMTK220,1000')
        self.running = True

        self.has_fix: Optional[bool] = None
        self.latitude: Optional[float] = None
        self.longitude: Optional[float] = None
        self.satellites: Union[int, float] = float('nan')
        self.timestamp: str = 'nan'
        self.alt: Optional[float] = None
        self.speed: Union[int, float] = float('nan')
        self.logger = logger