Ejemplo n.º 1
0
def buf_print(buf):
    buf_len = len(buf)
    i = 0

    print bsp_system.get_time_stamp(),
    while i < buf_len:
        print "%02X" % (ord(buf[i])),  #ord  char2int
        i = i + 1
    print " "
Ejemplo n.º 2
0
def analysis_cmd(str):
    global total_num
    global fail_times

    i = 0
    str_len = len(str)
    cmd1 = ord(str[3])
    if cmd1 != 0x07:
        return

    node1_id = ord(str[6])
    node2_id = ord(str[10])
    node1_on_off_line = ord(str[7])
    node2_on_off_line = ord(str[11])

    node_id_detect = 0x21
    node_if_detect = 'Y'
    node_on_off_line_detect = 0x00

    print bsp_system.get_time_stamp(),
    while i < str_len:
        print "%02X" % (ord(str[i])),  #ord  char2int
        i = i + 1

    if node1_id == node_id_detect:
        node_on_off_line_detect = node1_on_off_line
    elif node2_id == node_id_detect:
        node_on_off_line_detect = node2_on_off_line
    else:
        node_if_detect = 'N'
        print " "
        return

    total_num = total_num + 1
    if node_on_off_line_detect == 0x00:
        fail_times = fail_times + 1
        print "\033[1;35m",
        print "[F],total_num = %05d,fail_times = %05d" % (total_num,
                                                          fail_times),
        print "\33[0m"
    else:
        print " [T],total_num = %05d,fail_times = %05d" % (total_num,
                                                           fail_times)
    def analysis_cmd(self, str):
        i = 0
        str_len = len(str)
        cmd1 = ord(str[FRAME.CMD])

        print bsp_system.get_time_stamp(),

        if cmd1 == 0x08:
            print "\033[1;34m>> \033[0m",
            self.auto = self.PROCESS2

        if cmd1 == 0x09:
            print "\033[1;35m>< \033[0m",
            self.auto = self.FINISH

        while i < str_len:
            print "%02X" % (ord(str[i])),  #ord  char2int
            i = i + 1

        print " "
Ejemplo n.º 4
0
def analysis_cmd2(str):
    global total_num
    global fail_times

    i = 0
    str_len = len(str)
    cmd1 = ord(str[3])
    if cmd1 != 0x07:
        return

    node1_id = ord(str[6])
    node2_id = ord(str[10])
    node1_flag = ord(str[9])
    node2_flag = ord(str[13])
    node1_on_off_line = ord(str[7])
    node2_on_off_line = ord(str[11])

    have_off_line = 0

    if (node1_flag == 0xFF and node1_on_off_line == 0x00) or \
            (node2_flag == 0xFF and node2_on_off_line == 0x00):
        have_off_line = 1

    print bsp_system.get_time_stamp(),
    while i < str_len:
        print "%02X" % (ord(str[i])),  #ord  char2int
        i = i + 1

    total_num = total_num + 1
    if have_off_line == 1:
        fail_times = fail_times + 1
        print "\033[1;35m",
        print "[F],total_num = %05d,fail_times = %05d" % (total_num,
                                                          fail_times),
        print "\33[0m"
    else:
        print " [T],total_num = %05d,fail_times = %05d" % (total_num,
                                                           fail_times)