ProtocolVersion.parse constructor

ProtocolVersion.parse(
  1. ByteData data_
)

Implementation

factory ProtocolVersion.parse(ByteData data_) {
  if (data_.lengthInBytes < ProtocolVersion.mavlinkEncodedLength) {
    var len = ProtocolVersion.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var version = data_.getUint16(0, Endian.little);
  var minVersion = data_.getUint16(2, Endian.little);
  var maxVersion = data_.getUint16(4, Endian.little);
  var specVersionHash = MavlinkMessage.asUint8List(data_, 6, 8);
  var libraryVersionHash = MavlinkMessage.asUint8List(data_, 14, 8);

  return ProtocolVersion(
      version: version,
      minVersion: minVersion,
      maxVersion: maxVersion,
      specVersionHash: specVersionHash,
      libraryVersionHash: libraryVersionHash);
}