//This function runs in a separate thread and handles processing and parsing of the GPS data
 public static void GPSupdate()
 {
     Console.WriteLine("GPS Processing Thread Started");
     while (Program.runTranceiver)
     {
         do
         {
             String GPSinData = GPSin.ReadLine();
             ParseGPS.parseNMEAstring(GPSinData);
             if (ParseGPS.getCommand() == 0)
             {
                 //Console.Clear();
                 if (ParseGPS.findSignal())
                 {
                     float[] latlog  = ParseGPS.getCoordinates();
                     char[]  Compass = ParseGPS.getCompass();
                     //Console.WriteLine("Latitude - " + latlog[0] + " " + Compass[0] + " Longitude - " + latlog[1] + " " + Compass[1]);
                     List <String> TimeList = ParseGPS.getTime();
                     String[]      assemStr = new String[] { "0x", String.Format("{0:X}", devID), ",", ParseGPS.NMEAstring[2], ",", Compass[0].ToString(), ",", ParseGPS.NMEAstring[4], ",", Compass[1].ToString(), ",", TimeList[0], ",", TimeList[1], ",", TimeList[2].Substring(0, 3) };
                     deviceData = String.Join("", assemStr);
                     //Console.WriteLine("Time: " + TimeList[0] + ":" + TimeList[1] + ":" + TimeList[2]);
                 }
                 else
                 {
                     deviceData = ("0x" + String.Format("{0:X}", devID) + "," + noSignalStr);
                     //Console.WriteLine("No Signal Found");
                 }
             }
         } while (ParseGPS.getCommand() != 0);
     }
 }
 public static char[] getCompass()
 {
     char[] Compass = new char[2];
     Compass[0] = char.Parse(NMEAstring[3 - ParseGPS.getCommand()]);
     Compass[1] = char.Parse(NMEAstring[5 - ParseGPS.getCommand()]);
     return(Compass);
 }
 //Returns latitute and longitude as an array of 2 floating point numbers
 public static float[] getCoordinates()
 {
     float[] latLog = new float[2];
     latLog[0] = float.Parse(NMEAstring[2 - ParseGPS.getCommand()]);
     latLog[1] = float.Parse(NMEAstring[4 - ParseGPS.getCommand()]);
     return(latLog);
 }
 //Input a GGA string and this function will reply with the state of the network fix
 public static bool findSignal()
 {
     if ((ParseGPS.getCommand() == 0) && (Int32.Parse(NMEAstring[6]) != 0))
     {
         return(true);
     }
     return(false);
 }
        //Returns a list of strings for the coordinates, sorting the angle from the bearing
        public static List <String> getCoordStr()
        {
            List <String> latlogStr = new List <String>();
            String        lat       = NMEAstring[2 - ParseGPS.getCommand()];
            String        log       = NMEAstring[4 - ParseGPS.getCommand()];

            latlogStr.Add(lat.Substring(0, 2));
            latlogStr.Add(lat.Substring(2, 5));
            latlogStr.Add(log.Substring(0, 3));
            latlogStr.Add(log.Substring(3, 5));
            return(latlogStr);
        }
        public static List <String> getTime()
        {
            List <String> TimeList = new List <String>();
            String        Time     = NMEAstring[1 - ParseGPS.getCommand()];
            String        hours    = Time.Substring(0, 2);
            String        mins     = Time.Substring(2, 2);
            String        secs     = Time.Substring(4, 5);

            TimeList.Add(hours);
            TimeList.Add(mins);
            TimeList.Add(secs);
            return(TimeList);
        }