Changeset 78 in pacpussensors for trunk/SpanCPTComponent


Ignore:
Timestamp:
03/23/15 12:24:04 (9 years ago)
Author:
DHERBOMEZ Gérald
Message:
  • Usage of the new interface of win32serialport
  • Correction of a bug in frames initialization


Location:
trunk/SpanCPTComponent
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SpanCPTComponent/CPTComponent.cpp

    r59 r78  
    5757
    5858    //decoding
    59     currentDataFrame ="";
    60     currentRoadtime = 0;
    61     currentTimerange = 0;
     59    currentDataFrame_ ="";
    6260
    6361    frameToDecode = "";
     
    8987    setPortCOM( xmlParameters().getProperty("port").toLatin1() );
    9088
    91     if (!xmlParameters().getProperty("isRecording()").isNull()) {
    92         setRecording ( (xmlParameters().getProperty("isRecording()") == "true" ? true : false) );
     89    if (!xmlParameters().getProperty("recording").isNull()) {
     90        setRecording ( (xmlParameters().getProperty("recording") == "true" ? true : false) );
    9391    }
    9492    if (!xmlParameters().getProperty("verbose").isNull()) {
     
    148146
    149147    // get the frame and remove it in the list
    150     FRAME * currentFrame = serialPort->firstFrame();
     148    FRAME * currentFrame = serialPort->getNextFrame();
    151149
    152150    char * currentDataFrame = new char[currentFrame->length];
     
    154152    currentDataFrameLength_ = currentFrame->length;
    155153    currentRoadtime_ = currentFrame->t;
    156 
    157     serialPort->removeFirstFrame();
     154       
     155        // free memory
     156        delete currentFrame;
    158157
    159158    setState(ComponentBase::MONITOR_OK);
     
    174173    memcpy(buffer, currentDataFrame, currentDataFrameLength_);
    175174    buffer[currentDataFrameLength_] = '\0'; // add a \0 to convert for the conversion in QString
    176 
    177     currentDataFrame = buffer;
    178     currentRoadtime  = currentRoadtime_;
    179     currentTimerange = currentRoadtime_;
     175    currentDataFrame_ = QString::fromAscii(buffer);
     176
     177        delete[] buffer;
     178    delete[] currentDataFrame;
    180179
    181180    analyzeFrame();
     
    319318        frameToDecode = "";
    320319    }
    321     delete[] buffer;
    322     delete[] currentDataFrame;
    323320
    324321    memcpy(mAllFramesBuffer, allFramesBuffer, AllFramesSize);
     
    436433    //}
    437434
    438     currentDataFrame = restOfFrame + currentDataFrame;
     435    currentDataFrame_ = restOfFrame + currentDataFrame_;
    439436    restOfFrame = "";
    440437
    441     if (currentDataFrame.indexOf(QRegExp("[$#%]"),0)!=-1) {
    442         sofIdx_ = currentDataFrame.indexOf(QRegExp("[$#%]"),0);
     438    if (currentDataFrame_.indexOf(QRegExp("[$#%]"),0)!=-1) {
     439        sofIdx_ = currentDataFrame_.indexOf(QRegExp("[$#%]"),0);
    443440        startOfFrame = true;
    444         timeOfFrameToDecode = currentRoadtime;
    445 
    446         if (currentDataFrame.indexOf("\n",sofIdx_)!=-1) {
    447             eofIdx_ = currentDataFrame.indexOf("\n",sofIdx_);
     441        timeOfFrameToDecode = currentRoadtime_;
     442
     443        if (currentDataFrame_.indexOf("\n",sofIdx_)!=-1) {
     444            eofIdx_ = currentDataFrame_.indexOf("\n",sofIdx_);
    448445            endOfFrame = true;
    449             timerangeOfFrameToDecode = currentTimerange;
     446            timerangeOfFrameToDecode = currentTimerange_;
    450447        }
    451448        else
    452             restOfFrame = currentDataFrame;
     449            restOfFrame = currentDataFrame_;
    453450    }
    454451    else
    455         restOfFrame = currentDataFrame;
     452        restOfFrame = currentDataFrame_;
    456453
    457454    if ( (startOfFrame) && (endOfFrame) )
     
    459456        newFrameToDecode = true;
    460457        for (int i=sofIdx_;i<eofIdx_;i++)
    461             frameToDecode +=currentDataFrame.at(i);
    462         for (int j=eofIdx_+1; j<currentDataFrame.size(); j++)
    463             restOfFrame +=currentDataFrame.at(j);
     458            frameToDecode +=currentDataFrame_.at(i);
     459        for (int j=eofIdx_+1; j<currentDataFrame_.size(); j++)
     460            restOfFrame +=currentDataFrame_.at(j);
    464461        if (mVerbose) {
    465462            LOG_DEBUG("[Frame:] " << frameToDecode);
  • trunk/SpanCPTComponent/CPTComponent.h

    r59 r78  
    8484#endif
    8585
    86     road_time_t currentRoadtime_;
    87     road_timerange_t currentTimerange_;
    88     int currentDataFrameLength_;
     86
     87
    8988
    9089    bool mVerbose;
     
    111110
    112111    //Decoding
    113     QString currentDataFrame;
    114     road_time_t currentRoadtime;
    115     road_timerange_t currentTimerange;
     112    QString currentDataFrame_;
     113    road_time_t currentRoadtime_;
     114    road_timerange_t currentTimerange_;
     115        int currentDataFrameLength_;
    116116
    117117    QString frameToDecode;
Note: See TracChangeset for help on using the changeset viewer.