|
@@ -112,7 +112,7 @@ namespace Protocol
|
|
|
{
|
|
|
//resultData.Add(new UsbDecodeResultCell(element));
|
|
|
resultEvents.emplace_back(element);
|
|
|
- resultEvents[resultEvents.size() - 1].EventIndex = resultEvents.size();
|
|
|
+ resultEvents[resultEvents.size() - 1].EventIndex = static_cast<int64_t>(resultEvents.size());
|
|
|
}
|
|
|
}
|
|
|
WriteLog(LogLevel::Level2, "ParseSingleData done");
|
|
@@ -122,7 +122,7 @@ namespace Protocol
|
|
|
bool USBDecoder::CheckTimeDifferenceWithinThreshold(const double* array, int32_t size, double threshold)
|
|
|
{
|
|
|
//threshold = 0.15;
|
|
|
- for (int i = 1; i < size; i++)
|
|
|
+ for (int i = 2; i < size; i++)
|
|
|
{
|
|
|
double difference = std::abs(array[i] - array[i - 1]);
|
|
|
double percentage_difference = difference / array[i - 1];
|
|
@@ -179,6 +179,7 @@ namespace Protocol
|
|
|
return CheckSyncSpansByArray(start_indexs, count, avg_spans);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
bool USBDecoder::CheckSyncSpansByArray(const int32_t* start_indexs, const int32_t count,
|
|
|
int32_t& avg_spans)
|
|
|
{
|
|
@@ -186,18 +187,20 @@ namespace Protocol
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- auto tmpSpans = new double[count - 1];
|
|
|
+
|
|
|
+ auto tmp_spans = new double[count - 1];
|
|
|
for (int i = 1; i < count; i++)
|
|
|
{
|
|
|
- tmpSpans[i - 1] = static_cast<double>(start_indexs[i] - start_indexs[i - 1]);
|
|
|
+ tmp_spans[i - 1] = static_cast<double>(start_indexs[i] - start_indexs[i - 1]);
|
|
|
}
|
|
|
+
|
|
|
double total_spans = 0;
|
|
|
for (int i = 0; i < count - 1; i++)
|
|
|
{
|
|
|
- total_spans += std::abs(tmpSpans[0]);
|
|
|
+ total_spans += std::abs(tmp_spans[2 + (i / 2)]);
|
|
|
}
|
|
|
avg_spans = static_cast<int>(total_spans / (count - 1));
|
|
|
- return CheckTimeDifferenceWithinThreshold(tmpSpans, count - 1);
|
|
|
+ return CheckTimeDifferenceWithinThreshold(tmp_spans, count - 1);
|
|
|
}
|
|
|
|
|
|
bool USBDecoder::FindAllSyncs(Protocol::TwoLevelEdgePulse* node, std::vector<SYNC>& all_sync
|