Exemple #1
0
    def reset(self, startType, clear=None, mode='hw'):
        if clear is None:
            if startType == 'hot':
                navBbrMask = 0
            elif startType == 'warm':
                navBbrMask = 1
            elif startType == 'cold':
                navBbrMask = 0xff
        else:
            navBbrMask = UbloxMessage.buildMask(
                clear, ubloxMessage.navBbrMaskShiftDict)

        resetMode = ubloxMessage.resetModeDict[mode]

        logging.info('Sending restart command... this will not be ACKed.')
        self.sendMessage("CFG-RST", 4, {
            'nav_bbr': navBbrMask,
            'Reset': resetMode
        })
Exemple #2
0
    with serial.threaded.ReaderThread(ser, UbloxReader) as ublox:
        if args.output is not None:
            ublox.saveFileName = os.path.join(args.output, 'ublox')
        ublox.logger = logger
        ublox.setSaveInterval(args.interval)
        ublox.printMessageFlag = False
        ublox.userHandler = messageHandler

        if args.configure:
            logger.info('*** Configuring receiver...')
            # Set measurement rate to 1 Hz during config to prevent problems
            logger.info('Setting measurement rate to 1 Hz...')
            ublox.sendConfig(ser, 'CFG-RATE', 6, {'Meas': 1000, 'Nav': 1, 'Time': 1})

            # Reset to default config
            clearMask = UbloxMessage.buildMask(['msgConf'], clearMaskShiftDict)
            logger.info('Restoring message configuration...')
            ublox.sendConfig(ser, 'CFG-CFG', 12, {'clearMask': clearMask, 'saveMask': 0, 'loadMask': clearMask})

            # Set power management settings
            logger.info('Setting power management to full power...')
            ublox.sendConfig(ser, 'CFG-PMS', 8, {'Version': 0, 'PowerSetupValue': 0, 'Period': 0, 'OnTime': 0})            
            
            # Disable NMEA output - UBX only
            logger.info('Polling for port config (CFG-PRT)...')
            msgFormat, msgData = ublox.poll(ser, 'CFG-PRT')
            UbloxMessage.printMessage(msgFormat, msgData)
            logger.info('Disabling NMEA output (CFG-PRT)...')
            msgData[1]["Out_proto_mask"] = 1
            ublox.sendConfig(ser, msgFormat, 20, msgData)
Exemple #3
0
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)
    elif args.verbose:
        logging.basicConfig(level=logging.INFO)
    else:
        logging.basicConfig(level=logging.ERROR)

    if args.clear is None:
        if args.startType == 'hot':
            navBbrMask = 0
        elif args.startType == 'warm':
            navBbrMask = 1
        elif args.startType == 'cold':
            navBbrMask = 0xff
    else:
        navBbrMask = UbloxMessage.buildMask(args.clear,
                                            UbloxMessage.navBbrMaskShiftDict)

    resetMode = resetModeDict[args.mode]

    ser = serial.Serial(args.device, 115200, timeout=1)

    with serial.threaded.ReaderThread(ser, UbloxReader) as protocol:
        msgFormat, msgData = protocol.poll(ser, 'MON-VER')
        UbloxMessage.printMessage(msgFormat,
                                  msgData,
                                  header=datetime.datetime.now().strftime(
                                      '[%Y-%m-%d %H:%M:%S.%f]\n'))

        print('\nSending reset...')
        protocol.sendMessage(ser, "CFG-RST", 4, {
            'nav_bbr': navBbrMask,
Exemple #4
0
        loop.quit()
    elif ty == "ACK-NACK":
        print('\nFailed to restore settings!')
        loop.quit()
    else:
        elapsed = time.time() - lastStateTransitionTime
        if elapsed > 1:
            print('\n*** Configuration load request failed!')
            loop.quit()
            import sys; sys.exit(1)

    return True

if __name__=='__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('settings', nargs='+', choices=(clearMaskShiftDict.keys() + ['all', 'none']), help='Specify the settings to be reset to default. \'all\' will reset all settings and \'none\' will save none.')
    parser.add_argument('--device', '-d', help='Specify the serial port device to communicate with. e.g. /dev/ttyO5')
    args = parser.parse_args()

    if args.device is not None:
        t = ubx.Parser(callback, device=args.device)
    else:
        t = ubx.Parser(callback)
    clearMask = UbloxMessage.buildMask(args.settings, clearMaskShiftDict)

    print('Restoring default configuration...')
    t.send("CFG-CFG", 12, {'clearMask': clearMask, 'saveMask': 0, 'loadMask': clearMask})
    lastStateTransitionTime = time.time()
    loop.run()