UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
212 Views
Registered: ‎10-12-2018

XSCT error in pseudo terminal (pty)

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:

  • 5.0.0-32-generic # 34~18.04.2-Ubuntu SMP Thu Oct 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
0 Kudos
2 Replies
Moderator
Moderator
140 Views
Registered: ‎10-06-2016

Re: XSCT error in pseudo terminal (pty)

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


Ibai
Don’t forget to reply, kudo, and accept as solution.
Explorer
Explorer
101 Views
Registered: ‎10-12-2018

Re: XSCT error in pseudo terminal (pty)

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

 

0 Kudos