Ошибка при управлении Xilinx XSCT с pexpect - PullRequest
0 голосов
/ 06 ноября 2019

Вот пример оболочки для консоли Xilinx Xilinx. (Это просто повторяет ответ 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-generic # 34 ~ 18.04.2-Ubuntu SMP, четверг 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
...