I have a C++ Vector full of uint8_t values from a TCP data segment. I am looking specifically for 1 of two values which should be at the first index of the vector.
I have the following if statement to express my logic.
if ( ui8BufferIn.at(0) != 0xE4 || ui8BufferIn.at(0) != 0xE2){
printf("\nWe have a problem, no parsing will be done, Package Type = %u\n", ui8BufferIn.at(0));
proceed = false;
}
The above if statement is executing when it shouldn't. I get the following printout:
We have a problem, no parsing will be done, Package Type = 226
So you don't have to do the math, 226
as an integer is 0xE2
in HEX.
I've been at this a while, so it very well may be something simple, but any help would be great!
I think you might want your logic to be:
if ( ui8BufferIn.at(0) != 0xE4 && ui8BufferIn.at(0) != 0xE2){
As right now you're saying "If either case of: (it's not 0xE4
) or case of: (it's not 0xE2
), we have a problem" - which, if I understand correctly, is not what you want to say. With your statement, you could be getting 0xE2
, but because you're not getting 0xE4
(ui8BufferIn.at(0) != 0xE4
), your statement executes.