Why send my Arduino sometime Hex and sometimes the wrong?
I have found several problems with your program, although they may not
be related with your primary problem:



while (!Serial &amp; !Serial1 &amp;! Serial2)


You mean while (!Serial || !Serial1 || !Serial2), although this is
only useful with virtual serial ports, like on the Leonardo. On the
mega, all of these ports are real hardware ports.

void sendBinaryValue(short incomingByte)


The way you name the parameter is misleading: a short is not a byte,
it's two bytes.

int temp = (incomingByte &amp; 0xFF00)&gt;&gt;8;


You are bit-shifting a signed number, which is going to do a sign
extension. This is probably not what you want.

Serial.print(temp, DEC);


You are printing several numbers one after the other with no separator.
This is going to cause ambiguities: you cannot know whether "345" means
"3 45" or "34 5".

Finally, I don't get the purpose of your functions. Why don't you just
print the numbers like this?

Serial.println(incomingByte, HEX);
Serial.println(currentMillis);