Now I have something to help this problem; this code works:
lcd.clear();
char var1, var2;
signed short int var3, var4;
var1 = 0xab;
var2 = 0xcd;
var3 = ((signed short int) (var1 << 8) |(0xff & var2) );
if(sizeof(var3) == 2)
printf("signed short is 2 bytes\n");
if (var3 == 0xabcd) {
lcd.print("it's right!");
}
else {
lcd.print("var3=");
lcd.print(var3);
}
return;
Showing that the casting is done correctly. This must be a problem with the roomba protocol. Does anyone know anything about the ROI (Roomba Open Interface) to shed some light on this? It is really important that I get the arduino to receive negative values from the roomba, otherwise the project I am working on for my current internship will never be finished!!