- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Im trying to issue a set of commands to my nios using the jtag-uart. I can open up the command shell, type nios2-terminal, issue my command and then type ctrl-c and close the terminal. I can repeat this as often as needed. Now, Im trying to automate it using python: from winpexpect import winspawn import time SC=winspawn("C:/altera/13.0/nios2eds/Nios_II_Command_Shell.bat") SC.expect('$') SC.sendline('nios2-terminal') time.sleep(5) SC.sendline('deadbeef;') this works fine. But my problem comes when i try to send the crtl-c Winpexpect does have a send control function, so when i send SC.sendcontrol('c') the nios2-terminal just doesnt stop. It will stay connected and then not allow other connections to be made So, my question is : Is there a command line equivalent to "nios2-terminal deadbeef ctrl-c" such that i can just send the line and have nios2-terminal automatically close its session so i can open others later? thanks!Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok, figured this out and wanted to post it for others...
from a search on SF, the send control function might not work as expected. So the guy recommended that the poster use just send send('\003') instead of sendcontrol('c'). '\003' being the ascii for cntrl c so i tried that. didnt work. then i saw another mention on these forums that to escape nios2-terminal, i actually need to send a cntrl-D so i tried that. no luck then i sent another couple of sendline(deadbeefs) and tried to readline() well, in the response back from readline, i saw that nios2-terminal had closed in response to cntrl-d So the trick is.... after sending the cntrl-d ascii, i needed to "flush buffer" with a send line. I then modified the code to replace "SC.sendcontrol('c') to 'SC.sendline('\004') and bam, it worked so it should be: from winpexpect import winspawn import time SC=winspawn("C:/altera/13.0/nios2eds/Nios_II_Command_Shell.bat") SC.expect('$') SC.sendline('nios2-terminal') time.sleep(5) SC.sendline('deadbeef;') SC.sendline('\004') hope this helps someone!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had the same problem, but your solution did not work for me.
winpexpect has a close connection function that does the same operation as ctrl-c. I used SC.close() Thanks for post.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page