usb communication with c++

kindly help me to get data from the uno to my lap working on ubuntu 12.04. i am creating a program interfacing a camera in c++. i want to include a segment ie to get data from uno and use it manipulate the configurations of camera.kindly help...

The Arduino Uno creates a (virtual) serial port on the PC.
That serial port is used to upload a sketch and also to read from and write to the Arduino Uno.

There are many ways to use that serial port on the PC, for example in C++ but also the command line and some use python.

ok..thanks for the help :)..i have tried the following..
configured baudrate in terminal by

stty -F /dev/ttyACM0 9600

then i created a c++ program(exp.cpp) in my computer

#include
#include
#include
using namespace std;
int main()
{
string str;
fstream f;
f.open("/dev/ttyACM0");
while(1)
{
while (f >> str)
{
cout << str;
}
}
return 0;
}

and uploaded this program into arduino uno

int led = 13;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}

void loop()
{
digitalWrite(led, HIGH);
Serial.write("led");
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}

finally compiled the exp.cpp and got nothing...please consider me as newbie to usb communication

well i changed the c++ program as

#include
#include
using namespace std;
int main()
{
char ch;
ifstream f;
f.open("/dev/ttyACM0");

while (f.get(ch))
{
cout << ch;
}
return 0;
}

when i compile the program i get

naaeemuzz@naaeemuzz-Satellite-L655:~/project/samples$ ./samplesled
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
naaeemuzz@naaeemuzz-Satellite-L655:~/project/samples$

and this happens in split of a second and stops.i actually wanted an output similar to that of serial monitor..ie whenever the led blinks and shows out:"led" and else it does not....so what should i do??

The Uno keeps sending "led" every 2 seconds. I think that part is good.

Your program on PC ends when there is nothing to receive.
Perhaps you can test if a keyboard button is pressed to end the program.

What kind of compiler do you use for the PC program ?

i use g++ compiler...i compiled through terminal...lemme try about what you told...

i programmed cpp file as when it gets input "1",it shows output from uno,still the program stopes in 2 sec.. :frowning:

I tried to make a program in C++.
But it is not reading /dev/ttyACM0. I get a lot of EOF, and nothing else.

so what do u suggest??

I'm sorry, but I don't know. :~
I wanted to test the communication, but somehow I am not receiving anything with my c++ program.
I have not made a c++ program on the PC for the serial port before.
Normal programs like gtkterm can communicate without problem.

A quick search on google found these candidates:

I have not used them, but you can give them a try.

well thanx for your support...when i searched in stackoverflow.com i got a solution perfectly working...problem was the part where i configured baudrate..
i used

stty -F /dev/ttyACM0 sane raw pass8 -echo -hupcl clocal 9600

this works well
source:linux - Two-way C++ communication over serial connection - Stack Overflow