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();
}
The output doesnot show anythig on the screen..Can anyone please find it out where the problem is`?