UM6 serial parser function (in datasheet) does not show any data after getting serial data [closed]
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)="" {<="" p="">
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();
}
Could you clarify your problem giving some explanations on error messages you may have received, or whether you have receive some?
Hello Mr. Wolf Thanks for your reply. The serial reading is perfectly shown on screen. So for specific data requirement i am trying to use the parse_serial_data function that is given in the CHRobotics datasheet. But when I try to use this function it does not show anything. May be for single byte so it always out. I have no idea how i can make an array to fill this read into it and then parse it. Hope you understand. Again thanks and have a nice day.