Beispiel #1
0
    def get_reg_values(self, reg_values_single, ip):
        self.upload_tool(ip=ip)
        scp = SCP(ip, 22)
        scp.connect_noPassword()

        for command in self.commands:
            # command = command.strip()
            stdin, stdout, stderr = scp.write(command)
            out = stdout.readline().strip()
            # print("out:"+out)
            logging.debug("get respond => %s" % out)
            if not self.check_items[command]:
                pass
            elif self.check_items[command] == "LAST2BIT":
                logging.debug('get binary value => %s' % bin(int(out, 16)))
                reg_values_single[command] = bin(int(out, 16))
                if repr(bin(int(out, 16)))[-3:-1] == '11':
                    logging.debug('Verification result => correct')
                else:
                    logging.debug('Verification result => wrong')
                    self.fail_flag = True
            elif self.check_items[command] == "CHECKLINK":
                reg_values_single[command] = out
                if out in ['0x00002860', '0x00000060', '0x00008060']:
                    logging.debug('Verification result => correct')
                else:
                    logging.debug('Verification result => wrong')
                    self.fail_flag = True
            else:
                reg_values_single[command] = out.split()[-1]
                if out.split()[-1] == self.check_items[command]:
                    logging.debug('Verification result => correct')
                else:
                    logging.debug('Verification result => wrong')
                    self.fail_flag = True
Beispiel #2
0
def download_runtime_log(path=None, log_name=None):
    print("Catching runtime log...")
    if path is None:
        current_path = os.path.dirname(os.path.realpath(__file__))
        folder = current_path
    else:
        folder = path
    time_current = time.strftime("%Y%m%d%H%M%S")
    beamer_ip = "192.168.101.1"

    try:
        scp = SCP(host=beamer_ip,
                  port=22,
                  username="******",
                  password="******")
        scp.connect()
        scp.write(
            f"/usr/bin/ccsShell.sh log -a -z runtime_{time_current}_{log_name}.zip"
        )
        time.sleep(30)
        scp.download(local_path=folder +
                     f"runtime_{time_current}_{log_name}.zip",
                     remote_path=f"/ram/runtime_{time_current}_{log_name}.zip",
                     mode='bin')
        scp.close()
    except:
        logger.error("Error occur when grab log from beamer!")
Beispiel #3
0
 def _scp_connect(self):
     self.scp = SCP('192.168.101.2', 22)
     self.scp.connect_noPassword()
     # create ssh with no password
     local = os.path.join(current_path, 'spiafe')
     remote = '/var/tmp/spiafe'
     self.scp.upload(local, remote)
    def JesdTest_singleIP(self, repeat, ip, row, col, summary):
        pass_times = 0
        fail_times = 0

        scp = SCP(ip, 22)
        scp.connect_noPassword()
        current_path = os.path.dirname(os.path.realpath(__file__))
        local = os.path.join(current_path, 'JesdTestItems/spiafe')
        remote = '/var/tmp/spiafe'
        scp.upload(local, remote)

        for i in range(repeat):
            get_wrong_value = self._read_values(row, col, scp, summary, ip)
            if get_wrong_value:
                self.fail_flag = True
                fail_times += 1
            else:
                pass_times += 1
            col += 1
            self.logger.info(f"{ip} read finished...get fail values {get_wrong_value}")
            time.sleep(1)
        scp.close()
        if "pass time" in summary[ip].keys():
            summary[ip]["pass time"] += pass_times
        else:
            summary[ip]["pass time"] = pass_times

        if "fail time" in summary[ip].keys():
            summary[ip]["fail time"] += fail_times
        else:
            summary[ip]["fail time"] = fail_times
Beispiel #5
0
 def upload_tool(self, ip):
     scp = SCP(ip, 22)
     scp.connect_noPassword()
     local = os.path.join(current_path, 'JesdTestItems/spiafe')
     remote = '/var/tmp/spiafe'
     scp.upload(local, remote)
     scp.close()
