FileTransferProtocol.parse constructor

FileTransferProtocol.parse(
  1. ByteData data_
)

Implementation

factory FileTransferProtocol.parse(ByteData data_) {
  if (data_.lengthInBytes < FileTransferProtocol.mavlinkEncodedLength) {
    var len = FileTransferProtocol.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var targetNetwork = data_.getUint8(0);
  var targetSystem = data_.getUint8(1);
  var targetComponent = data_.getUint8(2);
  var payload = MavlinkMessage.asUint8List(data_, 3, 251);

  return FileTransferProtocol(
      targetNetwork: targetNetwork,
      targetSystem: targetSystem,
      targetComponent: targetComponent,
      payload: payload);
}