SerialControl.parse constructor

SerialControl.parse(
  1. ByteData data_
)

Implementation

factory SerialControl.parse(ByteData data_) {
  if (data_.lengthInBytes < SerialControl.mavlinkEncodedLength) {
    var len = SerialControl.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var baudrate = data_.getUint32(0, Endian.little);
  var timeout = data_.getUint16(4, Endian.little);
  var device = data_.getUint8(6);
  var flags = data_.getUint8(7);
  var count = data_.getUint8(8);
  var data = MavlinkMessage.asUint8List(data_, 9, 70);
  var targetSystem = data_.getUint8(79);
  var targetComponent = data_.getUint8(80);

  return SerialControl(
      baudrate: baudrate,
      timeout: timeout,
      device: device,
      flags: flags,
      count: count,
      data: data,
      targetSystem: targetSystem,
      targetComponent: targetComponent);
}