RcChannels.parse constructor

RcChannels.parse(
  1. ByteData data_
)

Implementation

factory RcChannels.parse(ByteData data_) {
  if (data_.lengthInBytes < RcChannels.mavlinkEncodedLength) {
    var len = RcChannels.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var timeBootMs = data_.getUint32(0, Endian.little);
  var chan1Raw = data_.getUint16(4, Endian.little);
  var chan2Raw = data_.getUint16(6, Endian.little);
  var chan3Raw = data_.getUint16(8, Endian.little);
  var chan4Raw = data_.getUint16(10, Endian.little);
  var chan5Raw = data_.getUint16(12, Endian.little);
  var chan6Raw = data_.getUint16(14, Endian.little);
  var chan7Raw = data_.getUint16(16, Endian.little);
  var chan8Raw = data_.getUint16(18, Endian.little);
  var chan9Raw = data_.getUint16(20, Endian.little);
  var chan10Raw = data_.getUint16(22, Endian.little);
  var chan11Raw = data_.getUint16(24, Endian.little);
  var chan12Raw = data_.getUint16(26, Endian.little);
  var chan13Raw = data_.getUint16(28, Endian.little);
  var chan14Raw = data_.getUint16(30, Endian.little);
  var chan15Raw = data_.getUint16(32, Endian.little);
  var chan16Raw = data_.getUint16(34, Endian.little);
  var chan17Raw = data_.getUint16(36, Endian.little);
  var chan18Raw = data_.getUint16(38, Endian.little);
  var chancount = data_.getUint8(40);
  var rssi = data_.getUint8(41);

  return RcChannels(
      timeBootMs: timeBootMs,
      chan1Raw: chan1Raw,
      chan2Raw: chan2Raw,
      chan3Raw: chan3Raw,
      chan4Raw: chan4Raw,
      chan5Raw: chan5Raw,
      chan6Raw: chan6Raw,
      chan7Raw: chan7Raw,
      chan8Raw: chan8Raw,
      chan9Raw: chan9Raw,
      chan10Raw: chan10Raw,
      chan11Raw: chan11Raw,
      chan12Raw: chan12Raw,
      chan13Raw: chan13Raw,
      chan14Raw: chan14Raw,
      chan15Raw: chan15Raw,
      chan16Raw: chan16Raw,
      chan17Raw: chan17Raw,
      chan18Raw: chan18Raw,
      chancount: chancount,
      rssi: rssi);
}