Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
while(readbyte(value)== TRUE)
                    {
                        buffer [count++] = queue.enqueue(value);
                        if(count == 128)
                            {count = 0;


                    if(parse_serial_data(buffer,22,&new_packet)==0)
                        {
                            if (new_packet.Address == 0x5C) {  //UM6_GYRO_PROC_XY

                                  // GYRO_PROC_X
                                MY_DATA_GYRO_PROC_X = (int16_t)new_packet.data[0]<<8; //bitshift it
                                MY_DATA_GYRO_PROC_X |= new_packet.data[1];
                                Data.Gyro_Proc_X = MY_DATA_GYRO_PROC_X*0.0610352f;
                                cout<<Data.Gyro_Proc_X<<"\t";


But problem is always shows 128 same values in each traval. The problem is for count==128. How I can resolve it? Hope I can explain clearly.
Posted
Comments
[no name] 19-Mar-14 9:12am    
Not clear.
1. Is 128 valid data and you only want to show it once?
OR
2. Is 128 invalid and you want to know why?
Pervez03 19-Mar-14 9:36am    
Like X-pro Y-pro Z-Pro
-0.427246 0.366211 2.01416
-0.427246 0.366211 2.01416
-0.427246 0.366211 2.01416
-0.427246 0.366211 2.01416
..
..
128 times this value then change the value if I move the sensor. Again for new position it gives another 128 same value for each axis.

1 solution

When the parse function returns zero for success, reset count to zero.

Not sure why you're using queue.enqueue instead of buffer[count++] = value.
 
Share this answer
 
Comments
Pervez03 20-Mar-14 4:46am    
Hello Mr. Bling
You are completely right. I have dont this because it will slow the processing time that can match with image data (normaly it takes more processing time than sensor). Or any other better way to do that? If so then please inform.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900