public bool compileSentence() { //CALLSIGN,SENTENCE_ID,TIME,LATITUDE,LONGITUDE,ALTITUDE,[CUSTOM, DATA, ..., ...] string _sentence; if (callsign.Length > 1) { _sentence = callsign.ToUpper(); } else { return(false); } if (sentence_id >= 0) { _sentence += "," + sentence_id; } else { return(false); } _sentence += "," + System.DateTime.Now.ToString("HH:mm:ss"); _sentence += "," + latitude; _sentence += "," + longitude; _sentence += "," + altitude; foreach (string item in sentenceData) { _sentence += "," + item; } Crc16Ccitt crc = new Crc16Ccitt(); string checksum = crc.ComputeChecksum(System.Text.UTF8Encoding.UTF8.GetBytes(_sentence)).ToString("X"); // $$$$$$CALLSIGN,SENTENCE_ID,TIME,LATITUDE,LONGITUDE,ALTITUDE,[CUSTOM, DATA, ..., ...]*XXXX if (checksum.Length == 4) { _wholeSentence = "$$" + _sentence + "*" + checksum; } else { return(false); } return(true); }
public bool compileSentence() { //CALLSIGN,SENTENCE_ID,TIME,LATITUDE,LONGITUDE,ALTITUDE,[CUSTOM, DATA, ..., ...] string _sentence; if (callsign.Length > 1) { _sentence = callsign.ToUpper(); } else { return false; } if (sentence_id >= 0) { _sentence += "," + sentence_id; } else { return false; } _sentence += "," + System.DateTime.Now.ToString("HH:mm:ss"); _sentence += "," + latitude; _sentence += "," + longitude; _sentence += "," + altitude; foreach (string item in sentenceData) { _sentence += "," + item; } Crc16Ccitt crc = new Crc16Ccitt(); string checksum = crc.ComputeChecksum(System.Text.UTF8Encoding.UTF8.GetBytes(_sentence)).ToString("X"); // $$$$$$CALLSIGN,SENTENCE_ID,TIME,LATITUDE,LONGITUDE,ALTITUDE,[CUSTOM, DATA, ..., ...]*XXXX if (checksum.Length == 4) { _wholeSentence = "$$" + _sentence + "*" + checksum; } else { return false; } return true; }