Пример #1
0
// IFM 4: Capability reply - OLD ITU 1371-4
// TODO(schwehr): WTF?  10 + 128 + 6 == 80  Is this 168 or 232 bits?
Ais6_1_4::Ais6_1_4(const char *nmea_payload, const size_t pad)
    : Ais6(nmea_payload, pad), ack_dac(0), capabilities(),
      cap_reserved(), spare2(0) {
  assert(dac == 1);
  assert(fi == 4);

  // TODO(schwehr): num_bits for 6_1_4.  226 bits?
  if (num_bits != 232) {
    status = AIS_ERR_BAD_BIT_COUNT;
    return;
  }

  AisBitset bs;
  const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
  if (r != AIS_OK) {
    status = r;
    return;
  }

  bs.SeekTo(88);
  ack_dac = bs.ToUnsignedInt(88, 10);
  for (size_t cap_num = 0; cap_num < 128/2; cap_num++) {
    size_t start = 98 + cap_num * 2;
    capabilities[cap_num] = bs[start];
    cap_reserved[cap_num] = bs[start + 1];
  }
  // spare2 = bs.ToUnsignedInt(226, 6);  // OR NOT
  // TODO(schwehr): add in the offset of the dest mmsi

  assert(bs.GetRemaining() == 0);
  status = AIS_OK;
}