hi, all,
I am using the new uefi, it use the cursor movement and the Enter to enter the entry.
So I use the config file to write it, but I found it can not work well. the config is below.
boot_cmds_ramdisk_sata = expect "Move Highlight", sendline "\033[B", sendline "\033[B", sendcontrol "M", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendcontrol "M", expect "D02", sendline "provision {SERVER_IP} -u htsat -p hello8943217 -f Image_D02 -a 10000", expect "succ" , sendline "norwfmem 100000 100000 1f00000", expect "OK", sendline "provision {SERVER_IP} -u htsat -p hello8943217 -f hip05-d02.dtb -a 100000", expect "succ", sendline "spiwfmem 100000 300000 100000", expect "OK", expect "OK", sendline "exit", expect "Select Language", sendline "\033[B", sendline "\033[B", sendcontrol "M", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendline "\033[B", sendcontrol "M"
After I read the source code of LAVA. I found it use the pexpect.spawn to interact with the terminal, So I directly writte a python file to directly use spawn to interact with the terminal, and it can work well . The source code is below.
import sys from pexpect import spawn
child = spawn("board_connect 2") # this is similar with minicom logfile = "/tmp/test_for_terminal.log" fd = open(logfile, 'a+') child.logfile = fd child.expect("to stop automatical booting", timeout=120) child.sendline("b") child.expect("Move Highlight") ## boot from sata child.sendline("\033[B") child.sendline("\033[B") child.sendcontrol("M") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendcontrol("M") child.expect("D02") child.sendline("provision 192.168.6.100 -u htsat -p hello8943217 -f Image_D02 -a 10000") child.expect("succ") child.sendline("norwfmem 100000 100000 1f00000") child.expect("OK") child.sendline("provision 192.168.6.100 -u htsat -p hello8943217 -f hip05-d02.dtb -a 100000") child.expect("succ") child.sendline("spiwfmem 100000 300000 100000") child.expect("OK") child.expect("OK") #child.interact() child.sendline("exit") child.expect("Select Language") child.sendline("\033[B") child.sendline("\033[B") child.sendcontrol("M") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendline("\033[B") child.sendcontrol("M") child.interact()
So I don't know why in LAVA it can not work. Also I have realized a function named /sendcursor /similar with the sendcontrol in the lava_dispatcher package especially in the /usr/lib/python2.7/dist-package/lava_dispatcher/utils.py, and it call the pexpect.spawn.sendline to send contents to the child process. But it still have the same phenomenon with using sendline(namely won't select the entry in the uefi menu). Does this problem is caused by the dashboard showing?
The attached files are the log files when I use the python file to execute the interaction and the one when LAVA execute it. Thanks for your help.
Elaine Hisilicon turing software and architecture
On 8 April 2016 at 10:21, Elaine Wu (wuyanjun) wu.wu@hisilicon.com wrote:
hi, all,
I am using the new uefi, it use the cursor movement and the Enter to enter the entry.
So I use the config file to write it, but I found it can not work well. the config is below.
boot_cmds_ramdisk_sata = expect "Move Highlight", sendline "\033[B",
We have sendcontrol to avoid problems with escaping characters because the device commands need to be mapped into python from a config file and this process can result in a mismatch between the script in the config file (not python) and the actual command sent to pexpect.
After I read the source code of LAVA. I found it use the pexpect.spawn to interact with the terminal, So I directly writte a python file to directly use spawn to interact with the terminal, and it can work well . The source code is below.
import sys from pexpect import spawn
The commands in the config file need to be of a form that results in the string below being processed by python.
child.sendline("\033[B") child.sendcontrol("M")
So I don't know why in LAVA it can not work.
It is a similar problem to quote handling in a shell script - there is another process between the commands in the configuration file and the expression of those commands to the python functions.
Also I have realized a function named sendcursor similar with the sendcontrol in the lava_dispatcher package especially in the /usr/lib/python2.7/dist-package/lava_dispatcher/utils.py, and it call the pexpect.spawn.sendline to send contents to the child process. But it still have the same phenomenon with using sendline(namely won't select the entry in the uefi menu).
I'd have to see the patch to go further with that. It should be possible to create a sendcursor command which takes a movement string and maps that to the correct sendline operation - as long as the escape characters are not in the config and are inserted directly from the python code.
However, that is unlikely to be supportable in LAVA V1 - it would need to be V2 support.
Alternatively, move this entire problem into a different area by fixing the position of the item you need from the menu at the top of the menu and remove the need for any cursor movement.
Another alternative was already discussed - interacting with the device outside the menu, e.g. using Grub.
hi, all,
I just found a way to support the cursor movement in the device config file.
It use the below commands.
sendcontrol "[", sendline "[B",
These two lines will equal the 'child.sendline("\033[B")' in the python codes.
Now it can work well.
Thanks your reply
Elaine
On 2016/4/12 16:36, Neil Williams wrote:
On 8 April 2016 at 10:21, Elaine Wu (wuyanjun) wu.wu@hisilicon.com wrote:
hi, all,
I am using the new uefi, it use the cursor movement and the Enter to enter the entry.
So I use the config file to write it, but I found it can not work well. the config is below.
boot_cmds_ramdisk_sata = expect "Move Highlight", sendline "\033[B",
We have sendcontrol to avoid problems with escaping characters because the device commands need to be mapped into python from a config file and this process can result in a mismatch between the script in the config file (not python) and the actual command sent to pexpect.
After I read the source code of LAVA. I found it use the pexpect.spawn to interact with the terminal, So I directly writte a python file to directly use spawn to interact with the terminal, and it can work well . The source code is below.
import sys from pexpect import spawn
The commands in the config file need to be of a form that results in the string below being processed by python.
child.sendline("\033[B") child.sendcontrol("M") So I don't know why in LAVA it can not work.
It is a similar problem to quote handling in a shell script - there is another process between the commands in the configuration file and the expression of those commands to the python functions.
Also I have realized a function named sendcursor similar with the sendcontrol in the lava_dispatcher package especially in the /usr/lib/python2.7/dist-package/lava_dispatcher/utils.py, and it call the pexpect.spawn.sendline to send contents to the child process. But it still have the same phenomenon with using sendline(namely won't select the entry in the uefi menu).
I'd have to see the patch to go further with that. It should be possible to create a sendcursor command which takes a movement string and maps that to the correct sendline operation - as long as the escape characters are not in the config and are inserted directly from the python code.
However, that is unlikely to be supportable in LAVA V1 - it would need to be V2 support.
Alternatively, move this entire problem into a different area by fixing the position of the item you need from the menu at the top of the menu and remove the need for any cursor movement.
Another alternative was already discussed - interacting with the device outside the menu, e.g. using Grub.