I want to send an integer coded as a byte array over a serial line with C and receive it using java and put the array back to an java int.
I'm using rs-232 to send four bytes in a byte array packed by a C union. (The slightly odd typedef is caused by the Arduino C dialect) Here I send for example the decimal value 600 It is packed in a type accordingly:
typedef union {
uint16_t integer;
byte binary[4];
} binaryInteger;
and sent using the function:
void mcProxySend(binaryInteger bi){
for (byte i = 0; i < 4 ; i ++) {
mcProxySend(bi.binary[i]);
}
}
mcProxySend is just a serial write with occasional escape characters.
I have the receiving end of my Java classes worked out. Data is flowing and, bit by bit, it is the same as I sent.
The problem I have is how to reassemble the broken up integer.