Пример #1
0
    def check_message(self, received_msg, expected_msg, retry: int, msg_index: int) -> (bool, str):
        if len(received_msg.decoded_bits) == 0:
            return False, "Failed to decode message {}".format(msg_index)

        for lbl in received_msg.message_type:
            if lbl.value_type_index in (1, 4):
                # get live, random
                continue

            start_recv, end_recv = received_msg.get_label_range(lbl.label, 0, True)
            start_exp, end_exp = expected_msg.get_label_range(lbl.label, 0, False)

            if isinstance(lbl.label, ChecksumLabel):
                expected = lbl.label.calculate_checksum_for_message(received_msg, use_decoded_bits=True)
                start, end = received_msg.get_label_range(lbl.label, 0, True)
                actual = received_msg.decoded_bits[start:end]
            else:
                actual = received_msg.decoded_bits[start_recv:end_recv]
                expected = expected_msg[start_exp:end_exp]

            if actual != expected:
                log_msg = []
                log_msg.append("Attempt for message {} [{}/{}]".format(msg_index, retry + 1,
                                                                       self.project_manager.simulator_retries))
                log_msg.append(HTMLFormatter.indent_string("Mismatch for label: <b>{}</b>".format(lbl.name)))
                expected_str = util.convert_bits_to_string(expected, lbl.label.display_format_index)
                got_str = util.convert_bits_to_string(actual, lbl.label.display_format_index)
                log_msg.append(HTMLFormatter.align_expected_and_got_value(expected_str, got_str, align_depth=2))
                return False, log_msg

        return True, ""
Пример #2
0
    def check_message(self, received_msg, expected_msg, retry: int, msg_index: int) -> (bool, str):
        if len(received_msg.decoded_bits) == 0:
            return False, "Failed to decode message {}".format(msg_index)

        for lbl in received_msg.message_type:
            if lbl.value_type_index in (1, 4):
                # get live, random
                continue

            start_recv, end_recv = received_msg.get_label_range(lbl.label, 0, True)
            start_exp, end_exp = expected_msg.get_label_range(lbl.label, 0, False)

            if isinstance(lbl.label, ChecksumLabel):
                expected = lbl.label.calculate_checksum_for_message(received_msg, use_decoded_bits=True)
                start, end = received_msg.get_label_range(lbl.label, 0, True)
                actual = received_msg.decoded_bits[start:end]
            else:
                actual = received_msg.decoded_bits[start_recv:end_recv]
                expected = expected_msg[start_exp:end_exp]

            if actual != expected:
                log_msg = []
                log_msg.append("Attempt for message {} [{}/{}]".format(msg_index, retry + 1,
                                                                       self.project_manager.simulator_retries))
                log_msg.append(HTMLFormatter.indent_string("Mismatch for label: <b>{}</b>".format(lbl.name)))
                expected_str = util.convert_bits_to_string(expected, lbl.label.display_format_index)
                got_str = util.convert_bits_to_string(actual, lbl.label.display_format_index)
                log_msg.append(HTMLFormatter.align_expected_and_got_value(expected_str, got_str, align_depth=2))
                return False, log_msg

        return True, ""
Пример #3
0
    def log_message_labels(self, message: Message):
        message.split(decode=False)
        for lbl in message.message_type:
            if not lbl.logging_active:
                continue

            try:
                data = message.plain_bits[lbl.start:lbl.end]
            except IndexError:
                return None

            lsb = lbl.display_bit_order_index == 1
            lsd = lbl.display_bit_order_index == 2

            data = util.convert_bits_to_string(data, lbl.display_format_index, pad_zeros=True, lsb=lsb, lsd=lsd)
            if data is None:
                continue

            log_msg = lbl.name + ": " + HTMLFormatter.monospace(data)
            self.log_messages.append(HTMLFormatter.indent_string(log_msg))
Пример #4
0
    def log_message_labels(self, message: Message):
        message.split(decode=False)
        for lbl in message.message_type:
            if not lbl.logging_active:
                continue

            try:
                data = message.plain_bits[lbl.start:lbl.end]
            except IndexError:
                return None

            lsb = lbl.display_bit_order_index == 1
            lsd = lbl.display_bit_order_index == 2

            data = util.convert_bits_to_string(data, lbl.display_format_index, pad_zeros=True, lsb=lsb, lsd=lsd)
            if data is None:
                continue

            log_msg = lbl.name + ": " + HTMLFormatter.monospace(data)
            self.log_messages.append(HTMLFormatter.indent_string(log_msg))