Ejemplo n.º 1
0
void JavaCodeGenerator::deserializeField(ofstream& ofs, TypeDeclaration& theField) {

    if (theField.declarationType == DLT_ARRAY) {
        string arrayLength = nextParamName();
        ofs << "int " + arrayLength + " = SerializationUtil.readVariableLength(dis);" << endl;
        if (theField.userTypeDefinition == NULL) {
            ofs << theField.name + " = new " + getPrimitiveTypeName(theField.dataType) + "[" + arrayLength + "];" << endl;
            ofs << "for(int i=0; i < " + arrayLength + ";i++){" << endl;

            readField(ofs, theField.dataType, theField.name + "[i]");

            ofs << "}" << endl;
        } else {
            ofs << theField.name + " = new " + theField.userTypeDefinition->name + "[" + arrayLength + "];" << endl;
            ofs << "for(int i=0; i < " + theField.name + ".length;i++){" << endl;
            ofs << theField.name + "[i] = new " << theField.userTypeDefinition->name << "();" << endl;
            ofs << theField.name + "[i].deserialize(dis);" << endl;
            ofs << "}" << endl;
        }

    } else if (theField.declarationType == DLT_USER) {
        ofs << theField.name + " = new " << theField.userTypeDefinition->name << "();" << endl;
        ofs << theField.name + ".deserialize(dis);" << endl;
    } else if (theField.declarationType == DLT_PRIMITIVE) {
        

        readField(ofs, theField.dataType, theField.name);
    } else if (theField.declarationType == DLT_BYTE_ARRAY) {
        string arrayLength = nextParamName();
        ofs << "int " + arrayLength + " = SerializationUtil.readVariableLength(dis);" << endl;
        ofs << theField.name + " = new byte[" + arrayLength + "];";
        ofs << "dos.read(" + theField.name + ");" << endl;
    }
}
Ejemplo n.º 2
0
 void fromJson( _T &v, JsonReader &json ) const
 {
     match( json, JsonReader::START_OBJECT );
     while( !match0( json, JsonReader::END_OBJECT ) )
     {
         readField( width_s, v.width, "width", json ) ||
         readField( height_s, v.height, "height", json ) ||
         ignoreField( json );
     }
 }
Ejemplo n.º 3
0
Error RPackageInfo::read(const FilePath& packageDir)
{
   // parse DCF file
   FilePath descFilePath = packageDir.childPath("DESCRIPTION");
   if (!descFilePath.exists())
      return core::fileNotFoundError(descFilePath, ERROR_LOCATION);
   std::string errMsg;
   std::map<std::string,std::string> fields;
   Error error = text::parseDcfFile(descFilePath, true, &fields, &errMsg);
   if (error)
      return error;

   error = readField(fields, "Package", &name_, descFilePath, ERROR_LOCATION);
   if (error) return error;
   
   error = readField(fields, "Version", &version_, descFilePath, ERROR_LOCATION);
   if (error) return error;
   
   readField(fields, "Depends", &depends_);
   readField(fields, "Imports", &imports_);
   readField(fields, "Suggests", &suggests_);
   readField(fields, "LinkingTo", &linkingTo_);
   readField(fields, "SystemRequirements", &systemRequirements_);
   readField(fields, "Type", &type_, kPackageType);

   return Success();
}
void
QAbstractValueEditor::readField(
    FieldContainerPtr pFC,         UInt32 uiFieldId,
    UInt32            uiValueIndex                  )
{
    readField(pFC, uiFieldId, uiValueIndex, Thread::getCurrent()->getAspect());
}
Ejemplo n.º 5
0
/**
 * @brief readRegistry return all the values for a required registry.
 * @param pFile the database to be consulted.
 * @param pRegister the row to be consulted.
 * @return
 */
array< char* > readfile::readRegistry(string pFile , int pRegister){
    array< char* > errorArray (1);
    string standardDir = "open";
    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }
    //cout << standardDir << endl;

    if ( !(file.is_open()) ){
        cout << NO_EXISTANT_DATA + pFile << endl;
        return errorArray;
    }

    //Create an array that will contain all the columns
    int columnQty = (getMetaDataSize() - METADATA_COLUMN_START)
                    / DEFAULT_COLUMN_SIZE;

    array < char* > arrayToReturn (columnQty);
    string tempString = EMPTY_STRING;
    char* toAdd;
    for (int i = ZE_ROW; i < columnQty; i++){
        tempString = readField(pFile , pRegister , i+1);
        toAdd = new char[tempString.size()+1];
        strcpy(toAdd, tempString.c_str());
        arrayToReturn[i] = toAdd;
    }

    file.close();
    return arrayToReturn;
}
Ejemplo n.º 6
0
QVariantMap Nuria::Serializer::serializeImpl (void *object, Nuria::MetaObject *meta) {
	QVariantMap map;
	this->d->curDepth--;
	
	if (!this->d->curDepth) {
		this->d->curDepth++;
		return map;
	}
	
	// 
	int fields = meta->fieldCount ();
	for (int i = 0; i < fields; i++) {
		MetaField field = meta->field (i);
		
		bool ignore = std::binary_search (this->d->excluded.constBegin (),
						  this->d->excluded.constEnd (),
						  field.name ());
		
		if (!ignore && !readField (object, field, map)) {
			this->d->failed.append (field.name ());
		}
		
	}
	
	// 
	this->d->curDepth++;
	return map;
}
Ejemplo n.º 7
0
/**
 * @brief readColumn return all the values on a named column
 * @param pFile is the database to be readed from.
 * @param pColumnName parameter for returning a value.
 * @return
 */
array<char*> readfile::readColumn(string pFile , string pColumnName){
    string standardDir;
    array <char*> errorArray (ONE_BYTE);   //if !database, return null array

    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        return errorArray;
    }

    int Column = getColumnNumber(&standardDir , &pColumnName );
    int regQty = getRegisterQuantity();
    string strToConvert = EMPTY_STRING;
    char * toAdd;
    array <char*> arrayToReturn (regQty);

    for (int rowCounter = ONE_BYTE ; rowCounter <= regQty ; rowCounter++){
        strToConvert = readField(pFile , rowCounter , pColumnName);
        toAdd = new char[strToConvert.size()+1];
        strcpy(toAdd, strToConvert.c_str());
        arrayToReturn[rowCounter - ONE_BYTE] = toAdd;
    }
    return arrayToReturn;
}
Ejemplo n.º 8
0
 void fromJson( _T &v, JsonReader &json ) const
 {
     match( json, JsonReader::START_OBJECT );
     while( !match0( json, JsonReader::END_OBJECT ) )
     {
         readField( radius_s, v.radius, "radius", json ) ||
         ignoreField( json );
     }
 }
Ejemplo n.º 9
0
void PdmlReader::readField(PdmlProtocol *pdmlProto, 
        OstProto::Protocol *pbProto)
{
    Q_ASSERT(isStartElement() && name() == "field");

    // fields with "hide='yes'" are informational and should be skipped
    if (attributes().value("hide") == "yes")
    {
        skipElement();
        return;
    }

    QString fieldName = attributes().value("name").toString();

    qDebug("  fieldName:%s", fieldName.toAscii().constData());

    pdmlProto->fieldHandler(fieldName, attributes(), pbProto, currentStream_);

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement())
        {
            if (name() == "proto")
            {
                // Since we are in the midst of processing a protocol, we
                // end it prematurely before we start processing the 
                // embedded protocol
                //
                int endPos = -1;

                if (!attributes().value("pos").isEmpty())
                    endPos = attributes().value("pos").toString().toInt();

                pdmlProto->prematureEndHandler(endPos, pbProto,
                        currentStream_);
                pdmlProto->postProtocolHandler(pbProto, currentStream_);

                StreamBase s;
                s.protoDataCopyFrom(*currentStream_);
                expPos_ = s.frameProtocolLength(0);

                readProto();
            }
            else if (name() == "field")
                readField(pdmlProto, pbProto);
            else 
                skipElement();
        }
    }
}
Ejemplo n.º 10
0
static void
readAndProcessHeaderFields(TSession *const sessionP,
                           time_t const deadline,
                           const char **const errorP,
                           uint16_t *const httpErrorCodeP) {
/*----------------------------------------------------------------------------
   Read all the HTTP header fields from the session *sessionP, which has at
   least one field coming.  Update *sessionP to reflect the information in the
   fields.

   If we find an error in the fields or while trying to read them, we return
   a text explanation of the problem as *errorP and an appropriate HTTP error
   code as *httpErrorCodeP.  Otherwise, we return *errorP = NULL and nothing
   as *httpErrorCodeP.
-----------------------------------------------------------------------------*/
    bool endOfHeader;

    assert(!sessionP->validRequest);
    /* Calling us doesn't make sense if there is already a valid request */

    *errorP = NULL;  /* initial assumption */
    endOfHeader = false;  /* Caller assures us there is at least one header */

    while (!endOfHeader && !*errorP) {
        char *field;
        bool error;
        readField(sessionP->connP, deadline, &endOfHeader, &field, &error);
        if (error) {
            xmlrpc_asprintf(errorP, "Failed to read header from "
                    "client connection.");
            *httpErrorCodeP = 408;  /* Request Timeout */
        } else {
            if (!endOfHeader) {
                char *p;
                char *fieldName;

                p = &field[0];
                getFieldNameToken(&p, &fieldName, errorP, httpErrorCodeP);
                if (!*errorP) {
                    char *fieldValue;

                    NextToken((const char **) &p);

                    fieldValue = p;

                    TableAdd(&sessionP->requestHeaderFields,
                             fieldName, fieldValue);

                    processField(fieldName, fieldValue, sessionP, errorP,
                                 httpErrorCodeP);
                }
            }
        }
    }
}
Ejemplo n.º 11
0
void GFFStruct::load() const {
	if (!_fields.empty())
		return;

	Common::SeekableReadStream &gff = _parent->getStream();

	// Read the field(s)
	if      (_fieldCount == 1)
		readField (gff, _fieldIndex);
	else if (_fieldCount > 1)
		readFields(gff, _fieldIndex, _fieldCount);
}
Ejemplo n.º 12
0
void GFF3Struct::load(uint32 offset) {
	Common::SeekableReadStream &data = _parent->getStream(offset);

	_id         = data.readUint32LE();
	_fieldIndex = data.readUint32LE();
	_fieldCount = data.readUint32LE();

	// Read the field(s)
	if      (_fieldCount == 1)
		readField (data, _fieldIndex);
	else if (_fieldCount > 1)
		readFields(data, _fieldIndex, _fieldCount);
}
Ejemplo n.º 13
0
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
(
    const IOobject& io,
    const Mesh& mesh,
    const word& fieldDictEntry
)
:
    regIOobject(io),
//    Field<Type>(0),
    mesh_(mesh), 
    dimensions_(dimless)
{
    readField(dictionary(readStream(typeName)), fieldDictEntry);
}
Ejemplo n.º 14
0
bool QSqlForm::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: readField((QWidget*)static_QUType_ptr.get(_o+1)); break;
    case 1: writeField((QWidget*)static_QUType_ptr.get(_o+1)); break;
    case 2: readFields(); break;
    case 3: writeFields(); break;
    case 4: clear(); break;
    case 5: clearValues(); break;
    case 6: clearValues((bool)static_QUType_bool.get(_o+1)); break;
    default:
	return QObject::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 15
0
void Foam::DimensionedField<Type, GeoMesh>::readIfPresent
(
    const word& fieldDictEntry
)
{
    if
    (
        (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
     || this->readOpt() == IOobject::MUST_READ
     || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
    )
    {
        readField(dictionary(readStream(typeName)), fieldDictEntry);
    }
}
Ejemplo n.º 16
0
int main() {
	int bombX, bombY;
	int fieldHeight, fieldWidth;
	char field[MAX_HEIGHT][MAX_WIDTH];

	scanf("%d %d %d %d", &fieldHeight, &fieldWidth, &bombY, &bombX);

	readField(field, fieldHeight, fieldWidth);

	explodeTile(field, fieldHeight, fieldWidth, --bombY, --bombX);

	printField(field, fieldHeight, fieldWidth);

	return 0;
}
Ejemplo n.º 17
0
int main(void){
	int row = 0, col = 0;
	int fieldNum = 0;
	while(fscanf(stdin, "%d%d", &row, &col) == 2 && row > 0 && row <= 100 && col > 0 && col <= 100){
		char** data = readField(row, col);
		parseField(data, row, col);

		if(fieldNum > 0)
			printf("\n");
		printf("Field #%d:\n", ++fieldNum);
		display(data, row, col);
		
		destroy(data, row);
	}	
	return 0;
}
Ejemplo n.º 18
0
static void
readRequestField(TSession *const sessionP,
                 time_t const deadline,
                 char **const requestLineP,
                 uint16_t *const httpErrorCodeP) {
/*----------------------------------------------------------------------------
   Read the HTTP request header field from session 'sessionP'.  We read
   through the session's internal buffer; i.e.  we may get data that was
   previously read from the network, or we may read more from the network.

   We assume the connection is presently positioned to the beginning of
   the HTTP document.  We leave it positioned after the request field.
   
   We ignore any empty lines at the beginning of the stream, per
   RFC2616 Section 4.1.

   Fail if we can't get the field before 'deadline'.

   Return as *requestLineP the request field read.  This ASCIIZ string is
   in the session's internal buffer.

   Return as *httpErrorCodeP the HTTP error code that describes how we
   are not able to read the request field, or 0 if we can.
   If we can't, *requestLineP is meaningless.
-----------------------------------------------------------------------------*/
    char *line;
    bool error;
    bool endOfHeader;

    skipToNonemptyLine(sessionP->connP, deadline, &error);

    if (!error) {
        readField(sessionP->connP, deadline, &endOfHeader, &line, &error);

        /* End of header is delimited by an empty line, and we skipped all
           the empty lines above, so readField() could not have encountered
           EOH:
        */
        assert(!endOfHeader);
    }
    if (error)
        *httpErrorCodeP = 408;  /* Request Timeout */
    else {
        *httpErrorCodeP = 0;
        *requestLineP = line;
    }
}
Ejemplo n.º 19
0
void GFF3Struct::readFields(Common::SeekableReadStream &data, uint32 index, uint32 count) {
	// Sanity check
	if (index > _parent->_header.fieldIndicesCount)
		throw Common::Exception("GFF3: Field indices index out of range (%d/%d)",
		                        index , _parent->_header.fieldIndicesCount);

	// Seek
	data.seek(_parent->_header.fieldIndicesOffset + index);

	// Read the field indices
	std::vector<uint32> indices;
	readIndices(data, indices, count);

	// Read the fields
	for (std::vector<uint32>::const_iterator i = indices.begin(); i != indices.end(); ++i)
		readField(data, *i);
}
Ejemplo n.º 20
0
bool writefile::deleteRegister(string pFile, string pCName, string newData){
    int currSeek = file.tellg();
    int Column;
    int cSize;
    string standardDir;
    bool bowl = true;

    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        standardDir = createNewFile(pFile.c_str());
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        return false;
    }

    Column = getColumnNumber(&standardDir , &pCName );
    cSize = getRegisterSize();
    int regQty = getRegisterQuantity();
    string voidField = K->EMPTY_STRING;
    int sizeToColumn = sizeUntilColumn(Column);

    fillString(&voidField,cSize);
    cout << voidField.length() <<endl;
    for (int rowCounter = K->ONE_BYTE ; rowCounter <= regQty ; rowCounter++){

        //Compare data.
        if (readField(pFile , rowCounter , Column) == newData){
            placeSeekOn(&rowCounter , &Column, &sizeToColumn, &cSize);
            if (file.is_open()){
                file << voidField;
            } else {
                bowl = false;
            }
        }
    }

    file.seekg(currSeek);
    if (file.is_open()){
        file.close();
    }
    return bowl;
}
Ejemplo n.º 21
0
int RTBinaryMessage::readMessage(const QByteArray &source)
{
  if (unsigned(source.size()) < _messageMinSize)
  {
    return 0;
  }

  QDataStream stream(source);
  stream.setByteOrder((_littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian);

  int read = 0;
  for (Field &field : _fields)
  {
    read += readField(stream, field, read);
  }

  return stream.status() == QDataStream::Ok ? read : -1;
}
Ejemplo n.º 22
0
array< array<char*> > readfile::getRegisters(string pFile, string pColumnName,
                                             string valueToConsult){
    string standardDir;
    int regs = getRegisterQuantity();
    int colNum;

    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }

    colNum = getColumnNumber(&standardDir, &pColumnName);

    array< array<char*> > select (getRegisterQuantity());

    for ( int i = ZE_ROW ; i < regs ; i ++){
        if(valueToConsult == readField(pFile,i+1,colNum)){
            select [i] = readRegistry( pFile , colNum);
        }
    }
    return select;
}
Ejemplo n.º 23
0
bool navcoreBDParse::processBDRMC(const char *sentence)
{
    UINT32 count;
     UINT8 fieldCount;
     char work[FIELD_BUFFER_LENGTH];
     const char *field;
     double  outLat  = 0;
     double  outLon = 0;

     lastBDType = NMEA_MESSAGE_TYPE_RMC;

     field = sentence;
     fieldCount = 0;

     // initialise BDRMC sentence values
     count = partialBDRMC.sentence;
     initBDRMC();
     partialBDRMC.sentence = count;
     successParse = FALSE;
     effectiveGPS = FALSE;
     // UTC
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 6 ) {
         if ( (partialBDRMC.utc = decodeTimeValue(work) ) != TIME_BAD_VALUE ) {
           fieldCount++;
         }
       }
     }

     // status
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 1 ) {
         partialBDRMC.status = work[0];
         if ( work[0] == 'A' ) {
           fieldCount++;
           //@TPE The counter is recorded when GPS status is fixed.
           if(FromUnfixToFx < FILTER_GPS_TIMES_FORM_UNFIX_TO_FIX)
             FromUnfixToFx++;
           effectiveGPS = TRUE;
         }
         else
             //@TPE The counter is reset when GPS status is unfixed.
             FromUnfixToFx = 0;
       }
     }

     // latitude
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 7 ) {
         if ( (partialBDRMC.latitude = decodeLatLong(work)) != GPS_BADVALUE ) {
           fieldCount++;
         }
       }
     }
     // latitude direction (N,S)
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 1 ) {
         fieldCount++;
         if ( (*field == 'S') && (partialBDRMC.latitude != GPS_BADVALUE) ) {
           partialBDRMC.latitude = -partialBDRMC.latitude;
         }
       }
     }

     // longitude
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 7 ) {
         if ( (partialBDRMC.longitude = decodeLatLong(work)) != GPS_BADVALUE ) {
           fieldCount++;
         }
       }
     }
     // longitude direction (E,W)
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 1 ) {
         fieldCount++;
         if ( (*field == 'W') && (partialBDRMC.longitude != GPS_BADVALUE) ) {
           partialBDRMC.longitude = -partialBDRMC.longitude;
         }
       }
     }

     // ground speed
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 3 ) {
         if ( (partialBDRMC.speed = decodeFloatValue(work)) != GPS_BADVALUE ) {
           fieldCount++;
         }
       }
     }

     // heading
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 3 ) {
         if ( (partialBDRMC.heading = decodeFloatValue(work)) != GPS_BADVALUE ) {
           fieldCount++;
         }
       }
     }

     // date
     if ( (field = findNextField(field)) != NULL ) {
       if ( readField(work,field) >= 6 ) {
         if ( (partialBDRMC.date = time_stringToUlong(NULL,work)) != TIME_BAD_VALUE ) {
           fieldCount++;
         }
       }
     }

     if(partialBDRMC.utc>0&&partialBDRMC.latitude!=GPS_BADVALUE&&partialBDRMC.longitude!=GPS_BADVALUE)
     {
         successParse = TRUE;
         utc = partialBDRMC.utc;
         latitude = partialBDRMC.latitude;
         longitude = partialBDRMC.longitude;
         speed = partialBDRMC.speed;
         heading = partialBDRMC.heading;
         date = partialBDRMC.date;
     }
     else
     {
         utc = 0;
         latitude = GPS_BADVALUE;
         longitude = GPS_BADVALUE;
     }

     if ( fieldCount >= 1 ) {
       partialBDRMC.sentence++;
       //@TPE S
       /*LOG_INFO(0, ("processBDRMC (before CN-condition +[%d, %d]",
            partialBDRMC.latitude,
            partialBDRMC.longitude));*/
   #ifdef _WIN32
       if (strncmp(gloadMapName,"CN",2)==0){
   /*      LOG_INFO(0, ("processBDRMC+[%d, %d]",
            partialBDRMC.latitude,
            partialBDRMC.longitude));*/
         ConverCHNCoords( partialBDRMC.latitude/100000.0, partialBDRMC.longitude/100000.0, &outLat, &outLon);
         partialBDRMC.latitude = (outLat*100000.0);
         partialBDRMC.longitude = (outLon*100000.0);
   /*     LOG_INFO(0, ("processBDRMC-[%d, %d]",
          partialBDRMC.latitude,
          partialBDRMC.longitude));*/
       }
   #endif
       //@TPE E
       memcpy(&gps_BDRMC,&partialBDRMC,sizeof(partialBDRMC));
       return TRUE;
     }

     return FALSE;

}
Ejemplo n.º 24
0
// parses the PTTKT sentence into the BD_partialPTTKT structure which is
// copied over to the externally visible PTTKT structure if any non null
// fields are decoded.
BOOL8 navcoreBDParse ::processPTTKT(const char *sentence)
{
  char  work[FIELD_BUFFER_LENGTH];
  UINT8 index;
  const char *field, *wrk;

  lastBDType = NMEA_MESSAGE_TYPE_TRAFFIC;

  field = sentence;

  // MESSAGE SUBTYPE
  if ( (field = findNextField(field)) != NULL ) {
    readField(work,field);
    if (strncmp (work,"DATA",4)==0)
    {
      // contains one field, which is 16 hex characters
      if ((field = findNextField(field)) != NULL)
      {
        if (readField(work,field) == 16)
        {
          // convert 16 hex characters  into UINT8 buffer
          wrk = work;
          for (index = 0; index < 8; index++) {
           BD_partialPTTKT.tmcData[index] = hexToBinary (wrk);
            wrk += 2;
          }

          BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_DATA;
          memcpy (&BD__PTTKT,&BD_partialPTTKT,sizeof(BD__PTTKT));
          return TRUE;
        }
      }
      return FALSE;
    }
    else if (strncmp (work,"STAT",4)==0)
    {
      // contains 5 fields
      for (index = 0; index < 5; index++) {
        if ((field = findNextField(field)) != NULL) {
          readField(work,field);
          switch (index) {
            case 0:
              BD_partialPTTKT.hardwarePresent = (UINT8)atoi(work);
              break;
            case 1: // tuned frequency (decimal number)
              BD_partialPTTKT.frequency = (UINT16)atoi(work);
              break;
            case 2: // Block Count (decimal number)
              BD_partialPTTKT.blockCount = (UINT8)atoi(work);
              break;
            case 3: // Traffic Message Count
              BD_partialPTTKT.tmcCount = (UINT8)atoi(work);
              break;
            case 4: // error rate (decimal number)
              BD_partialPTTKT.errorRate = (UINT8)atoi(work);
              break;
          }
        } else {
          return FALSE;
        }
      }
      BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_STATUS;
      memcpy (&BD__PTTKT,&BD_partialPTTKT,sizeof(BD__PTTKT));
      return TRUE;
    }
    else if (strncmp (work,"TUNE",4)==0)
    {
      // returns the TUNE command sent to the hardware
      // need to get the tune status from this

      // contains 2 fields (only the last is of interest)
      for (index = 0; index < 2; index++) {
        if ((field = findNextField(field)) != NULL) {
          readField(work,field);
          switch (index) {
            case 0: // frequency
              break;
            case 1: // status (0 or 1)
              BD_partialPTTKT.tuneStatus = (UINT8)atoi(work);
              break;
          }
        } else {
          return FALSE;
        }
      }

      BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_TUNE;
      memcpy (&BD__PTTKT,&BD_partialPTTKT,sizeof(BD__PTTKT));
      return TRUE;
    }
    else if (strncmp (work,"WAKE",4)==0)
    {
      // The WAKE command is generated when
      // the (Wince) target comes out of sleep mode
      BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_WAKEUP;
      BD__PTTKT.lastMessage = TMC_MSG_TYPE_WAKEUP;
      return TRUE;
    }
    else if (strncmp (work,"LIST",4)==0)
    {
      // contains 8 fields
      for (index = 0; index < 8; index++)
      {
        if ((field = findNextField(field)) != NULL)
        {
          readField(work,field);
          switch (index)
          {
            case 0: // Flag to indicate tuned freq
              BD_partialPTTKT.stnCurrent = (BOOL8)atoi(work);
              break;
            case 1: // Station Count (decimal number)
              BD_partialPTTKT.stnCount = (UINT8)atoi(work);
              break;
            case 2: // station Index (decimal number)
              BD_partialPTTKT.stnIndex = (UINT8)atoi(work);
              break;
            case 3: // station Frequency (decimal number)
              BD_partialPTTKT.stnFrequency = (UINT16)atoi(work);
              break;
            case 4: // station PI code (hex)
              wrk = work;
              BD_partialPTTKT.stnPI = (hexToBinary (wrk) << 8);
              wrk+=2;
              BD_partialPTTKT.stnPI += (hexToBinary (wrk));
              break;
            case 5: // station signal strength
              BD_partialPTTKT.stnSignal = (UINT8)atoi(work);
              break;
            case 6: // station flag
              BD_partialPTTKT.stnFlag = (UINT8)atoi(work);
              break;
            case 7: // station name
              strcpy (BD_partialPTTKT.stnName, work);
              break;
          }
        } else
        {
          return FALSE;
        }
      }
      BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_LIST;
      memcpy (&BD__PTTKT,&BD_partialPTTKT,sizeof(BD__PTTKT));
      return TRUE;
    }
    else if (strncmp (work,"SGNL",4)==0)
    {
      // contains 3 fields freq, PI, signal
      // station list entries used for storage
      for (index = 0; index < 3; index++)
      {
        if ((field = findNextField(field)) != NULL)
        {
          readField(work,field);
          switch (index)
          {
            case 0: // station Frequency (decimal number)
              BD_partialPTTKT.stnFrequency = (UINT16)atoi(work);
              break;
            case 1: // station PI code (hex)
              wrk = work;
              BD_partialPTTKT.stnPI = (hexToBinary (wrk) << 8);
              wrk+=2;
              BD_partialPTTKT.stnPI += (hexToBinary (wrk));
              break;
            case 2: // station signal strength
              BD_partialPTTKT.stnSignal = (UINT8)atoi(work);
              break;
          }
        } else
        {
          return FALSE;
        }
      }
      BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_SIGSTRENGTH;
      memcpy (&BD__PTTKT,&BD_partialPTTKT,sizeof(BD__PTTKT));
      return TRUE;
    }
    else if (strncmp (work,"RESET",5)==0)
    {
      // return the RESET command sent to the hardware
     BD_partialPTTKT.lastMessage = TMC_MSG_TYPE_RESET;
      BD__PTTKT.lastMessage = TMC_MSG_TYPE_RESET;
      return TRUE;
    }
  }
  return FALSE;
}
Ejemplo n.º 25
0
void PdmlReader::readProto()
{
    PdmlProtocol *pdmlProto = NULL;
    OstProto::Protocol *pbProto = NULL;

    Q_ASSERT(isStartElement() && name() == "proto");

    QString protoName;
    int pos = -1;
    int size = -1;

    if (!attributes().value("name").isEmpty())
        protoName = attributes().value("name").toString();
    if (!attributes().value("pos").isEmpty())
        pos = attributes().value("pos").toString().toInt();
    if (!attributes().value("size").isEmpty())
        size = attributes().value("size").toString().toInt();

    qDebug("proto: %s, pos = %d, expPos_ = %d, size = %d", 
            protoName.toAscii().constData(), pos, expPos_, size);

    // This is a heuristic to skip protocols which are not part of
    // this frame, but of a reassembled segment spanning several frames
    //   1. Proto starting pos is 0, but we've already seen some protocols
    //   2. Protocol Size exceeds frame length
    if (((pos == 0) && (currentStream_->protocol_size() > 0))
        || ((pos + size) > int(currentStream_->core().frame_len())))
    {
        skipElement();
        return;
    }

    if (isDontCareProto())
    {
        skipElement();
        return;
    }

    // if we detect a gap between subsequent protocols, we "fill-in"
    // with a "hexdump" from the pcap
    if (pos > expPos_ && pcap_)
    {
        appendHexDumpProto(expPos_, pos - expPos_);
        expPos_ = pos;
    }

    // for unknown protocol, read a hexdump from the pcap
    if (!factory_.contains(protoName) && pcap_)
    {
        int size = -1;

        if (!attributes().value("size").isEmpty())
            size = attributes().value("size").toString().toInt();

        // Check if this proto is a subset of previous proto - if so, do nothing
        if ((pos >= 0) && (size > 0) && ((pos + size) <= expPos_))
        {
            qDebug("subset proto");
            skipElement();
            return;
        }

        if (pos >= 0 && size > 0 
                && ((pos + size) <= pktBuf_.size()))
        {
            appendHexDumpProto(pos, size);
            expPos_ += size;

            skipElement();
            return;
        }
    }

    pdmlProto = appendPdmlProto(protoName, &pbProto);

    qDebug("%s: preProtocolHandler(expPos = %d)", 
            protoName.toAscii().constData(), expPos_);
    pdmlProto->preProtocolHandler(protoName, attributes(), expPos_, pbProto,
            currentStream_);

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement())
        {
            if (name() == "proto")
            {
                // an embedded proto
                qDebug("embedded proto: %s\n", attributes().value("name")
                        .toString().toAscii().constData());

                if (isDontCareProto())
                {
                    skipElement();
                    continue;
                }

                // if we are in the midst of processing a protocol, we
                // end it prematurely before we start processing the 
                // embedded protocol
                //
                // XXX: pdmlProto may be NULL for a sequence of embedded protos
                if (pdmlProto)
                {
                    int endPos = -1;

                    if (!attributes().value("pos").isEmpty())
                        endPos = attributes().value("pos").toString().toInt();

                    pdmlProto->prematureEndHandler(endPos, pbProto,
                            currentStream_);
                    pdmlProto->postProtocolHandler(pbProto, currentStream_);

                    StreamBase s;
                    s.protoDataCopyFrom(*currentStream_);
                    expPos_ = s.frameProtocolLength(0);
                }

                readProto();

                pdmlProto = NULL;
                pbProto = NULL;
            }
            else if (name() == "field")
            {
                if ((protoName == "fake-field-wrapper") &&
                        (attributes().value("name") == "tcp.segments"))
                {
                    skipElement();
                    qDebug("[skipping reassembled tcp segments]");

                    skipUntilEnd_ = true;
                    continue;
                }

                if (pdmlProto == NULL)
                {
                    pdmlProto = appendPdmlProto(protoName, &pbProto);

                    qDebug("%s: preProtocolHandler(expPos = %d)", 
                            protoName.toAscii().constData(), expPos_);
                    pdmlProto->preProtocolHandler(protoName, attributes(), 
                            expPos_, pbProto, currentStream_);
                }

                readField(pdmlProto, pbProto);
            }
            else 
                skipElement();
        }
    }

    // Close-off current protocol
    if (pdmlProto)
    {
        pdmlProto->postProtocolHandler(pbProto, currentStream_);
        freePdmlProtocol(pdmlProto);

        StreamBase s;
        s.protoDataCopyFrom(*currentStream_);
        expPos_ = s.frameProtocolLength(0);
    }
}
Ejemplo n.º 26
0
void PdmlReader::readPacket()
{
    PcapFileFormat::PcapPacketHeader pktHdr;

    Q_ASSERT(isStartElement() && name() == "packet");

    qDebug("%s: packetNum = %d", __FUNCTION__, packetCount_);

    skipUntilEnd_ = false;

    // XXX: we play dumb and convert each packet to a stream, for now
    prevStream_ = currentStream_;
    currentStream_ = streams_->add_stream();
    currentStream_->mutable_stream_id()->set_id(packetCount_);
    currentStream_->mutable_core()->set_is_enabled(true);

    // Set to a high number; will get reset to correct value during parse
    currentStream_->mutable_core()->set_frame_len(16384); // FIXME: Hard coding!

    expPos_ = 0;

    if (pcap_)
        pcap_->readPacket(pktHdr, pktBuf_);

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement())
        {
            if (skipUntilEnd_)
                skipElement();
            else if (name() == "proto")
                readProto();
            else if (name() == "field")
                readField(NULL, NULL); // TODO: top level field!!!!
            else 
                skipElement();
        }
    }

    currentStream_->mutable_core()->set_name(""); // FIXME

    // If trailing bytes are missing, add those from the pcap 
    if ((expPos_ < pktBuf_.size()) && pcap_)
    {
        OstProto::Protocol *proto = currentStream_->add_protocol();
        OstProto::HexDump *hexDump = proto->MutableExtension(
                OstProto::hexDump);

        proto->mutable_protocol_id()->set_id(
                OstProto::Protocol::kHexDumpFieldNumber);

        qDebug("adding trailing %d bytes starting from %d",
               pktBuf_.size() - expPos_, expPos_); 
        hexDump->set_content(pktBuf_.constData() + expPos_, 
                pktBuf_.size() - expPos_);
        hexDump->set_pad_until_end(false);
    } 

    packetCount_++;
    emit progress(int(characterOffset()*100/device()->size())); // in % 
    if (prevStream_)
        prevStream_->mutable_control()->CopyFrom(currentStream_->control());
    if (stop_ && *stop_)
        raiseError("USER-CANCEL");
}
Ejemplo n.º 27
0
int main() {
	int i, j, k;
	int maxIndex;
	double gradeSum;
	int participantsAmount;
	double participantScores[MAX_WIDTH];
	double participantAverages[MAX_WIDTH];
	int participantsClassfication[MAX_WIDTH];
	double participantGrades[MAX_HEIGHT][MAX_WIDTH];
	int participantPositions[MAX_HEIGHT][MAX_WIDTH];

	scanf("%d", &participantsAmount);

	readField(participantGrades, MAX_HEIGHT, participantsAmount);

	/* Cálculo da Média */
	for (j = 0; j < participantsAmount; j++) {
		gradeSum = participantGrades[0][j];

		for (i = 1; i < MAX_HEIGHT; i++) {
			gradeSum += participantGrades[i][j];
		}

		participantAverages[j] = gradeSum / MAX_HEIGHT;
	}

	{
		printf("Nota Media:");
		for (j = 0; j < participantsAmount; j++) {
			printf(" %.1f", participantAverages[j]);
		}
		printf("\n");
		printf("\n");
	}

	/* Define a ordem inicial de classificação para cada jurado. */
	for (i = 0; i < MAX_HEIGHT; i++) {
		for (j = 0; j < participantsAmount; j++) {
			participantPositions[i][j] = j;
		}

		insertionSort(&participantPositions[i][0], &participantGrades[i][0], participantsAmount);
	}

	{
		printf("Preferencia:\n");
		for (i = 0; i < MAX_HEIGHT; i++) {
			printf("Membro %d:", i + 1);
			for (j = 0; j < participantsAmount; j++) {
				printf(" %d", participantPositions[i][j] + 1);
			}
			printf("\n");
		}
		printf("\n");
	}

	for (j = 0; j < participantsAmount; j++) {
		participantScores[j] = participantAverages[j];
	}

	for (i = 0; i < MAX_HEIGHT; i++) {
		participantScores[participantPositions[i][0]] += 100;
	}

	for (k = 0; k < participantsAmount; k++) {
		maxIndex = 0;

		for (j = 1; j < participantsAmount; j++) {
			if (participantScores[maxIndex] < participantScores[j]) {
				maxIndex = j;
			}
		}

		participantsClassfication[k] = maxIndex;
		participantScores[maxIndex] = 0;

		for (i = 0; i < MAX_HEIGHT; i++) {
			if (participantPositions[i][0] == maxIndex) {
				if (participantsAmount - k > 1) {
					participantScores[participantPositions[i][1]] += 100;
				}
			}

			removeFromArray(&participantPositions[i][0], participantsAmount - k, maxIndex);
		}
	}

	{
		printf("Classificacao:");
		for (j = 0; j < participantsAmount; j++) {
			printf(" %d", participantsClassfication[j] + 1);
		}
		printf("\n");
	}

	return 0;
}
Ejemplo n.º 28
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;
  }
Ejemplo n.º 29
0
bool navcoreBDParse ::processBDGSA(const char *sentence)
{
    UINT32 count;
      UINT8 i;
      UINT8 fieldCount;
      char work[FIELD_BUFFER_LENGTH];
      const char *field;

      lastBDType = NMEA_MESSAGE_TYPE_GSA;

      field = sentence;
      fieldCount = 0;

      // initialise the BDGSA sentence parameters to defaults
      count = partialBDGSA.sentence;
      initBDGSA();
      partialBDGSA.sentence = count;

      // mode
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          partialBDGSA.mode = work[0];
          fieldCount++;
        }
      }

      // fix type
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 1 ) {
          partialBDGSA.fixType = (UINT8)(work[0] - '0');
          if ( (work[0] == '2') || (work[0] == '3') ) {
            fieldCount++;
          }
        }
      }

      // sv ID's
      for ( i = 0; i < 12; i++ ) {
        partialBDGSA.satelliteIDs[i] = 0;
        if ( (field = findNextField(field)) != NULL ) {
          if ( readField(work,field) >= 1 ) {
            // must be at least 3 valid fields for a fix
            partialBDGSA.satellitesUsed++;
            partialBDGSA.satelliteIDs[i] = (UINT8)atoi(work);
            if(atoi(work)>0 )
            {
                BD2StatelliteNum++;
            }

            fieldCount++;
          } else {
            partialBDGSA.satelliteIDs[i] = 0;
          }
        }
      }

      // pdop
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 3 ) {
          if ( (partialBDGSA.pdop = decodeFloatValue(work)) != GPS_BADVALUE ) {
            fieldCount++;
          }
        }
      }

      // hdop
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 3 ) {
          if ( (partialBDGSA.hdop = decodeFloatValue(work)) != GPS_BADVALUE ) {
            fieldCount++;
          }
        }
      }

      // vdop
      if ( (field = findNextField(field)) != NULL ) {
        if ( readField(work,field) >= 3 ) {
          if ( (partialBDGSA.vdop = decodeFloatValue(work)) != GPS_BADVALUE ) {
            fieldCount++;
          }
        }
      }

      if ( fieldCount >= 1 ) {
        partialBDGSA.sentence++;
        memcpy(&gps_BDGSA,&partialBDGSA,sizeof(partialBDGSA));
        return TRUE;
      }

      return FALSE;

}
Ejemplo n.º 30
0
bool navcoreBDParse ::processBDGGA(const char *sentence)
{
    UINT32 count;
    UINT8 fieldCount;
    char work[FIELD_BUFFER_LENGTH];
    const char *field;
    double outLat  = 0;
    double outLon = 0;

    lastBDType = NMEA_MESSAGE_TYPE_GGA;

    field = sentence;
    fieldCount = 0;

    // initialise BDGGA message values to default
    count = partialBDGGA.sentence;
    initBDGGA();
    partialBDGGA.sentence = count;
    successParse = FALSE;
    // UTC
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 6 ) {
        if ( (partialBDGGA.utc = decodeTimeValue(work) ) != TIME_BAD_VALUE ) {
          fieldCount++;
        }
      }
    }

    // latitude
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 7 ) {
        if ( (partialBDGGA.latitude = decodeLatLong(work)) != GPS_BADVALUE ) {
          fieldCount++;
        }
      }
    }
    // latitude direction (N,S)
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        fieldCount++;
        if ( (*field == 'S') && (partialBDGGA.latitude != GPS_BADVALUE) ) {
          partialBDGGA.latitude = -partialBDGGA.latitude;
        }
      }
    }

    // longitude
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 7 ) {
        if ( (partialBDGGA.longitude = decodeLatLong(work)) != GPS_BADVALUE ) {
          fieldCount++;
        }
      }
    }
    // longitude direction (E,W)
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        fieldCount++;
        if ( (*field == 'W') && (partialBDGGA.longitude != GPS_BADVALUE) ) {
          partialBDGGA.longitude = -partialBDGGA.longitude;
        }
      }
    }

    // quality
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        partialBDGGA.quality = work[0];
        if ( work[0] != '0' ) {
          fieldCount++;
        }
      }
    }

    // SV's used
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        partialBDGGA.satellitesUsed = (UINT8)atoi(work);
        fieldCount++;
      }
    }

    // Horizontal Dilution (Ignore)
    if ( (field = findNextField(field)) != NULL ) {
      readField(work,field);
    }

    // altitude
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 3 ) {
        if ( (partialBDGGA.altitude = decodeFloatValue(work)) != GPS_BADVALUE ) {
          fieldCount++;
        }
      }
    }
    // altitude direction (+,-)
    if ( (field = findNextField(field)) != NULL ) {
      if ( readField(work,field) >= 1 ) {
        fieldCount++;
        if ( (*field == '-') && (partialBDGGA.altitude != GPS_BADVALUE) ) {
          partialBDGGA.altitude = -partialBDGGA.altitude;
        }
      }
    }
    if(partialBDGGA.utc>0&&partialBDGGA.latitude!=GPS_BADVALUE&&partialBDGGA.longitude!=GPS_BADVALUE)
    {
        successParse = TRUE;
        utc = partialBDGGA.utc;
        latitude = partialBDGGA.latitude;
        longitude=partialBDGGA.longitude;
    }
    else
    {
        utc = 0;
        latitude = GPS_BADVALUE;
        longitude = GPS_BADVALUE;
    }

    if ( fieldCount >= 1 ) {
      partialBDGGA.sentence++;
      memcpy(&gps_BDGGA,&partialBDGGA,sizeof(partialBDGGA));
      return TRUE;
    }
      return FALSE;
}