Skip to content

Commit 5159acb

Browse files
authored
Merge pull request #189 from svlad-90/dev/vladyslav-goncharuk/ISSUE-188
[ISSUE #188][FILES_VIEW] Update implementation of the 'CDLTFileItem::updateIndex'
2 parents bd036a4 + 5d1c35a commit 5159acb

File tree

4 files changed

+98
-30
lines changed

4 files changed

+98
-30
lines changed

dltmessageanalyzerplugin/src/common/PlotDefinitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ static tPlotViewIDsMap createPlotIDsMap()
720720
item.id_type = ePlotViewIDType::e_Mandatory_Gantt;
721721
item.id_str = s_PLOT_GANTT_EVENT;
722722
formGanttParameters(item);
723-
item.description = QString("Declares event of a certain type ( either \"start\" or \"end\" ). "
723+
item.description = QString("Declares event of a certain type ( either \"start\" or \"end\" ). %1."
724724
"Used to identify start and end points of different events, which should "
725725
"be represented on the Gantt chart. "
726726
"Mandatory. One or more.").arg(item.getParametersDescription());

dltmessageanalyzerplugin/src/components/analyzer/src/CMTAnalyzer.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,22 @@ bool CMTAnalyzer::regexAnalysisIteration(tRequestMap::iterator& inputIt, const t
198198

199199
auto pStringData = getDataStrFromMsg(msgIdx, pMsg, *iter);
200200

201-
pStr->append(*pStringData);
202-
newRangeCounter += pStringData->size() - 1;
203-
204-
if (std::next(iter) != searchColumnsSet.end())
201+
if(nullptr != pStringData)
205202
{
206-
pStr->append(" ");
207-
newRangeCounter += 2;
208-
}
203+
pStr->append(*pStringData);
204+
newRangeCounter += pStringData->size() - 1;
205+
206+
if (std::next(iter) != searchColumnsSet.end())
207+
{
208+
pStr->append(" ");
209+
newRangeCounter += 2;
210+
}
209211

210-
tIntRange strRange(rangeCounter, rangeCounter + pStringData->size() - 1);
211-
fieldRanges.insert(*iter, strRange);
212+
tIntRange strRange(rangeCounter, rangeCounter + pStringData->size() - 1);
213+
fieldRanges.insert(*iter, strRange);
212214

213-
rangeCounter = newRangeCounter;
215+
rangeCounter = newRangeCounter;
216+
}
214217
}
215218

216219
tItemMetadata itemMetadata( msgIdx,

dltmessageanalyzerplugin/src/components/logsWrapper/src/CDLTFileWrapper.cpp

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,10 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
767767

768768
QByteArray buf;
769769
qint64 pos = 0;
770+
quint16 last_message_length = 0;
771+
quint8 version=1;
772+
qint64 lengthOffset=2;
773+
qint64 storageLength=0;
770774

771775
/* open file */
772776
if(false == mInfile.isOpen())
@@ -784,7 +788,39 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
784788
{
785789
/* move behind last found position */
786790
const QVector<qint64>* const_indexAll = &(mIndexAll);
787-
pos = (*const_indexAll)[mIndexAll.size()-1] + 4;
791+
pos = (*const_indexAll)[mIndexAll.size()-1];
792+
793+
// first move to beginnng of last found message
794+
mInfile.seek(pos);
795+
796+
// read and get file storage length
797+
buf = mInfile.read(14);
798+
if(((unsigned char)buf.at(3))==2)
799+
{
800+
storageLength = 14 + ((unsigned char)buf.at(13));
801+
}
802+
else
803+
{
804+
storageLength = 16;
805+
}
806+
807+
// read and get last message length
808+
mInfile.seek(pos + storageLength);
809+
buf = mInfile.read(7);
810+
version = (((unsigned char)buf.at(0))&0xe0)>>5;
811+
if(version==2)
812+
{
813+
lengthOffset = 5;
814+
}
815+
else
816+
{
817+
lengthOffset = 2; // default
818+
}
819+
last_message_length = (unsigned char)buf.at(lengthOffset); // was 0
820+
last_message_length = (last_message_length<<8 | ((unsigned char)buf.at(lengthOffset+1))) + storageLength; // was 1
821+
822+
// move just behind the next expected message
823+
pos += (last_message_length - 1);
788824
mInfile.seek(pos);
789825
}
790826
else {
@@ -807,6 +843,7 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
807843

808844
while(true)
809845
{
846+
810847
/* read buffer from file */
811848
buf = mInfile.read(READ_BUF_SZ);
812849
if(buf.isEmpty())
@@ -822,16 +859,37 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
822859
if(counter_header>0)
823860
{
824861
counter_header++;
825-
if (counter_header==16)
862+
if(storageLength==13 && counter_header==13)
863+
{
864+
storageLength += ((unsigned char)cbuf[num]) + 1;
865+
}
866+
else if (counter_header==storageLength)
867+
{
868+
// Read DLT protocol version
869+
version = (((unsigned char)cbuf[num])&0xe0)>>5;
870+
if(version==1)
871+
{
872+
lengthOffset = 2;
873+
}
874+
else if(version==2)
875+
{
876+
lengthOffset = 5;
877+
}
878+
else
879+
{
880+
lengthOffset = 2; // default
881+
}
882+
}
883+
else if (counter_header==(storageLength+lengthOffset)) // was 16
826884
{
827885
// Read low byte of message length
828-
message_length = static_cast<unsigned char>(cbuf[num]);
886+
message_length = (unsigned char)cbuf[num];
829887
}
830-
else if (counter_header==17)
888+
else if (counter_header==(storageLength+1+lengthOffset)) // was 17
831889
{
832890
// Read high byte of message length
833891
counter_header = 0;
834-
message_length = static_cast<quint16>((message_length<<8 | (static_cast<unsigned char>(cbuf[num]))) + 16);
892+
message_length = (message_length<<8 | ((unsigned char)cbuf[num])) + storageLength;
835893
next_message_pos = current_message_pos + message_length;
836894
if(next_message_pos==file_size)
837895
{
@@ -840,11 +898,11 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
840898
break;
841899
}
842900
// speed up move directly to next message, if inside current buffer
843-
if((message_length > 20))
901+
if((message_length > storageLength+2+lengthOffset)) // was 20
844902
{
845-
if((num+message_length-20<cbuf_sz))
903+
if((num+message_length-(storageLength+2+lengthOffset)<cbuf_sz)) // was 20
846904
{
847-
num+=message_length-20;
905+
num+=message_length-(storageLength+2+lengthOffset); // was 20
848906
}
849907
}
850908
}
@@ -861,36 +919,44 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
861919
{
862920
lastFound = 'T';
863921
}
864-
else if(lastFound == 'T' && cbuf[num] == 0x01)
922+
else if(lastFound == 'T' && (cbuf[num] == 0x01 || cbuf[num] == 0x02))
865923
{
866924
if(next_message_pos == 0)
867925
{
868926
// first message detected or first message after error
869927
current_message_pos = pos+num-3;
870-
counter_header = 1;
928+
counter_header = 3;
929+
if(cbuf[num] == 0x01)
930+
storageLength = 16;
931+
else
932+
storageLength = 13;
871933
if(current_message_pos!=0)
872934
{
873935
// first messages not at beginning or error occured before
874936
errors_in_file++;
875937
}
876938
// speed up move directly to message length, if inside current buffer
877-
if(num+14<cbuf_sz)
939+
if(num+9<cbuf_sz)
878940
{
879-
num+=14;
880-
counter_header+=14;
941+
num+=9;
942+
counter_header+=9;
881943
}
882944
}
883945
else if( next_message_pos == (pos+num-3) )
884946
{
885947
// Add message only when it is in the correct position in relationship to the last message
886948
mIndexAll.append(current_message_pos);
887949
current_message_pos = pos+num-3;
888-
counter_header = 1;
950+
counter_header = 3;
951+
if(cbuf[num] == 0x01)
952+
storageLength = 16;
953+
else
954+
storageLength = 13;
889955
// speed up move directly to message length, if inside current buffer
890-
if(num+14<cbuf_sz)
956+
if(num+9<cbuf_sz)
891957
{
892-
num+=14;
893-
counter_header+=14;
958+
num+=9;
959+
counter_header+=9;
894960
}
895961
}
896962
else if(next_message_pos > (pos+num-3))
@@ -920,7 +986,6 @@ bool CDLTFileWrapper::CSubFilesHandler::CDLTFileItem::updateIndex()
920986
}
921987

922988
mInfile.close();
923-
924989
bResult = true;
925990
}
926991
}

dltmessageanalyzerplugin/src/components/searchView/src/CSearchResultView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void CSearchResultView::copyMessageFiles()
907907
else if(selectedRowsSize == 1)
908908
{
909909
auto selectedRowModelIdx = selectedRows.front();
910-
auto selectedRowIdx = selectedRowModelIdx.sibling(selectedRowModelIdx.row(), static_cast<int>(eSearchResultColumn::UML_Applicability)).data().value<int>();
910+
auto selectedRowIdx = selectedRowModelIdx.sibling(selectedRowModelIdx.row(), static_cast<int>(eSearchResultColumn::Index)).data().value<int>();
911911

912912
mpFile->copyFileNameToClipboard(selectedRowIdx);
913913
}

0 commit comments

Comments
 (0)