PaulS:
Serial.println((int)help);
Why are you casting a long long to an int?
The intention was to have at least the lower 32 bits printed. But therefore, I should not have used “unsigned long”. Of course Int is comepletely wrong here.
Anyways, I think I found a solution:
//////////////////////////////////////////////////////////////////////
unsigned long long help=0; unsigned long long1=0, long2=0; unsigned char c=0;
for(i=0; i<8; i++){
c=client.read();
Serial.print(c, HEX); Serial.print(" "); Serial.println(c, BIN);
help=( help << 8 );
help=( help | c );
}
long1=(unsigned long)(help >> 32); //copying higher 4 bytes to long1
long2=(unsigned long)(help); //copying lower 4 bytes to long1
Serial.println(“Longs are:”);
Serial.print(long1,HEX);Serial.print(" “);Serial.println(long1, BIN);
Serial.print(long2,HEX);Serial.print(” ");Serial.println(long2, BIN);
/////////////////////////////////////////////////////////////////////////////
I told my android to send the long (Java 8 (?) long) number “976786878678567600” and the printout on the monitor was:
…
D 1101
8E 10001110
3E 111110
7D 1111101
AC 10101100
E6 11100110
A 1010
B0 10110000
Longs are:
D8E3E7D 1101100011100011111001111101
ACE60AB0 10101100111001100000101010110000
…
according to some web hex converters,
D8E3E7DACE60AB0 is supposed to be 976786878678567600.
Can I assume this is working perfectly?
What risks would you guys expect in using this code?
I highly appreciate any kinds of feedbacks 