Skip to content

Commit

Permalink
Merge pull request #3 from saleae/fix/real-time-invalid-results
Browse files Browse the repository at this point in the history
Fix invalid results when running in real-time.
  • Loading branch information
Marcus10110 committed Jan 18, 2024
2 parents e09b414 + 72b0c8e commit 6caec0d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/SMBusAnalyzer.cpp
Expand Up @@ -42,11 +42,30 @@ AnalyzerChannelData* SMBusAnalyzer::AdvanceAllTo( U64 toSample )

AnalyzerChannelData* SMBusAnalyzer::GetNearestTransitionChannel()
{
// if neither channel has more transitions, block for more data.
while( !mSMBDAT->DoMoreTransitionsExistInCurrentData() && !mSMBCLK->DoMoreTransitionsExistInCurrentData() )
{
// DoMoreTransitionsExistInCurrentData will block for up to 250ms waiting for more data, and it will trigger a thread exit if the
// capture ends and there is still no more data.
}

if( !mSMBDAT->DoMoreTransitionsExistInCurrentData() )
return mSMBCLK;
{
auto next_clk_edge = mSMBCLK->GetSampleOfNextEdge();
if( !mSMBDAT->WouldAdvancingToAbsPositionCauseTransition( next_clk_edge ) )
{
return mSMBCLK;
}
}

if( !mSMBCLK->DoMoreTransitionsExistInCurrentData() )
return mSMBDAT;
{
auto next_dat_edge = mSMBDAT->GetSampleOfNextEdge();
if( !mSMBCLK->WouldAdvancingToAbsPositionCauseTransition( next_dat_edge ) )
{
return mSMBDAT;
}
}

if( mSMBDAT->GetSampleOfNextEdge() < mSMBCLK->GetSampleOfNextEdge() )
return mSMBDAT;
Expand Down

0 comments on commit 6caec0d

Please sign in to comment.