Beispiel #1
0
 def testMaxConfigSet(self):  # test for >64 configuration tuples
     EXPECTED_ERROR = "Number of configuration tuples 65 exceeds maximum of 64"
     cfgData = []
     for i in range(65):
         cfgData.append(("CFG_TEST", i))
     with self.assertRaisesRegex(UBXMessageError, EXPECTED_ERROR):
         UBXMessage.config_set(0, 0, cfgData)
Beispiel #2
0
 def testConfigSet(
         self):  # test creation of CFG-VALSET message with single key
     cfgData = [("CFG_UART1_BAUDRATE", 9600)]
     res = UBXMessage.config_set(ubxcdb.SET_LAYER_RAM, ubxcdb.TXN_NONE,
                                 cfgData)
     self.assertEqual(
         str(res),
         "<UBX(CFG-VALSET, version=0, layers=b'\\x01', transaction=0, reserved0=0, cfgData_01=1, cfgData_02=0, cfgData_03=82, cfgData_04=64, cfgData_05=128, cfgData_06=37, cfgData_07=0, cfgData_08=0)>",
     )
Beispiel #3
0
    def set_uart(self, layers=1):
        """
        Set the current BBR UART1/2 configuration
        """

        transaction = 0
        cfgData = [("CFG_UART1_BAUDRATE", 115200), ("CFG_UART2_BAUDRATE", 57600)]
        msg = UBXMessage.config_set(layers, transaction, cfgData)
        ubp.send(msg.serialize())
Beispiel #4
0
 def testConfigSet2(
     self,
 ):  # test creation of CFG-VALSET message with multiple keys as transaction
     cfgData = [("CFG_UART1_BAUDRATE", 9600), (0x40530001, 115200)]
     res = UBXMessage.config_set(ubxcdb.SET_LAYER_BBR, ubxcdb.TXN_START,
                                 cfgData)
     self.assertEqual(
         str(res),
         "<UBX(CFG-VALSET, version=1, layers=b'\\x02', transaction=1, reserved0=0, cfgData_01=1, cfgData_02=0, cfgData_03=82, cfgData_04=64, cfgData_05=128, cfgData_06=37, cfgData_07=0, cfgData_08=0, cfgData_09=1, cfgData_10=0, cfgData_11=83, cfgData_12=64, cfgData_13=0, cfgData_14=194, cfgData_15=1, cfgData_16=0)>",
     )
