简体   繁体   中英

Controlling a program on one Raspberry Pi from a separate Raspberry Pi c++

I have two Pis that will run an identical program. I want to be able to control a second pi with the Controlling Pi using an ethernet cable and TCP. I will be inputting a number to start the code once the connection between the Pis is established, and I want that number to be input on both machines so the code begins running at the same time. Once the code completes I want the second Pi to send the value it calculates back to the first Pi.

The value sent from the "Controlling Pi" to the second pi will be a 1 digit number. The value sent from the second pi to the Controlling Pi will be a 2 or 3 digit number.

This is the first time I've ever worked with a device communication, so my question is can I use normal TCP protocols or will that not work due to the fact I need to run the code on both machines?

The code below is the data that will be sent from the Controlling Pi. The algorithm that each Pi runs is fully functional, I just need a way to trigger it at the same time and then send the data from one pi to the other. Thanks for the help.

cout << "Have patient move eyes to Left, Type: 1, Press enter";
cin >> Step;

A Raspberry-Pi is nothing more than a (mini) Linux machine. You can communicate between them using sockets. There are plenty of tutorials on this. Make sure you change the default nane of the Raspberry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM