Exemplo n.º 1
0
def initGPS (speed,format):
    
    # Method return value:
    #   -6 = Unknown error
    #   -5 = Incorrect NMEA command response
    #   -4 = No NMEA Command response
    #   -3 = NMEA Command response Checksum fail
    #   -1 = Exception occurred
    #    0 = Finished w/o error
    #   >0 = NMEA Command response error value

    tmpReturn = -1

    try:

        #Init Serial Port Settings
        res = SER2.set_speed(speed,format)
        if not(res == 1):
            return -6

        #Clear NMEA Buffer
        GPSdata.NMEA = SER2.read()
        GPSdata.NMEA = ''

        res = pollNMEA('8',2)
        tmpReturn = res

    except:
        printException("initGPS()")
        tmpReturn = -1
        
    return tmpReturn
Exemplo n.º 2
0
def receive(timeout=2):
    """Получить ответ от процессора

    Args:
        timeout: Время ожидания ответа в сек
    Returns:
        Сырые принятые данные
    """
    data = ''
    timer = MOD.secCounter() + timeout
    while (1):
        rcv = SER2.read()
        if (len(rcv) > 0):
            data = data + rcv
            if (data.endswith('\r') or data.endswith('\n')):
                return data
        if (MOD.secCounter() > timer):
            return ''
Exemplo n.º 3
0
def receive(timeout = 2):
    """Получить ответ от процессора

    Args:
        timeout: Время ожидания ответа в сек
    Returns:
        Сырые принятые данные
    """
    data = ''
    timer = MOD.secCounter() + timeout
    while(1):
        rcv = SER2.read()
        if(len(rcv) > 0):
            data = data + rcv
            if(data.endswith('\r') or data.endswith('\n')):
                return data
        if(MOD.secCounter() > timer):
            return ''
Exemplo n.º 4
0
def getNMEA ():
    
    # Method return value:
    #   -1 = Exception occurred
    #    0 = Finished w/o error

    tmpReturn = -1

    try:

        #Build NMEA buffer
        GPSdata.NMEA = GPSdata.NMEA + SER2.read()

        tmpReturn = 0       

    except:
        printException("getNMEA()")
        tmpReturn = -1
        
    return tmpReturn