11-10-2019 02:21 AM
Here is a so post about this issue. I didn't get an answer.
Here is a sample wrapper for Xilinx's XSCT console. (It just echoes the XSCT answer to the console and give the commands to the 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
My problem is that the answers form the XSCT are misaligned, or never arrived. Here is a snippet:
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%
While I started XSCT natively it works as expected:
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%
What do I do wrong?
(I have tried to change the executable in the wrapper from xsct to bash, then it works as expected.)
I use:
11-14-2019 08:40 AM
Hi @betontalpfa
I'm not sure how does work python when creating a subprocess and neither XSCT as doing really but maybe you might want to try using xsdbserver instead. Basically you can launch XSDB server with a TCP opened to process commands and use Python as front end.
Regards
11-18-2019 05:50 AM
Thanks @ibaie
I have create a simple python wrapper called pysct on github (based on your reply).
Here is an example code:
import pysct
win_xsct_executable = r'C:\Xilinx\SDK\2017.4\bin\xsct.bat'
xsct_server = XsctServer(win_xsct_executable, port=PORT, verbose=False)
xsct = Xsct('localhost', PORT)
print("xsct's pid: {}".format(xsct.do('pid')))
print(xsct.do('set a 5'))
print(xsct.do('set b 4'))
print("5+4={}".format(xsct.do('expr $a + $b')))
xsct.close()
xsct_server.stop_server()
Prints out:
xsct's pid: 13808 5 4 5+4=9