UM6 parser serial data function does not show any values PC

After c in circular buffer function when asking for specific address data it does not show anything.
How I can solve this problem? PLease any idea.

[code]BOOL readbyte(BYTE &resp)
{
BOOL bReturn = TRUE;
BYTE rx;
DWORD dwBytesTransferred=0;

if (ReadFile (hPort, &rx, 1, &dwBytesTransferred, 0)> 0)
{
if (dwBytesTransferred == 1)
{
resp=rx;
bReturn = TRUE;
}
else bReturn = FALSE;
}
else bReturn = FALSE;
return bReturn;
}
void put_in_buffer(uint8_t data){

buffer[head] = data;
if (++head>=MAX)
{head=0;}
}
void circular_buf(uint8_t data)
{
uint8_t c;
put_in_buffer(data);
int16_t MY_DATA_ACCEL_PROC_Z;
if ( available_buffer()){

c = get_from_buffer();

if(parse_serial_data(buffer,36,&packet)==0)
{
if (packet.address_type == ADDRESS_TYPE_DATA) {

if (packet.Address == UM6_ACCEL_PROC_Z ) {// ACC_RAW_Z
MY_DATA_ACCEL_PROC_Z = (int16_t)packet.data[4]<<8; //bitshift it
MY_DATA_ACCEL_PROC_Z |= packet.data[5];
Data.Accel_Proc_Z = MY_DATA_ACCEL_PROC_Z*0.000183105;
cout<<MY_DATA_ACCEL_PROC_Z<<endl;
cout<< Data.Accel_Proc_Z;
} // end if(MY_DATA_GYRO_PROC)
}
}
}
else cout<<"Help ";
}
int main(void)
{

hPort = ConfigureSerialPort(L"COM1");
if(hPort == NULL)
{
cout<<“Com port configuration failed\n”;
return -1;
}
BYTE data;

while(readbyte(data)== TRUE)
{
circular_buf(data);
}

system(“PAUSE”);
ClosePort();

}[/code]

Hello.

Have you been able to get anything (even an error message) to print using “cout”?

-Brandon

Hello Mr BrandonM,
Thanks for reply. Actually after the parse_serial_data function it does not showing anything. Although there is cout. This means conditions are not fulfill. So I have chanced buffer to &c in parse_serial_data function. It also not shows anything because it always take only one byte at a time (today I have checked). I thing may be possible to make 16bit data array to save the serial data from the buffer then this packet data will pass through parse_serial_data function. But I spent whole day to find how I can do that. I have no idea about this. I am actually new in programming.

Hello.

You might try using the example C code in the “Windows C” section of the Maestro user’s guide as an example. The commands will be different, but the structure of the code might be useful. As mentioned in this similar post, another good suggestion is to look at the UM6 sensor’s source code to see how they read and interpret packets.

If you have not done so already, I recommend using the CH Robotics Serial Interface (which can be found in the “Resources” tab of the UM6 r2 product page) to get a little more familiar with the UM6 module and verify that it is working correctly.

-Brandon

Mr Brandon
Thanks a lot. I am observing. Hopefully I can solve but if I face any problem I will inform you. Have a nice day.