I solved by doing uint16_t blockN = buffer[2]<<8 | (buffer[3]&0xFF);
1
ouah
On
You have to change the type of buffer array from an array of char to an array of unsigned char, otherwise buffer[2] will be promoted to int and sign extension will occur. On most platforms char type is a signed type.
I solved by doing uint16_t blockN = buffer[2]<<8 | (buffer[3]&0xFF);