c++ - Executing a command shell from popen and set other command shell -


I am working with Quadroਟਰ and Mavalink in a project. I have successfully installed mavproxy in my Ubuntu PC and have run it without problems from the terminal. When I run mavproxy.py from the terminal and connects to a square robot with support for MVLC (APM autoplot), then detects the Mawproxy Quadrotor and everything is fine.

When you execute mavproxy.py , the program starts sending and receiving many parameters in the terminal. You can write some parameters in the terminal to use for any configuration. For example, in the terminal, help command:

  $ mavlink.py. Data donor Fixed & gt; "When the program terminates configuration, you are allowed to input any parameters, for example," STABILIZE &   

I have mavlink.py Has a code to execute from C ++

 include  & lt; Iostream & gt; Include & lt; Stdio.h & gt; using namespace std; Int main () {FILE * in; Four buff [512]; If (! (In = popen ("mavlink.py", "r"))) {return1; } While (fgets (in fond, size (fond))! = Null) {cout & lt; & Lt; Fond } Pckloc (In); Return 0; }   

When I run this C ++ program the terminal shows only one that will appear if I was running mavproxy.py from the terminal, but I do not know how I can send commands like help in C ++ code

If you read the program, the while the statement allows me to capture mavproxy.py and cout The parameter generated, but mavlink.py does not end at any time unless you type something in the terminal exits or press CTRL + C So that while the loop does not end.

I am reading about the popping function, but I have not got the right form to do this.

I know that I can use the mavlink.h library in my program and send the parameter to the square controller, but not mavlink.h want to do this.

I'm not sure I understand your question, but I think you Read the output along with sending the command to mavlink.py .

If so, you have to change the open mode of popen () to " r " to " w "So that you can write, then you can send commands like this:

  FILE * fp; Char * command = "HELP"; If (! (Fp = popen ("mavlink.py", "w"))) {return1; Filitt (command, size (four), strangel (command), fp);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -