Brief Question:

I am working on a project that requires me to execute a C++ program on my laptop, and, the result of the program will determine the actions of the Raspberry Pi, which is triggered using some Python code. But, I need a way to connect the Pi to my laptop, and sending a byte of data across to the pi (hopefully in real-time) but how would I do this?

Detailed description

I have a C++ program, which, I execute through the use of a web page (that is stored on localhost). I execute a command, the program then returns a byte of information usually either "1" or "0" which I am hoping to send to the pi. The pi will execute python code, when the result from the C++ program is given, the code will then perform different actions. I do not want to use sockets, web or not. The main problem is the fact I am doing this away from my home, so, IP addresses and firewalls are very limited. I was thinking that if I had a file on the pi, and when the C++ program executes, it updates the file on the pi with either a "0" or "1" and in the python code (on the pi) just have a while (true)statement which keeps reading the value from the file. I don't mind about polling it too much, because, it's only a very short demonstration.

I hope someone can offer atleast some help with this, as it's confusing me a lot.


  • 2
    You have ethernet as a tag, but you say "I do not want to use sockets". If you meant you want to connect to the pi over the ethernet without sockets, that's impossible. The ethernet is sockets; if you don't want to use sockets, then you don't want to use the ethernet. – goldilocks Mar 23 '13 at 13:44
  • Using files in this way as a path for communication is not a good idea. Use sockets. Its easy. – Ber Apr 8 '13 at 8:18

You could take a look at this cable from Adafruit: http://www.adafruit.com/products/954

It is a USB to TTL serial cable which allows you to connect serial communication to the Pi's GPIO pins. You would then need to find a way of communicating via serial from your C++ program . This is similar to the way in which an Arduino communicates to a laptop or PC so you may find some help from the Arduino community's methods.

  • +1. Serial communication between OS X & Raspberry Pi was a lot easier than I thought it would be. Thanks to the Arduino community. – emcconville Mar 22 '13 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.