Skip to content

Commit

Permalink
fixed output and some read datatypes from s_int_16 to u_int_16
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-republic committed Dec 1, 2024
1 parent c918c4b commit ee7824d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ protected void readBatteryInfo(final BatteryPack pack, final ByteBuffer data) {
pack.packSOC = data.get() * 10;
// SOH (1%) - uint_8
pack.packSOH = data.get() * 10;
// BMS cycles
pack.bmsCycles = data.getChar();

LOG.debug("\nPack V \t Pack A \t Avg \nSOC \tSOH\\n{} \t{} {}\t\t {}", pack.packVoltage / 10f, pack.packCurrent / 10f, pack.packSOC / 10f, pack.packSOH / 10f);
}
Expand Down Expand Up @@ -143,10 +145,10 @@ protected void readAlarms(final BatteryPack pack, final ByteBuffer data) {
protected void readChargeDischargeInfo(final BatteryPack pack, final ByteBuffer data) {
// Battery charge voltage (0.1V) - uint_16
pack.maxPackVoltageLimit = data.getChar();
// Charge current limit (0.1A) - sint_16
pack.maxPackChargeCurrent = data.getShort();
// Discharge current limit (0.1A) - sint_16
pack.maxPackDischargeCurrent = data.getShort() * -1;
// Charge current limit (0.1A) - uint_16
pack.maxPackChargeCurrent = data.getChar();
// Discharge current limit (0.1A) - uint_16
pack.maxPackDischargeCurrent = data.getChar() * -1;
// Battery discharge voltage (0.1V) - uint_16
pack.minPackVoltageLimit = data.getChar();

Expand All @@ -159,13 +161,13 @@ protected void readMinMaxVoltage(final BatteryPack pack, final ByteBuffer data)
// Average cell voltage (1mV) - uint_16
data.getShort();
// Maximum cell voltage (1mV) - uint_16
pack.maxCellmV = data.getShort();
pack.maxCellmV = data.getChar();
// Minimum cell voltage (1mV) - uint_16
pack.minCellmV = data.getShort();
pack.minCellmV = data.getChar();
// Average tray voltage (1mV) - uint_16
data.getShort();

LOG.debug("\nMax Cell mV \tMin Cell mV\n{}\t{}", pack.maxCellmV * 1000f, pack.minCellmV * 1000f);
LOG.debug("\nMax Cell mV \tMin Cell mV\n{}\t{}", pack.maxCellmV / 1000f, pack.minCellmV / 1000f);
}


Expand Down Expand Up @@ -202,13 +204,14 @@ protected void readCellVoltages(final BatteryPack pack, final ByteBuffer data, f
// Tray id
final int tray = data.getShort() - 1;
// Cell voltage (1mV)
pack.cellVmV[cellNoStart + tray * 3] = data.getShort();
pack.cellVmV[cellNoStart + tray * 3] = data.getChar();
// Cell voltage (1mV)
pack.cellVmV[cellNoStart + tray * 3 + 1] = data.getShort();
pack.cellVmV[cellNoStart + tray * 3 + 1] = data.getChar();

if (cellNoStart != 80) {
// Cell voltage (1mV)
pack.cellVmV[cellNoStart + tray * 3 + 2] = data.getShort();
pack.cellVmV[cellNoStart + tray * 3 + 2] = data.getChar();
}
}

}
Binary file added docs/images/batterypack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ee7824d

Please sign in to comment.