Ejemplo n.º 1
0
def calc_busload(single_test):
    messages = single_test.dbc.messages
    b11 = 47
    b29 = 65
    bitr = int(single_test.cnf['baudrate'])
    overhead = (b11 if single_test.cnf['id_size'] == 'Force 11 bits' else b29)
    auto_size = False
    if single_test.cnf['id_size'] == 'Auto':
        auto_size = True
    sum_message_load = 0.0
    message_count = 0.0
    bit_stuff = int(single_test.cnf['bit_stuffing']) / 100
    output_list = []
    output_not_used_list = []
    output_ignored = []
    message_time = 0

    for message in messages:
        message_time = 0
        message_load = 0
        if message.name not in single_test.erase_message:
            if message.cycle > 0:
                ml = message.size
                if auto_size:
                    overhead = (b11 if int(message.id) < 2100 else b29)
                message_time = ((ml * 8 + overhead) +
                                ((ml * 8 + overhead - 13) * bit_stuff)) / bitr
                message_load = (message_time / message.cycle)
                sum_message_load += message_load
                message_count += 1
                output_list.append(
                    MessageOut(message.name, message.id, message.size,
                               message.cycle, message_time, message_load))
                event_log(output_list[-1])
            else:
                output_not_used_list.append(
                    MessageOut(message.name, message.id, message.size,
                               message.cycle, message_time, message_load))
                event_log(output_not_used_list[-1])
        else:
            # eventLog("[-] message %s doesn't used in busload calc" % message.name)
            output_not_used_list.append(
                MessageOut(message.name, message.id, message.size,
                           message.cycle, message_time, message_load))
            event_log(output_not_used_list[-1])

    result = Statistic(sum_message_load * 100, message_count, len(messages))

    result_output = [output_list, output_not_used_list, result, output_ignored]
    event_log('---> busload: %0.6f' % sum_message_load, single_test)
    single_test.result = result_output
Ejemplo n.º 2
0
    def __init__(self, config, module):
        self.config = config
        self.module = module
        self.handlers = None
        self.log = None
        self.__setup_log(module)
        self.user_log_bytes = 0

        self.message_out = MessageOut(self.module, self.config)

        ## flush stdout to avoid out of order logging
        sys.stdout.flush()
Ejemplo n.º 3
0
    def __init__(self, config, module):
        self.config = config
        self.module = module
        self.handlers = None
        self.__setup_log(module)
        self.user_logger_enabled = False
        self.user_log_bytes = 0
        self.header_params = None

        self.message_out = MessageOut(self.module, self.config)

        self.console_buffer = []
        self.console_buffer_lock = threading.Lock()

        ## flush stdout to avoid out of order logging
        sys.stdout.flush()