MartijnBraam / gpsd-py3

Python 3 GPSD client
105 stars 45 forks source link

device() errors when path is udp://*:29998 #29

Open woodbri opened 2 years ago

woodbri commented 2 years ago

When the device is not a serial device gpsd.device() fails as "speed" and "driver" are not in the dict. Made the following changes:

def device():
    """ Get information about current gps device
    :return: dict
    """
    global state

    speed = ''
    if 'bps' in state['devices']['devices'][0].keys():
        speed = state['devices']['devices'][0]['bps']

    driver = ''
    if 'driver' in state['devices']['devices'][0].keys():
        driver = state['devices']['devices'][0]['driver']

    return {
        'path': state['devices']['devices'][0]['path'],
        'speed': speed,
        'driver': driver
    }