/**
  *THIS IS A SERIAL INTERRUPT
  *IT OCCURS WHEN THE GPS IS OUTPUTTING A STRING
  *it inputs the entire string
**/
/**COMMENT OUT
#int_rda
void rda_isr(void)
{
   //ch is the incoming character
   char ch;
   //get incoming character from GPS Stream
   ch = fgetc(GPSSTREAM);
   if(ch == '$')        //$ Marks beginning of a packet
   {
   fgets(GPSbuffer,GPSSTREAM);
         //check if GPRMC string is in use
         if(noUpdate)
         {
            //we'll let the function update the string
            needUpdate = 1;
         } else {
            //put string into GPRMC
            strcpy(GPRMC,GPSbuffer);
         }
   }

}
**/ //END COMMENT OUT
/**
  *THIS IS A SERIAL INTERRUPT
  *IT OCCURS WHEN THE GPS IS OUTPUTTING A STRING
  *it inputs individual characters
**/

#int_rda
void rda_isr(void)
{
   //ch is the incoming character
   char ch;
   //get incoming character from GPS Stream
   ch = fgetc(GPSSTREAM);
   if(ch == '$')        //$ Marks beginning of a packet 
   {
      //start accepting packets
      GPSRecieving = TRUE;
      BuffIndex = 0;      // Reset buffer index
   }
   //accept packets if we are recieving
   if(GPSRecieving)
   {
      if(ch==13 || ch==10)    //Got a CR\r\n end of packet
      {
         //stop recieving
         GPSRecieving = FALSE;
         //check if GPRMC string is in use
         if(noUpdate)
         {
            //we'll let the function update the string
            needUpdate = 1;
         } else {
            //put string into GPRMC
            strcpy(GPRMC,GPSbuffer);
         }
      } else {
      
      GPSbuffer[BuffIndex] = ch;   // Add char to buffer
      BuffIndex++;                   // Advance buffer pointer     
      
      }

      if(BuffIndex > 82) //If buffer is full, this is an error
      {
         //*HANDLE BUFFER OVERRUN ERROR
         fprintf(BASESTREAM,"!ERROR:BUFFER-OVERRUN%u",BuffIndex);
      }
   } 
}

