10-02-2014 02:37 AM
Q1.
BIP-4 checksum: is computed by xor'ing all the bytes in the packet together and then xor'ing the left nibble of the result with the right nibble of the result.
unsigned char calcBIP4( unsigned char* data ) {
int i;
unsigned char bip8=(data[0]& 0x0f) ^ data[1] ^ data[2] ^ data[3];
unsigned char bip4=((bip8 & 0xf0) >>4) ^ (bip8 & 0x0f);
return bip4;
I have xor'ed all the bytes and get a U8 integer. how can I xor the left part with the right part?
I tried to use 'split number', but for a U8, the high half is 0, and the low half is the same 8-bit number.
Q2.
assume I get a 4-bit checksum, how to combine the checksum with 0001 to get a U8?
10-02-2014 02:50 AM - edited 10-02-2014 03:16 AM
10-02-2014 03:01 AM
thank you very much!
for the 2nd question, I want to combine the checksum with 0001(write=1) to get a byte. for example, checksum=1111, then the byte=11110001.
could you tell me what is the 'RIQ' function called?
10-02-2014 03:07 AM - edited 10-02-2014 03:08 AM
Hi cantata,
for your Q2 explanation: the solution is shown above…
The function is found in the basic numerics function palette - just look for it! 😄
As a sidenote: by now you should have learned how to use SNIPPETS - they are explained in the LabVIEW help too…
10-02-2014 03:15 AM
In answer to the question "how to manipulate bits?" I was tempted to write, build up their hopes, feed them lies and pretend to be their friend.
But the answers given already are also good.
10-02-2014 06:28 AM
@cantata2014 wrote:
thank you very much!
for the 2nd question, I want to combine the checksum with 0001(write=1) to get a byte. for example, checksum=1111, then the byte=11110001.
could you tell me what is the 'RIQ' function called?
You just use the Shift function and then OR the result with 0b0001.
08-04-2016 01:46 AM
In Q1, why are you AND'ing data[0] with 0x0f? What is the purpose of this?
08-04-2016 02:16 AM
Hi abuts,
when you answer to an old thread you should always use nicknames instead of just "you" when you want to ask a specific participant ona specific problem. Or you need to link to the message you are talking about!
ANDing data usually is used to mask certain bits - to make sure all other bits are cleared…