Beispiel #1
0
errorCode decodeFloatValue(EXIStream* strm, Float* fl_val)
{
	errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR;
	Integer mantissa;
	Integer exponent;

	DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (float)"));

	TRY(decodeIntegerValue(strm, &mantissa));	//decode mantissa
	TRY(decodeIntegerValue(strm, &exponent));	//decode exponent

	DEBUG_MSG(ERROR, DEBUG_STREAM_IO, (">Float value: %ldE%ld\n", (long int)mantissa, (long int)exponent));

//  TODO: Improve the below validation: it should be independent of how the Float is defined
//
//	if(exponent >= (1 << 14) || exponent < -(1 << 14)
//			|| mantissa >= ((uint64_t) 1 << 63) ||
//			(mantissa < 0 && -mantissa > ((uint64_t) 1 << 63))
//			)
//	{
//		DEBUG_MSG(ERROR, DEBUG_STREAM_IO, (">Invalid float value: %lldE%lld\n", mantissa, exponent));
//		return EXIP_INVALID_EXI_INPUT;
//	}

	fl_val->mantissa = mantissa;
	fl_val->exponent = (int16_t)exponent; /* TODO not using exip_config.h */

	return EXIP_OK;
}
Beispiel #2
0
bool navcoreBDParse ::processBDGSV(const char *sentence)
{
    UINT32 count;
    UINT8 i;
    UINT8 index;
    INT32 message;
    INT32 messages;
    INT32 value;
    char work[FIELD_BUFFER_LENGTH];
    const char *field;

    lastBDType = NMEA_MESSAGE_TYPE_GSV;

    field = sentence;
    message = GPS_BADVALUE;
    messages = GPS_BADVALUE;

    // messages
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        messages = decodeIntegerValue(work);
      }
    }

    // message #
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        message = decodeIntegerValue(work);
        if (message == 1) {
            //set the flag indicating if the full BDGSV set of sentences have been received
            gps_fullBDGSV=FALSE;
            if (message==1){
              gps_Rx_BDGSV1=TRUE;
              gps_Rx_BDGSV2=FALSE;
              gps_Rx_BDGSV3=FALSE;
          partialBDGSV.satelliteTracked = 0;
        }
      }
    }

      //@MIC
      gps_Rx_BDGSV4=FALSE;
      gps_Rx_BDGSV5=FALSE;
      gps_Rx_BDGSV6=FALSE;
      //@MIC
      if (messages==1){
        gps_fullBDGSV=TRUE;
      }
    }
    if ((message==2) && (gps_Rx_BDGSV1==TRUE)){
      gps_Rx_BDGSV2=TRUE;
      gps_Rx_BDGSV3=FALSE;
      //@MIC
      gps_Rx_BDGSV4=FALSE;
      gps_Rx_BDGSV5=FALSE;
      gps_Rx_BDGSV6=FALSE;
      //@MIC
      if (messages==2){
        gps_fullBDGSV=TRUE;
      }
    }
    if ((message==3) && (gps_Rx_BDGSV2==TRUE)){
      gps_Rx_BDGSV3=TRUE;
      //@MIC
      gps_Rx_BDGSV4=FALSE;
      gps_Rx_BDGSV5=FALSE;
      gps_Rx_BDGSV6=FALSE;
      //@MIC
      if (messages==3){
        gps_fullBDGSV=TRUE;
      }
    }
    //@MIC
    if ((message==4) && (gps_Rx_BDGSV3==TRUE)){
      gps_Rx_BDGSV4=TRUE;
      gps_Rx_BDGSV5=FALSE;
      gps_Rx_BDGSV6=FALSE;
      if (messages==4){
        gps_fullBDGSV=TRUE;
      }
    }
    if ((message==5) && (gps_Rx_BDGSV4==TRUE)){
      gps_Rx_BDGSV5=TRUE;
      gps_Rx_BDGSV6=FALSE;
      if (messages==5){
        gps_fullBDGSV=TRUE;
      }
    }
    if ((message==6) && (gps_Rx_BDGSV5==TRUE)){
      gps_Rx_BDGSV6=TRUE;
      if (messages==6){
        gps_fullBDGSV=TRUE;
      }
    }
    //@MIC


    // iBDore messages with null message or message count fields
    if ( (messages == GPS_BADVALUE) || (message == GPS_BADVALUE) ) {
      return FALSE;
    }

    // check that message number is in range
    if ( (message < 1) || (message > 6/*3*/) ) {
      return FALSE;
    }

    // check that number of messages is in range
    if ( (messages < 1) || (messages > 6/*3*/) ) {
      return FALSE;
    }

    // for message number 1 initialise gsv rx parameters
    if ( message == 1 ) {
      gsvFieldCount = 0;
      gsvMessageCount = 0;
      count = partialBDGSV.sentence;
      initBDGSV();
      partialBDGSV.sentence = count;
    }
    // increment message count
    gsvMessageCount++;

    // # satellites being tracked
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        if ( (value = decodeIntegerValue(work)) != GPS_BADVALUE ) {
          partialBDGSV.satelliteCount = (UINT8)value;
          gsvFieldCount++;
        }
      }
    }

    for ( i = 0; i < 4; i++ ) {
      index = (UINT8)(((message - 1) << 2) + i);

      // PRN number
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          if ( (value = decodeIntegerValue(work)) != GPS_BADVALUE ) {
            partialBDGSV.prn[index] = (UINT8)value;
            gsvFieldCount++;
          }
        }
      }

      // elevation
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          if ( (value = decodeIntegerValue(work)) != GPS_BADVALUE ) {
            partialBDGSV.elevation[index] = (UINT8)value;
            gsvFieldCount++;
          }
        }
      }

      // azimuth
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          if ( (value = decodeIntegerValue(work)) != GPS_BADVALUE ) {
            partialBDGSV.azimuth[index] = (UINT16)value;
            gsvFieldCount++;
          }
        }
      }

      // snr
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          if ( (value = decodeIntegerValue(work)) != GPS_BADVALUE ) {
            partialBDGSV.snr[index] = (UINT8)value;
            if ( value > 0 ) {
              ++partialBDGSV.satelliteTracked;
            }
            gsvFieldCount++;
          } else {
            partialBDGSV.snr[index] = 0;
          }
        }
      }
    }

    /* A complete sentence has all the appropriate fields filled */
    /* A complete SET of sentences is also true if: */
    /* if ( (message == messages) && (gsvMessageCount == messages) ) */
    if ( gsvFieldCount >= messages ) {
      // perhaps copy sentences across to valid sentences when they become valid
      partialBDGSV.sentence++;
      memcpy(&gps_BDGSV,&partialBDGSV,sizeof(partialBDGSV));
      return TRUE;
    }

    return FALSE;
  }
