SensBatmon.parse constructor

SensBatmon.parse(
  1. ByteData data_
)

Implementation

factory SensBatmon.parse(ByteData data_) {
  if (data_.lengthInBytes < SensBatmon.mavlinkEncodedLength) {
    var len = SensBatmon.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var batmonTimestamp = data_.getUint64(0, Endian.little);
  var temperature = data_.getFloat32(8, Endian.little);
  var safetystatus = data_.getUint32(12, Endian.little);
  var operationstatus = data_.getUint32(16, Endian.little);
  var voltage = data_.getUint16(20, Endian.little);
  var current = data_.getInt16(22, Endian.little);
  var batterystatus = data_.getUint16(24, Endian.little);
  var serialnumber = data_.getUint16(26, Endian.little);
  var cellvoltage1 = data_.getUint16(28, Endian.little);
  var cellvoltage2 = data_.getUint16(30, Endian.little);
  var cellvoltage3 = data_.getUint16(32, Endian.little);
  var cellvoltage4 = data_.getUint16(34, Endian.little);
  var cellvoltage5 = data_.getUint16(36, Endian.little);
  var cellvoltage6 = data_.getUint16(38, Endian.little);
  var soc = data_.getUint8(40);

  return SensBatmon(
      batmonTimestamp: batmonTimestamp,
      temperature: temperature,
      safetystatus: safetystatus,
      operationstatus: operationstatus,
      voltage: voltage,
      current: current,
      batterystatus: batterystatus,
      serialnumber: serialnumber,
      cellvoltage1: cellvoltage1,
      cellvoltage2: cellvoltage2,
      cellvoltage3: cellvoltage3,
      cellvoltage4: cellvoltage4,
      cellvoltage5: cellvoltage5,
      cellvoltage6: cellvoltage6,
      soc: soc);
}