Search found 4 matches

by rockindy
Wed Apr 29, 2020 6:38 am
Forum: Programs, Libraries and Tools
Topic: I can’t interact with micropython by Popen
Replies: 10
Views: 660

Re: I can’t interact with micropython by Popen

Sorry, I think I misunderstood dhylands' post. The correct understanding is: if (ret == NOTHING_EXECUTED || inspect) { - if (isatty(0)) { + if (isatty(0) || inspect) { prompt_read_history(); With this patch, it should work as excepted. Thank you @dhylands and @Christian Walther .
by rockindy
Tue Apr 28, 2020 3:05 am
Forum: Programs, Libraries and Tools
Topic: I can’t interact with micropython by Popen
Replies: 10
Views: 660

Re: I can’t interact with micropython by Popen

In the current code, once you redirect stdin, it won't call do_repl().

And I don't know how to tell the redirection is from '<' or from Popen.

My suggestion is once you set -i flag, it will always call do_repl().

And if you want to run script from a file, just use '<' without -i flag.
by rockindy
Mon Apr 27, 2020 3:52 am
Forum: Programs, Libraries and Tools
Topic: I can’t interact with micropython by Popen
Replies: 10
Views: 660

Re: I can’t interact with micropython by Popen

Hi, Thanks for your replies. I want to let user interacts with MicroPython REPL via gui widget, so I need to pipe the stdin/stdout. @Christian Walther your way works but can only write the stdin once. Finally I found a way to do it. For whom encountered the same problem, you can modify the main.c of...
by rockindy
Fri Apr 24, 2020 3:18 am
Forum: Programs, Libraries and Tools
Topic: I can’t interact with micropython by Popen
Replies: 10
Views: 660

I can’t interact with micropython by Popen

Hi, I tried to use Popen of python2/3 to interact with micropyton unix port, but will be blocked by proc.stdout.readline() function: proc = subprocess.Popen(['./micropython', '-i'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc.stdin.write(b'2+2\n') proc.stdin.flush() p...