- #1
AppleBite
- 54
- 0
Hey guys,
I'm having trouble with sampling data from a force/torque sensor. I'm using Serial Com to receive the readings from the sensor, which is stored in a character of with 45 individual elements. What I'm trying to do is to pick out pieces of these data and store them separately. I'm using the code:
Now, if I print the full string from the character "buff", I get the full readings of a series of numbers representing sensor readings:
However, if I try to print the data stored in fx, which should be a small part of the data from buff, I get a combination of letters and symbols;
Anyone know what I'm doing wrong? Why am I getting a series of correct numbers from "buff", but strange data from "fx"?
I'm having trouble with sampling data from a force/torque sensor. I'm using Serial Com to receive the readings from the sensor, which is stored in a character of with 45 individual elements. What I'm trying to do is to pick out pieces of these data and store them separately. I'm using the code:
char * buff=serial.receive(45); // receives a string of data
char fx[6]; // Character to store the fx-readings
int i;
while (i<7)
{
char fx[6]; // Character to store the fx-readings
int i;
while (i<7)
{
fx=buff[i+2];
i=i+1;
}i=i+1;
Now, if I print the full string from the character "buff", I get the full readings of a series of numbers representing sensor readings:
cout<<buff;
However, if I try to print the data stored in fx, which should be a small part of the data from buff, I get a combination of letters and symbols;
cout<<fx<<endl;
Anyone know what I'm doing wrong? Why am I getting a series of correct numbers from "buff", but strange data from "fx"?