RcChannelsRaw.parse constructor

RcChannelsRaw.parse(
  1. ByteData data_
)

Implementation

factory RcChannelsRaw.parse(ByteData data_) {
  if (data_.lengthInBytes < RcChannelsRaw.mavlinkEncodedLength) {
    var len = RcChannelsRaw.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 port = data_.getUint8(20);
  var rssi = data_.getUint8(21);

  return RcChannelsRaw(
      timeBootMs: timeBootMs,
      chan1Raw: chan1Raw,
      chan2Raw: chan2Raw,
      chan3Raw: chan3Raw,
      chan4Raw: chan4Raw,
      chan5Raw: chan5Raw,
      chan6Raw: chan6Raw,
      chan7Raw: chan7Raw,
      chan8Raw: chan8Raw,
      port: port,
      rssi: rssi);
}