BatteryStatus.parse constructor
BatteryStatus.parse(
- ByteData data_
Implementation
factory BatteryStatus.parse(ByteData data_) {
if (data_.lengthInBytes < BatteryStatus.mavlinkEncodedLength) {
var len = BatteryStatus.mavlinkEncodedLength - data_.lengthInBytes;
var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
data_ = Uint8List.fromList(d).buffer.asByteData();
}
var currentConsumed = data_.getInt32(0, Endian.little);
var energyConsumed = data_.getInt32(4, Endian.little);
var temperature = data_.getInt16(8, Endian.little);
var voltages = MavlinkMessage.asUint16List(data_, 10, 10);
var currentBattery = data_.getInt16(30, Endian.little);
var id = data_.getUint8(32);
var batteryFunction = data_.getUint8(33);
var type = data_.getUint8(34);
var batteryRemaining = data_.getInt8(35);
var timeRemaining = data_.getInt32(36, Endian.little);
var chargeState = data_.getUint8(40);
var voltagesExt = MavlinkMessage.asUint16List(data_, 41, 4);
var mode = data_.getUint8(49);
var faultBitmask = data_.getUint32(50, Endian.little);
return BatteryStatus(
currentConsumed: currentConsumed,
energyConsumed: energyConsumed,
temperature: temperature,
voltages: voltages,
currentBattery: currentBattery,
id: id,
batteryFunction: batteryFunction,
type: type,
batteryRemaining: batteryRemaining,
timeRemaining: timeRemaining,
chargeState: chargeState,
voltagesExt: voltagesExt,
mode: mode,
faultBitmask: faultBitmask);
}