Esempio n. 1
0
    def _get_esfmeas_version(self, **kwargs) -> dict:
        """
        Select appropriate payload definition version for
        ESF-MEAS message by checking bit 3 (calibTtagValid)
        in the'flags' attribute.

        :param kwargs: optional payload key/value pairs
        :return: dictionary representing payload definition
        :rtype: dict
        :raises: UBXMessageError

        """
        # pylint: disable=no-self-use

        if "flags" in kwargs:
            flags = kwargs["flags"]
        elif "payload" in kwargs:
            flags = kwargs["payload"][4:6]
        else:
            raise ube.UBXMessageError(
                "ESF-MEAS message definitions must include flags or payload keyword"
            )
        calibTtagValid = get_bits(flags, 0b00001000)  # get bit 3 in flags
        if calibTtagValid:
            pdict = ubg.UBX_PAYLOADS_GET["ESF-MEAS-CT"]
        else:
            pdict = ubg.UBX_PAYLOADS_GET["ESF-MEAS"]
        return pdict
Esempio n. 2
0
 def testgetbits(self):
     INPUTS = [(b'\x89', 192), (b'\xc9', 3), (b'\x89', 9), (b'\xc9', 9),
               (b'\x18\x18', 8), (b'\x18\x20', 8)]
     EXPECTED_RESULTS = [2, 1, 9, 9, 1, 0]
     for i, (vb, mask) in enumerate(INPUTS):
         vi = get_bits(vb, mask)
         self.assertEqual(vi, EXPECTED_RESULTS[i])