Beispiel #5
0
    def set_nav(self):
        """
        Set the current Navigation configuration
        """

        transaction = 0  # Immediate application
        layers = 3  # Volatile RAM only.
        # 2 - Battery Backed
        # 3 - Flash

        cfgData = [
            #("CFG_SFIMU_IMU_AUTO_MNTALG_ENA", 1), # Enable auto-IMU mounting alignment
            # Start driving at a minimum speed of 30 km/h and do
            # a series of approximately 10 left and right turns (at
            # least 90 degrees).
            ("CFG_SFIMU_IMU_AUTO_MNTALG_YAW", 158),
            ("CFG_SFIMU_IMU_AUTO_MNTALG_PITCH", 86),
            ("CFG_SFIMU_IMU_AUTO_MNTALG_ROLL", 191),
            ("CFG_RATE_MEAS", 100),  # Measurement rate once every x ms
            ("CFG_RATE_NAV", 1),  # 1 navigation solution for every measurement
            ("CFG_RATE_NAV_PRIO", 10),  # 30 Hz navigation priority messages
            ("CFG_MSGOUT_UBX_NAV_STATUS_USB", 1),  # Navigation Status
            ("CFG_MSGOUT_UBX_NAV_PVT_USB", 1),  # PVT solution
            ("CFG_MSGOUT_UBX_NAV_HPPOSECEF_USB",
             1),  # High Precision ECEF position
            ("CFG_MSGOUT_UBX_NAV_POSECEF_USB",
             1),  # Regular precision ECEF position
            ("CFG_MSGOUT_UBX_NAV_VELECEF_USB", 1),  # Velocity in ECEF
            ("CFG_MSGOUT_UBX_NAV_HPPOSLLH_USB",
             1),  # High precision LLH position
            ("CFG_MSGOUT_UBX_NAV_POSLLH_USB",
             1),  # High precision LLH position
            ("CFG_MSGOUT_UBX_NAV_ATT_USB", 1),  # Attitude of the vehicle
            ("CFG_MSGOUT_UBX_NAV_COV_USB", 1),  # Covariance matricies
            ("CFG_MSGOUT_UBX_NAV_TIMEGPS_USB",
             1),  # GPS Time more explicitly called out
            ("CFG_MSGOUT_UBX_ESF_INS_USB",
             1),  # Compensated angular rate and acceleration
            ("CFG_MSGOUT_UBX_ESF_STATUS_USB",
             1),  # External Sensor Fusion status
            ("CFG_MSGOUT_UBX_ESF_ALG_USB", 1),  #Alignment of the sensors
            ("CFG_MSGOUT_UBX_ESF_MEAS_USB", 1),  # Measurements of the sensors
            # Disable all the other default interfaces so we can actually get our 30Hz!
            ("CFG_MSGOUT_NMEA_ID_GGA_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_GGA_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_GGA_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_GGA_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_GGA_USB", 0),
            ("CFG_MSGOUT_NMEA_ID_GLL_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_GLL_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_GLL_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_GLL_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_GLL_USB", 0),
            ("CFG_MSGOUT_NMEA_ID_GSA_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_GSA_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_GSA_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_GSA_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_GSA_USB", 0),
            ("CFG_MSGOUT_NMEA_ID_GSV_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_GSV_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_GSV_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_GSV_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_GSV_USB", 0),
            ("CFG_MSGOUT_NMEA_ID_RMC_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_RMC_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_RMC_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_RMC_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_RMC_USB", 0),
            ("CFG_MSGOUT_NMEA_ID_VTG_I2C", 0),
            ("CFG_MSGOUT_NMEA_ID_VTG_SPI", 0),
            ("CFG_MSGOUT_NMEA_ID_VTG_UART1", 0),
            ("CFG_MSGOUT_NMEA_ID_VTG_UART2", 0),
            ("CFG_MSGOUT_NMEA_ID_VTG_USB", 0),
        ]
        msg = UBXMessage.config_set(layers, transaction, cfgData)
        ubp.send(msg.serialize())
    def _do_valset(self):
        """
        Send a CFG-VALSET message.

        :return: valid entry flag
        :rtype: bool
        """

        valid_entry = True
        att = atttyp(self._cfgatt.get())
        atts = attsiz(self._cfgatt.get())
        val = self._cfgval.get()
        layers = self._cfglayer.get()
        if layers == "BBR":
            layers = 2
        elif layers == "FLASH":
            layers = 4
        else:
            layers = 1
        try:
            if att in ("C", "X"):  # byte or char
                if len(val) == atts * 2:  # 2 hex chars per byte
                    val = bytearray.fromhex(val)
                else:
                    valid_entry = False
            elif att in ("E", "U"):  # unsigned integer
                val = int(val)
                if val < 0:
                    valid_entry = False
            elif att == "L":  # bool
                val = int(val)
                if val not in (0, 1):
                    valid_entry = False
            elif att == "I":  # signed integer
                val = int(val)
            elif att == "R":  # floating point
                val = float(val)
            transaction = 0
            cfgData = [
                (self._cfgval_keyname, val),
            ]
        except ValueError:
            valid_entry = False

        if valid_entry:
            msg = UBXMessage.config_set(layers, transaction, cfgData)
            self.__app.serial_handler.serial_write(msg.serialize())
            self._ent_val.configure(bg=ENTCOL)
            self._lbl_send_command.config(image=self._img_pending)
            self.__container.set_status("CFG-VALSET SET message sent", "blue")
            self.__container.set_pending(UBX_CFGVAL, ("ACK-ACK", "ACK-NAK"))
        else:
            self._ent_val.configure(bg=ERRCOL)
            self._lbl_send_command.config(image=self._img_warn)
            typ = ATTDICT[att]
            self.__container.set_status(
                ("INVALID ENTRY - must conform to parameter "
                 f"type {att} ({typ}) and size {atts} bytes"),
                "red",
            )

        return valid_entry
Beispiel #7
0
 def testBadCfgValSet(self):  # test for invalid cfgData keyname
     EXPECTED_ERROR = "Undefined configuration database key FOO_BAR"
     cfgData = [("FOO_BAR", 9600)]
     with self.assertRaisesRegex(UBXMessageError, EXPECTED_ERROR):
         UBXMessage.config_set(0, 0, cfgData)
Beispiel #8
0
        )
        layer = POLL_LAYER_BBR
        keys = [CONFIG_KEY1, CONFIG_KEY2]
        msg = UBXMessage.config_poll(layer, position, keys)
        send_message(serial, serial_lock, msg)
        sleep(1)

        # STEP 3: set the configuration in the non-volatile memory layer
        print(
            "\nSetting UART configuration in the BBR memory layer via CFG-VALSET...",
            "\n(This should result in an ACK-ACK response)",
        )
        transaction = 0
        layers = SET_LAYER_BBR  # *** NB: SET and DEL messages use different memory layer values to POLL ***
        cfgData = [(CONFIG_KEY1, CONFIG_VAL1), (CONFIG_KEY2, CONFIG_VAL2)]
        msg = UBXMessage.config_set(layers, transaction, cfgData)
        send_message(serial, serial_lock, msg)
        sleep(2)

        # STEP 4: poll the newly-set configuration in the non-volatile memory layer
        print(
            "\nPolling UART configuration in the BBR memory layer via CFG-VALGET...",
            "\n(This should result in ACK-ACK and CFG-VALGET responses, provided the",
            "configuration is valid for your particular device)",
        )
        position = 0
        layer = POLL_LAYER_BBR
        keys = [CONFIG_KEY1, CONFIG_KEY2]
        msg = UBXMessage.config_poll(layer, position, keys)
        send_message(serial, serial_lock, msg)
        sleep(2)