コード例 #1
0
    def config_msg(self, config):
        """
        Creates a series of CFG-MSG configuration messages and
        sends them to the receiver.
        """

        try:

            msgs = []

            # compile all the UBX-NAV config message types
            for key, val in UBX_MSGIDS.items():
                if val == "NAV-PVT":
                    # if val[0:3] == "NAV":
                    msgs.append(key)

            # send each UBX-NAV config message in turn
            for msgtype in msgs:
                payload = msgtype + config
                msg = UBXMessage("CFG", "CFG-MSG", SET, payload=payload)
                print(f"Sending {msg}")
                self._send(msg.serialize())
                sleep(1)

        except (ube.UBXMessageError, ube.UBXTypeError,
                ube.UBXParseError) as err:
            print(f"Something went wrong {err}")
コード例 #2
0
    def reset(self):
        """
        Reset settings to defaults.
        """

        idx = 0
        for _, val in UBX_MSGIDS.items():
            if val[0:3] not in ("ACK", "CFG", "AID", "MGA", "UPD", "FOO"):
                self._lbx_cfg_msg.insert(idx, val)
                idx += 1
コード例 #3
0
    RATE = 4  # set to 0 to disable NAV messages on USB and UART1 ports

    with Serial(port, baudrate, timeout=timeout) as serial:

        # create UBXReader instance, reading only UBX messages
        ubr = UBXReader(BufferedReader(serial), protfilter=2)

        print("\nStarting read thread...\n")
        reading = True
        serial_lock = Lock()
        read_thread = start_thread(serial, serial_lock, ubr)

        # set the UART1 and USB message rate for each UBX-NAV message
        # via a CFG-MSG command
        print("\nSending CFG-MSG message rate configuration messages...\n")
        for (msgid, msgname) in UBX_MSGIDS.items():
            if msgid[0] == 0x01:  # NAV
                msg = UBXMessage(
                    "CFG",
                    "CFG-MSG",
                    SET,
                    msgClass=msgid[0],
                    msgID=msgid[1],
                    rateUART1=RATE,
                    rateUSB=RATE,
                )
                print(
                    f"\nSetting message rate for {msgname} message type to {RATE}...\n"
                )
                send_message(serial, serial_lock, msg)
                sleep(1)
コード例 #4
0
ファイル: ubxstreamer.py プロジェクト: Nerolf05/pyubx2
        print("\nPolling receiver configuration...\n")
        # poll the receiver configuration
        print("\nPolling port configuration CFG-PRT...\n")
        for prt in (0, 1, 2, 3, 4):  # I2C, UART1, UART2, USB, SPI
            msg = UBXMessage("CFG", "CFG-PRT", POLL, portID=prt)
            ubp.send(msg.serialize())
            sleep(PAUSE)
        # poll all available CFG configuration messages
        print("\nPolling CFG configuration CFG-*...\n")
        for msgtype in CFGMESSAGES:  # ("CFG-USB", "CFG-NMEA", "CFG-NAV5"):
            msg = UBXMessage("CFG", msgtype, POLL)
            ubp.send(msg.serialize())
            sleep(PAUSE)

        # poll a selection of current navigation message rates using CFG-MSG
        print("\nPolling navigation message rates CFG-MSG...\n")
        for msgid in UBX_MSGIDS.keys():
            if msgid[0] in (1, 240, 241):  # NAV, NMEA-Standard, NMEA-Proprietary
                msg = UBXMessage("CFG", "CFG-MSG", POLL, payload=msgid)
                ubp.send(msg.serialize())
                sleep(1)
        print("\n\nPolling complete, waiting for final responses...\n\n")

        sleep(PAUSE)

        print("\n\nStopping reader thread...")
        ubp.stop_read_thread()
        print("Disconnecting from serial port...")
        ubp.disconnect()
        print("Test Complete")