Preon decode and then encode doesn't return the same byte array

自古美人都是妖i 提交于 2019-12-08 22:50:32

Question resolved.

The describing class did not take into account the byte order. Foolishly I did not consider the byte-order to be an issue within the bits in the byte itself. But this is obviously the case:

Example-byte: 0xf7=1111 01 11 (Big Endian: MSB first)

@BoundNumber(size="4", byteOrder=ByteOrder.BigEndian) //Corresponds to 1111
private byte b1_3_notUsed;

@BoundNumber(size="2", byteOrder=ByteOrder.BigEndian) //Corresponds to 01
private ParkingBrakeSwitch parkingBrakeSwitch;

@BoundNumber(size="2", byteOrder=ByteOrder.BigEndian) //Corresponds to 11
private byte b1_1_notUsed;

Now encoding returns 0xf7=1111 01 11 again when it has been re-encoded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!