Skip to main content
Source Link
gre_gor
  • 1.7k
  • 4
  • 18
  • 30

Note: This is an answer that OP originally edited into his question.


I gather the data into an array of bytes data[125].

Then I gather the relevant bytes per value and stack them together:

long var = (data[4]<<8) + (data[3]); 

I shift them so the relevant bytes start first

var=var>>3; 

Afterwards I mask them with the RIGHT mask

var=var & 0xFF; 

For the example in my question:

long var = (data[1]<<8) + (data[0]); // I need two bytes var=var>>1; // shift them to the right one bit var=var & 0x7FFF; // mask it with "0111 1111 1111 1111" 
Post Made Community Wiki by gre_gor