You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your System almost works!!! BUT Conversion with little endian does not work. It
seems like you forgot to impliment byteorder when unpacking?? It is really
unfortunate because I am soo close to get it working a serial protocol for
arduino.
You can reproduce the problem with the code below:
@StructClass
public class Foo{
@StructField(order = 0)
public int b;
@StructField(order = 1)
public int i;
}
try{
// Pack the class as a byte buffer
Foo f = new Foo();
f.b = (int)14;
f.i = 12;
byte[] b = JavaStruct.pack(f,ByteOrder.LITTLE_ENDIAN );
// Unpack it into an object
Foo f2 = new Foo();
JavaStruct.unpack(f2, b,ByteOrder.LITTLE_ENDIAN );
println(f2.b);
}
catch(StructException e){
}
et_begin();
size(800, 600);
}
Original issue reported on code.google.com by [email protected] on 26 Jun 2014 at 8:46
The text was updated successfully, but these errors were encountered:
Since we are only using short (8bit = 2 bytes) we have solved it with this
nasty solution:
try {
// Pack the class as a byte buffer
Foo f = new Foo();
f.b = (int)14;
f.i = 12;
byte[] b = JavaStruct.pack(f, ByteOrder.LITTLE_ENDIAN );
byte[] c = new byte[b.length];
/* for(int i =0; i < b.length;i++)
{
c[i] = b[b.length -i-1];
}*/
for(int i=0; i < b.length-1;i=i+2)
{
c[i] = b[i+1];
c[i+1] = b[i];
}
// Unpack it into an object
Foo f2 = new Foo();
JavaStruct.unpack(f2, c );
println(f2.b);
}
catch(StructException e) {
}
Original issue reported on code.google.com by
[email protected]
on 26 Jun 2014 at 8:46The text was updated successfully, but these errors were encountered: