UM6 serial parser function (in datasheet) does not show any data after getting serial data
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 putinbuffer(uint8_t data){
buffer[head] = data; if (++head>=MAX) {head=0;} } void circularbuf(uint8t data) { uint8t c; putinbuffer(data); int16t MYDATAACCELPROCZ; if ( available_buffer()){
c = getfrombuffer();
if(parseserialdata(buffer,36,&packet)==0) { if (packet.addresstype == ADDRESSTYPE_DATA) {
if (packet.Address == UM6ACCELPROCZ ) {// ACCRAWZ MYDATAACCELPROCZ = (int16t)packet.data[4]<<8; //bitshift it MYDATAACCELPROCZ |= packet.data[5]; Data.AccelProcZ = MYDATAACCELPROCZ*0.000183105; cout<<MYDATAACCELPROCZ<<endl; cout<< Data.AccelProcZ; } // end if(MYDATAGYRO_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();
}
Asked by pervez03 on 2014-03-10 03:16:13 UTC
Comments
Could you clarify your problem giving some explanations on error messages you may have received, or whether you have receive some?
Asked by Wolf on 2014-03-10 07:30:13 UTC
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.
Asked by pervez03 on 2014-03-11 08:12:58 UTC