Beispiel #3
0
errorCode decodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime* dt_val)
{
	errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR;
	Integer year;
	unsigned int monDay = 0;
	unsigned int timeVal = 0;
	boolean presence = FALSE;

	dt_val->presenceMask = 0;

	DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (dateTime)"));

	if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_DATE || dtType == VALUE_TYPE_YEAR)
	{
		/* Year component */
		TRY(decodeIntegerValue(strm, &year));
		dt_val->dateTime.tm_year = (int)year - 100;
	}
	else
	{
		dt_val->dateTime.tm_year = INT_MIN;
	}

	if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_DATE || dtType == VALUE_TYPE_MONTH)
	{
		/* MonthDay component */
		TRY(decodeNBitUnsignedInteger(strm, 9, &monDay));
		dt_val->dateTime.tm_mon = monDay / 32 - 1;
		dt_val->dateTime.tm_mday = monDay % 32;
	}
	else
	{
		dt_val->dateTime.tm_mon = INT_MIN;
		dt_val->dateTime.tm_mday = INT_MIN;
	}

	if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_TIME)
	{
		/* Time component */
		TRY(decodeNBitUnsignedInteger(strm, 17, &timeVal));
		dt_val->dateTime.tm_hour = (timeVal / 64) / 64;
		dt_val->dateTime.tm_min = (timeVal / 64) % 64;
		dt_val->dateTime.tm_sec = timeVal % 64;

		/* FractionalSecs presence component */
		TRY(decodeBoolean(strm, &presence));
		if(presence)
		{
			UnsignedInteger fSecs = 0;
			unsigned int tmp = 0;

			dt_val->presenceMask = dt_val->presenceMask | FRACT_PRESENCE;
			dt_val->fSecs.offset = 0;
			dt_val->fSecs.value = 0;

			/* FractionalSecs component */
			TRY(decodeUnsignedInteger(strm, &fSecs));

			while(fSecs != 0)
			{
				tmp = fSecs % 10;
				dt_val->fSecs.offset++;

				if(tmp != 0)
				{
					dt_val->fSecs.value = dt_val->fSecs.value*10 + tmp;
				}

				fSecs = fSecs / 10;
			}
			dt_val->fSecs.offset -= 1;
		}
	}
	else
	{
		dt_val->dateTime.tm_hour = INT_MIN;
		dt_val->dateTime.tm_min = INT_MIN;
		dt_val->dateTime.tm_sec = INT_MIN;
	}

	/* TimeZone presence component */
	TRY(decodeBoolean(strm, &presence));

	if(presence)
	{
		unsigned int tzone = 0;
		dt_val->presenceMask = dt_val->presenceMask | TZONE_PRESENCE;
		TRY(decodeNBitUnsignedInteger(strm, 11, &tzone));
		dt_val->TimeZone = tzone;
	}

	return EXIP_OK;
}