Beispiel #6
0
class JesdVerify(object):
    def __init__(self):
        self.UL_JESD_status_commands = [
            '/sbin/devmem 0xfc980270', '/sbin/devmem 0xfc980274',
            '/sbin/devmem 0xfc980278', '/sbin/devmem 0xfc980294',
            '/sbin/devmem 0xfc98027C', '/sbin/devmem 0xfc980280',
            '/sbin/devmem 0xfc980288', '/sbin/devmem 0xfc98028C',
            '/sbin/devmem 0xfc980290', '/sbin/devmem 0xfc98026C',
            '/sbin/devmem 0xfc980264', '/sbin/devmem 0xfc980268'
        ]

        self.UL_int_status_commands = [
            '/sbin/devmem 0xfc980094', '/sbin/devmem 0xfc980098',
            '/sbin/devmem 0xfc98009c', '/sbin/devmem 0xfc9800a0',
            '/sbin/devmem 0xfc9800a4', '/sbin/devmem 0xfc9800a8',
            '/sbin/devmem 0xfc9800ac', '/sbin/devmem 0xfc9800b0',
            '/sbin/devmem 0xfc9800b8', '/sbin/devmem 0xfc9800bc',
            '/sbin/devmem 0xfc9800c0', '/sbin/devmem 0xfc9800c4'
        ]

        self.reg_values = {'0x12a': 'AA', '0x12c': '55'}
        self.pass_times = 0
        self.fail_times = 0
        self.wb = Workbook()
        self.ws = self.wb.active
        # self.ws.title = "JesdVerify"

    def _scp_connect(self):
        self.scp = SCP('192.168.101.2', 22)
        self.scp.connect_noPassword()
        # create ssh with no password
        local = os.path.join(current_path, 'spiafe')
        remote = '/var/tmp/spiafe'
        self.scp.upload(local, remote)

    def _load_commands(self):
        self.commands = []
        row = 2
        with open(os.path.join(current_path, "JESDCommands.txt"), 'r') as f:
            lines = f.readlines()
        for line in lines:
            if not line.startswith('#'):
                self.commands.append(line.strip())
                command_to_write = re.search(r'/dev/spidev.*$', line)
                if command_to_write:
                    _ = self.ws.cell(column=1,
                                     row=row,
                                     value=command_to_write.group().strip())
                else:
                    _ = self.ws.cell(column=1, row=row, value=line.strip())
                row += 1
        # self.wb.save(filename='JesdVerify.xls')

    def _scp_close(self):
        self.scp.close()

    def _read_values(self, col):
        row = 2
        for command in self.commands:
            # logging.info(f'run command {command}')
            stdin, stdout, stderr = self.scp.write(command)
            out = stdout.readline().strip()
            logging.info("get respond => %s" % out)
            command = command.strip()
            # logging.info(stderr.readline())
            # check with 0xfc90010c
            if command == '/sbin/devmem 0xfc90010c':
                _ = self.ws.cell(row=row, column=col, value=out)
                if out == '0xFFFFFFFF':
                    logging.info('Verification result => correct')
                else:
                    logging.info('Verification result => wrong')
                    self.test_result = 'FAIL'
                    _.font = Font(color='00FF0000')

            elif command in self.UL_JESD_status_commands:
                logging.info('get binary value => %s' % bin(int(out, 16)))
                _ = self.ws.cell(row=row, column=col, value=bin(int(out, 16)))
                if repr(bin(int(out, 16)))[-3:-1] == '11':
                    logging.info('Verification result => correct')
                else:
                    self.test_result = 'FAIL'
                    logging.info('Verification result => wrong')
                    _.font = Font(color='00FF0000')

            elif command in self.UL_int_status_commands:
                _ = self.ws.cell(row=row, column=col, value=out)
                if out in ['0x00002860', '0x00000060']:
                    logging.info('Verification result => correct')
                else:
                    self.test_result = "FAIL"
                    logging.info('Verification result => wrong')
                    _.font = Font(color='00FF0000')

            # write values
            # should return Register to write 0015 with value 02
            elif re.search(r'-w .* -v .*', command):
                _ = self.ws.cell(row=row, column=col, value=out)
                if out.startswith('Register to write'):
                    logging.info('write value successfully')
                else:
                    logging.info('write value falied')
                    self.test_result = 'FAIL'
                    _.font = Font(color='00FF0000')
            # read values
            #  should return Value from 012A is: AA
            elif re.search(r'-r .*', command):
                reg = re.search(r'-r .*', command).group()[-5:]
                _ = self.ws.cell(row=row, column=col, value=out[-2:])
                if out[-2:] == self.reg_values[reg]:
                    logging.info('Verification result => correct')
                else:
                    self.test_result = 'FAIL'
                    logging.info('Verification result => wrong')
                    _.font = Font(color='00FF0000')
            else:
                # logging.info("Invalid command!")
                _ = self.ws.cell(row=row, column=col, value=out)
                _.font = Font(color='00FF0000')
            row += 1

    def JesdTest(self, REPEAT):
        self.test_result = 'PASS'
        try:
            self._load_commands()
            self._scp_connect()
            col = 2
            for i in range(REPEAT):
                self._read_values(col)
                col += 1
                if self.test_result == 'PASS':
                    self.pass_times += 1
                else:
                    self.fail_times += 1
                time.sleep(3)

            logging.info('JESD TEST RESULT => ' + self.test_result)
            logging.info('#' * 100)

        except Exception as e:
            logging.info(msg=e)
            logging.info('error: ', e)

        self._scp_close()
        self.ws.cell(row=1, column=1, value="Test loops:" + str(REPEAT))
        self.ws.cell(row=1,
                     column=2,
                     value="PASS: "******" FAIL: " +
                     str(self.fail_times))
        current_path = os.path.dirname(os.path.realpath(__file__))
        self.wb.save(filename=os.path.join(
            current_path, 'JesdLogAndResults/JesdVerify.xlsx'))