Exemplo n.º 1
0
static void UARTISR(int port) {
  char next,status;
  
  //Read the whole FIFO
  hasLoad(LOAD_UART);
  status=ULSR(port);
  while(status & 0x01) {
    next=URBR(port);
    if(uartInPkt[port] || isFrameStart(port,next)) { //If already in the frame, or this character starts it
      uartInPkt[port]=1; //We're still in the frame
      fill(&uartbuf[port],next);
      if(isFrameEnd(port) || unreadylen(&uartbuf[port])>=912) {
        //But not after this character
        uartInPkt[port]=0;
        if(PKT_SIRF==uartMode[port]) {
          parseSirf(&uartbuf[port]);
        } else if(PKT_NMEA==uartMode[port]) {
          parseNmea(&uartbuf[port]);
        }
//        sendBuf(1-port,&uartbuf[port]);
        mark(&uartbuf[port]);
      }
    }
    status=ULSR(port);
  }

}
Exemplo n.º 2
0
bool GPSDecoder::decodeByte(int8_t newByte)
{
	bool success = false;
	if (parseNmea(&nmeaPosition, newByte)) 
	{//lat comes in form AA.BBCCC  A degrees B minutes C decimal minutes  
	//lat retruned in form AA.BBB A degrees B decimal degrees decimal fixed between A and B
		latitude = atoi(latitudeString) * 1000;  //lat = AABBC
		latitude = ((int)latitude / 1000) * 1000 + (int)(latitude % 1000) / 600;
		if (0 == strcmp( NSlatitudeString, "S") ) {
			latitude = -latitude;
		}
		longitude= atoi(longitudeString)*1000;	
		longitude= ((int)longitude/1000)*1000+ (int)(longitude%1000)/600;
		if (0 == strcmp( EWlongitudeString, "E") ) {
			latitude = -latitude;
		}

		altitute=atoi( altitudeString)/1000;
		
		realNumSatellites =atoi( numSatellitesString);
		//strtol(numSatellitesString, &endPointer, 10);
		realHdop = atoi (hdopString);
		success = true;
	}
	if (parseNmea(&nmeaVelocity, newByte)){ 
		char* endpointer; 
		speed =(int32_t) strtol(speedString, &endpointer, 10)*10000/36;
		if(endpointer!=NULL){
			speed=speed+ (int32_t) strtol(endpointer+1, &endpointer, 10)*1000/36;
		}
		trueheading= atoi(trueheadingString);
		magneticheading= atoi( magneticheadingString);
		success = true;
	}
	return success;
 }
Exemplo n.º 3
0
bool IMUDecoder::decodeByte(int8_t newByte)
{
    if (parseNmea(&nmeaData, newByte))
    {
        // It parsed! Something happened!
        lastCalcData = currentCalcData;
        convertToCalcData();
        
        // Time stamp our just converted time!
        struct timeval currentTime;
        gettimeofday(&currentTime, NULL);
        currentCalcData.accel.timestamp = (double)currentTime.tv_sec + (double)currentTime.tv_usec / 1000000;
        
        calculateIntegratedData();
        return true;
    }
    
    return false;
}