3

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.

Thanks

Phorce
  • 623
  • 1
  • 8
  • 15

1 Answers1

6

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.

recantha
  • 4,489
  • 21
  • 26