这里是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程序中?)
我使用:
- 5.0.0-32-通用#34〜18.04.2-Ubuntu SMP 10月10日10:36:02 UTC 2019 x86_64 x86_64 x86_64 GNU / Linux
- Python 3.6.8
- pexpect == 4.2.1
- Vivado 2017.4