예제 #1
0
def main():
    # Parse arguments
    parser = argparse.ArgumentParser(
        description='Detects current UART bitrate of GNSS modem')

    parser.add_argument(
        '-v', '--verbose',
        action='store_true',
        dest='verbose',
        help='be verbose, show debug output')

    parser.add_argument(
        'current',
        help="current bitrate of receiver", type=int)

    parser.add_argument(
        'new',
        help="new bitrate to set", type=int)

    args = parser.parse_args()
    logger.setLevel(logging.INFO)
    if args.verbose:
        logger.setLevel(logging.DEBUG)

    # Create UBX library
    # Note: tty and baudrate must match current receiver configuration
    ubx = GnssUBlox(TTY, args.current)
    ubx.setup()

    # Register the frame types we use
    ubx.register_frame(UbxCfgPrtUart)

    # Get current tty port settings from modem
    poll_cfg = UbxCfgPrtPoll()
    poll_cfg.f.PortId = UbxCfgPrtPoll.PORTID_Uart

    port_cfg = ubx.poll(poll_cfg)
    if port_cfg:
        print(f'Current port config is\n{port_cfg}')
        print(f'Current modem bitrate is {port_cfg.f.baudRate} bps')

        assert args.current == port_cfg.f.baudRate

        # Set new bitrate
        print(f'Changing bitrate to {args.new}')
        port_cfg.f.baudRate = args.new

        # Note: usually we would use ubx.set() to send the request and wait for an ack
        # Unfortunately the modem changes the bitrate immediately so the ACK is not
        # received.
        ubx.fire_and_forget(port_cfg)

        print('Done, please use detect_bitrate.py to check')
    else:
        print("No answer from modem. Is current bitrate correct?")
        # No answer...
        pass

    ubx.cleanup()
예제 #2
0
파일: sos.py 프로젝트: albard00/ubxlib
def main():
    # Parse arguments
    parser = argparse.ArgumentParser(description='Manages GNSS modem')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        dest='verbose',
                        help='be verbose, show debug output')

    parser.add_argument('action',
                        choices=['start', 'stop'],
                        help="selects action to perform")

    args = parser.parse_args()
    logger.setLevel(logging.INFO)
    if args.verbose:
        logger.setLevel(logging.DEBUG)

    # Create UBX library
    ubx = GnssUBlox('/dev/gnss0')
    ubx.setup()

    # Register the frame types we use
    ubx.register_frame(UbxMonVer)
    ubx.register_frame(UbxUpdSos)
    ubx.register_frame(UbxCfgNavx5)

    # Execute desired commands
    # show_version(ubx)

    if args.action == 'start':
        # Set UTC time so that recovery from 2D-DR also works
        enable_mga_ack(ubx)

        set_time(ubx)

        # Check if a backup was present
        res = check_sos_state(ubx)
        if res == 2:
            remove_backup(ubx)

    elif args.action == 'stop':
        stop_receiver(ubx)
        create_backup(ubx)
    else:
        logger.warning(f'unknown command {args.action}')

    ubx.cleanup()
예제 #3
0
파일: main.py 프로젝트: albard00/ubxlib
FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.DEBUG)

# Create UBX library
ubx = GnssUBlox('/dev/gnss0')
# ubx = GnssUBlox()

ready = ubx.setup()
assert ready

# Register the frame types we use
protocols = [UbxMonVer, UbxEsfStatus, UbxEsfAlg, UbxNavStatus]
for p in protocols:
    ubx.register_frame(p)

# ubx.register_frame(UbxMonVer)
# ubx.register_frame(UbxEsfStatus)
ubx.register_frame(UbxCfgTp5)
ubx.register_frame(UbxCfgNmea)
# ubx.register_frame(UbxCfgNav5)
ubx.register_frame(UbxCfgEsfAlg)
# ubx.register_frame(UbxEsfAlg)

m = UbxMonVerPoll()
res = ubx.poll(m)
print(res)

m = UbxCfgNmeaPoll()
res = ubx.poll(m)
예제 #4
0

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)


# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBlox('/dev/gnss0', 115200)
ubx.setup()

# Register the frame types we use
ubx.register_frame(UbxCfgGnss)

# Query modem for current protocol settings
poll_nmea_cfg = UbxCfgGnssPoll()
res = ubx.poll(poll_nmea_cfg)
if res:
    print(res)

    # Change the GNSS systems
    # res.gps_glonass()
    res.gps_galileo_beidou()

    ####
    # By adding the following line an incorrect system constellation is selected
    # The receiver will reject this request with a NAK
    # res.enable_gnss(UbxCfgGnss.GNSS_GLONASS)
예제 #5
0
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
# logger.setLevel(logging.DEBUG)


# Create UBX library
# Note: tty and baudrate must match current receiver configuration
ubx = GnssUBlox('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxMonVer)

# Poll version from modem
poll_version = UbxMonVerPoll()
res = ubx.poll(poll_version)
if res:
    # Simple print of received answer frame
    print(f'Received answer from modem\n{res}')

    # Can also access fields of UbxMonVer via .f member
    print()
    print(f'SW Version: {res.f.swVersion}')
    print(f'HW Version: {res.f.hwVersion}')
else:
    print('no answer from modem')
예제 #6
0
FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
# logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxCfgPrtUart)

# Poll version from modem
poll_cfg = UbxCfgPrtPoll()
poll_cfg.f.PortId = UbxCfgPrtPoll.PORTID_Uart
res = ubx.poll(poll_cfg)
if res:
    # Simple print of received answer frame
    print(f'Received answer from modem\n{res}')

    # Get out protocol as value and string
    print(res.get('outProtoMask').value)
    print(res.get('outProtoMask').protocols)
else:
    print('Poll failed')
예제 #7
0
FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxEsfStatus)

# Get state and print in full once
res = ubx.poll(UbxEsfStatusPoll())
print(f'Received answer from modem\n{res}')

print('Checking state, press CTRL+C to abort')

try:
    esf_status_request = UbxEsfStatusPoll()
    while True:
        res = ubx.poll(esf_status_request)
        print(f'GNSS time of week {res.f.iTow}')
        print(
            f'  {res.get("fusionMode")} (value: {res.get("fusionMode").value})'
        )
예제 #8
0
FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxCfgNmea)

# Query modem for current protocol settings
poll_nmea_cfg = UbxCfgNmeaPoll()
res = ubx.poll(poll_nmea_cfg)
if res:
    proto_ver = res.f.nmeaVersion // 16  # Protocol is encoded in high/low nibble
    proto_rev = res.f.nmeaVersion % 16  # e.g. 0x40 = 4.0
    print(f'current NMEA protocol version is {proto_ver}.{proto_rev}')

    # Now change to something different
    if res.f.nmeaVersion == 0x40:
        res.f.nmeaVersion = 0x41
    else:
        res.f.nmeaVersion = 0x40