Go Down

Topic: Help on reading serial data (Read 1 time) previous topic - next topic

hadriel26

Hi there,

I'm currently working on a AGV with Arduino Duemilanove + CMUcam 2 and am having some hard time trying to read serial data sent by the CMUcam. I succesfully managed to send serial data from the Arduino to the CMU-CAM, but reading is really hard. The camera sends back a data packet of this type: "T mx my x1 y1 x2 y2 pixels confidence\r", where "mx, my" and the rest are some numbers with informations I need to process.

The problem is: how do I isolate what I need in that packet and store them into variables? In my case, I need to get only the "mx" and "my" values, but the serial sends everything altogether.

Thanks!

PaulS

Quote
In my case, I need to get only the "mx" and "my" values, but the serial sends everything altogether.

The "serial" doesn't send anything. The camera does. It sends a stream of characters that presumably mean something to the receiver.

How are you reading/capturing that data now? The answer to that has a lot to do with how you then parse the data. If you are doing it right, storing the data in a char array, the strtok() and atoi() or atof() functions might be worth looking into.

hadriel26

Yeah, I know the serial doesn't send anything, but you got my point, hehe.

Right now I'm just storing the whole packet in a variable, but what I need is to 'filter' the packet and store only what I need, that is, the 'mx' and 'my' values. How can I get only these values and store 'em into separate buffers?

PaulS

Quote
Right now I'm just storing the whole packet in a variable, but what I need is to 'filter' the packet and store only what I need, that is, the 'mx' and 'my' values. How can I get only these values and store 'em into separate buffers?

That depends on the type of the variable that you are currently storing the data in.

PGT

#4
Oct 03, 2012, 05:29 pm Last Edit: Oct 03, 2012, 05:30 pm by PGTBOOS Reason: 1
Just curious how do you want to store a RGB like image of a cam on a arduino, or what would you like to do with the received data.
Because I mean even a small cam lets say (800 x 600 pixels x 3 colors) requires 1.44 Mb thats more then a arduino has.


(  i'm curious since i had been thinking of using cams with arduino to, and then abandoned the idea in favor of a cheap ITX motherboard )

Go Up