UM6 serial parser function (in datasheet) does not show any data after getting serial data [closed]

asked 2014-03-10 03:16:13 -0500

pervez03 gravatar image

updated 2016-10-24 08:36:14 -0500

ngrennan gravatar image

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&lt;<endl; cout&lt;&lt;="" data.accel_proc_z;="" }="" end="" if(my_data_gyro_proc)="" }="" }="" }="" else="" cout&lt;&lt;"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();

}

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-11-02 01:23:53.814663

Comments

Could you clarify your problem giving some explanations on error messages you may have received, or whether you have receive some?

Wolf gravatar image Wolf  ( 2014-03-10 07:30:13 -0500 )edit

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.

pervez03 gravatar image pervez03  ( 2014-03-11 08:12:58 -0500 )edit