下面是Xilinx的XSCT控制台的包装示例。(它只是将XSCT应答回显到控制台并向XSCT发出命令)
#xsct_wrapper.py
import sys
import os
import re
import pexpect
# Path of Xilinx'XSCT executable:
xsct = '/opt/Xilinx/Vivado/2017.4/bin/xsdb'
prompt = '% '
# Start XSCT
p = pexpect.spawn(xsct)
# Wait for prompt
p.expect(prompt, timeout = 5)
# print the texts
print(p.before.decode(), end='')
print(p.match.group(0).decode(), end='')
while True:
# Wait and run a command.
command = input()
p.sendline(command)
try:
# Wait for prompt
p.expect(prompt)
# print the texts
print(p.before.decode(), end='')
print(p.match.group(0).decode(), end='')
except pexpect.EOF:
# The program has exited
print('The program has exied... BY!')
break
我的问题是,XSCT的答案没有对齐,或者根本就没有到达。下面是一个片段:
PC:~$ python3 xsct_wrapper.py
rlwrap: warning: your $TERM is 'xterm-256color' but rlwrap couldn't find it in the terminfo database. Expect some problems.
****** Xilinx System Debugger (XSDB) v2017.4
**** Build date : Dec 15 2017-21:02:16
** Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
xsdb% puts hello
xsdb% ((I hit enters here...))
xsdb%
xsdb% ello
xsdb%
虽然我以本机方式启动xsct,但它的工作方式与预期一致:
PC:~$ /opt/Xilinx/Vivado/2017.4/bin/xsdb
rlwrap: warning: your $TERM is 'xterm-256color' but rlwrap couldn't find it in the terminfo database. Expect some problems.
****** Xilinx System Debugger (XSDB) v2017.4
**** Build date : Dec 15 2017-21:02:16
** Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
xsdb% puts hello
hello
xsdb%
我做错了什么?
(我已经尝试将包装器中的可执行文件从xsct
更改为bash
,然后它会按预期工作。缺陷是否位于XSCT程序中?)你知道吗
我使用:
目前没有回答
相关问题 更多 >
编程相关推荐