Skip to content

Commit ecc1541

Browse files
committed
fixed setting byte order
1 parent a991492 commit ecc1541

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

bms-jk-can/src/main/java/com/airepublic/bmstoinverter/bms/jk/can/JKBmsCANProcessor.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ public class JKBmsCANProcessor extends BMS {
3434
protected void collectData(final Port port) {
3535
try {
3636
final ByteBuffer frame = port.receiveFrame();
37-
frame.order(ByteOrder.LITTLE_ENDIAN);
3837
final int frameId = frame.getInt();
3938
final byte[] bytes = new byte[8];
4039
frame.get(bytes);
41-
final ByteBuffer data = ByteBuffer.wrap(bytes);
40+
final ByteBuffer data = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
4241

4342
final int cmd = frameId & 0xFFFFFFF0;
4443
final int bmsId = (frameId & 0x0000000F) - 4;
@@ -279,11 +278,11 @@ private void readChargingInfo(final BatteryPack pack, final ByteBuffer data) {
279278
public static void main(final String[] args) {
280279
final JKBmsCANProcessor jk = new JKBmsCANProcessor();
281280

282-
final ByteBuffer data = ByteBuffer.wrap(new byte[] { (byte) 0xEC, 0x01, (byte) 0xA0, 0x0F, 0x33, 0x00, 0x00, 0x00 }).order(ByteOrder.LITTLE_ENDIAN);
281+
final ByteBuffer data = ByteBuffer.wrap(new byte[] { (byte) 0xED, 0x01, (byte) 0xA0, 0x0F, 0x33, 0x00, 0x00, 0x00 }).order(ByteOrder.LITTLE_ENDIAN);
283282
System.out.println(Port.printBuffer(data));
284283
final BatteryPack pack = new BatteryPack();
285284
jk.readBatteryStatus(pack, data);
286-
System.out.println(pack.packVoltage / 10 + "V, " + pack.packCurrent / 10 + "A, " + pack.packSOC / 10 + "%");
285+
System.out.println(pack.packVoltage / 10f + "V, " + pack.packCurrent / 10f + "A, " + pack.packSOC / 10f + "%");
287286
;
288287
}
289288
}

0 commit comments

Comments
 (0)