Hello Every One,
I am stuck with a problem with bitwise shifting and ORing of 2 bytes.. Actually i am getting data on RS232 port in ascii which i convert into hex and save the converted data into the db.

Qt Code:
  1. data = (QByteArray::fromRawData(buff,numBytes)).toHex();
To copy to clipboard, switch view to plain text mode 

now i need to bitshift left and OR each byte from the db to get the valid data. This is the first time i am doing some thing like this. So i am confused don't know how to go about it.

This the Hexa Decimal data which i have saved into the database . Here i need to Bitwise shift left the first byte "1d" by 5 times , Next i need to bitwise shift left the second byte "17" and OR the second and the first byte. so on for all the consecutive data.

1d17110009008f008f008f008f008f008f008f008f008f008f 008f008f008f008f008f008f008f008f008f008f
1d1711000a008f008f008f008f008f008f008f008f008f008f 008f008f008f008f008f008f008f008f008f008f
1d1711000b008f008f008f008f008f008f008f008f008f008f 008f008f008f008f008f008f008f008f008f008f
1d1711000c008f008f008f008f008f008f008f008f008f008f 008f008f008f008f008f008f008f008f008f008f

Qt Code:
  1. QSqlQuery sq1("select ChannelData from Bulkdb where rowid = (" + QString::number(rowcnt) + ")");
  2. if(sq1.exec())
  3. {
  4. if (sq1.first())
  5. {
  6. do
  7. {
  8. rowdata.push_back(sq1.value(0).toString());
  9. } while(sq1.next());
  10. }
  11. }
  12.  
  13. for(int j = 0; j < rowdata.count(); j++)
  14. databuff.append(rowdata.at(j));
  15.  
  16. for(int i= 0;i<databuff.count() ;i++)
  17. {
  18. databuff1.append(databuff.at(i));
  19. alignbuff = ((databuff1.at(ld) << 5) // I am trying to Bitwise shift left each byte here , not sure if what i am doing is correct .
  20. final_data = secondByte OR | firstByte;
  21. // Not able to figure out a logic
  22. }
To copy to clipboard, switch view to plain text mode 

Not able to figure out a logic to OR the bytes like.. 2nd Byte|1st Byte, 4th Byte|3rd Byte , 6th Byte|5 byte , 8th byte|7th Byte and so on for all the data present.

some one Please who has an example or a suggestion it will help me a lot.

Thank You