예제 #1
0
        public static void ReorderFieldsAndClacCrc(this MavlinkMessageModel src)
        {
            src.Fields = src.Fields.OrderByDescending(_ => _.FieldTypeByteSize).ToList();

            var crc = Tool.X25Crc.Accumulate($"{src.Name} ", Tool.X25Crc.CrcSeed);

            crc          = src.Fields.Aggregate(crc, (acc, field) => field.CalculateCrc(acc));
            src.CrcExtra = (byte)((crc & 0xFF) ^ (crc >> 8));
        }
예제 #2
0
        /// <summary>
        /// It's for Variable Length Arrays calculation
        /// </summary>
        /// <param name="src"></param>
        public static void CalculateLargestArray(this MavlinkMessageModel src)
        {
            var largestArray = src.Fields.Where(_ => _.IsArray).OrderByDescending(_ => _.FieldByteSize).FirstOrDefault();

            if (largestArray != null)
            {
                largestArray.IsTheLargestArrayInMessage = true;
            }
        }
예제 #3
0
 public static IEnumerable <MessageFieldModel> GetAllFields(this MavlinkMessageModel src)
 {
     return(src.Fields.Concat(src.ExtendedFields));
 }