public static MavLink Deserialize(string path) { XDocument mavLinkDocument = XDocument.Load(path); MavLink mavLink = Deserialize(mavLinkDocument); return(mavLink); }
public static MavLink Deserialize(TextReader textReader) { XDocument mavLinkDocument = XDocument.Load(textReader); MavLink mavLink = Deserialize(mavLinkDocument); return(mavLink); }
public void AreCrcValid() { MavLink mavLink = LoadMavLink(); IDictionary <uint, MessageInfo> messageInfoById = DefinitionDataHelper.GetMessageInfoById(); IDictionary <Message, byte> errorDictionary = new Dictionary <Message, byte>(); foreach (Message message in mavLink.Messages) { uint messageId = (uint)message.Id; MessageInfo messageInfo = messageInfoById.ContainsKey(messageId) ? messageInfoById[messageId] : null; if (messageInfo != null) { Assert.AreEqual(messageInfo.Crc, message.CrcExtra); if (messageInfo.Crc != message.CrcExtra) { errorDictionary.Add(message, messageInfo.Crc); } } } Console.WriteLine("Name \t| Expected \t| Computed"); foreach (var kvp in errorDictionary) { Console.WriteLine($"{kvp.Key.Name} \t| {kvp.Value} \t| {kvp.Key.CrcExtra}"); } }
private static MavLink LoadMavLink() { //string definitionFilePath = @"F:\UserData\Amael\OneDrive\Projets\MavLink4Net\message_definitions\0.9\common.xml"; string definitionFilePath = @"F:\UserData\Amael\OneDrive\Projets\MavLink4Net\message_definitions\1.0\common.xml"; MavLink1MessageFilter messageFilter = new MavLink1MessageFilter(); DataProvider dataProvider = new DataProvider(false, null, null, null, null, messageFilter); MavLink mavLink = dataProvider.GetMavLink(definitionFilePath); return(mavLink); }
public void AreNameValid() { MavLink mavLink = LoadMavLink(); IDictionary <uint, MessageInfo> messageInfoById = DefinitionDataHelper.GetMessageInfoById(); foreach (Message message in mavLink.Messages) { uint messageId = (uint)message.Id; MessageInfo messageInfo = messageInfoById.ContainsKey(messageId) ? messageInfoById[messageId] : null; if (messageInfo != null) { Assert.AreEqual(messageInfo.Name, message.Name); } } }
private static MavLink ToMavLink(XElement xElement) { MavLink mavLink = new MavLink(); mavLink.Version = Int32.Parse(xElement.Element(XName.Get("version")).Value); mavLink.Dialect = xElement.Element(XName.Get("dialect"))?.Value; // enums XElement enumsElement = xElement.Element(XName.Get("enums")); IEnumerable <XElement> enumElements = enumsElement.Elements(XName.Get("enum")); mavLink.Enums = ToEnums(enumElements); // messages XElement messagesElement = xElement.Element(XName.Get("messages")); IEnumerable <XElement> messageElements = messagesElement.Elements(XName.Get("message")); mavLink.Messages = ToMessages(messageElements); return(mavLink); }