Skip to content

Commit

Permalink
Fix GetNearestTransitionChannel() to block until a new transition is …
Browse files Browse the repository at this point in the history
…found, to make the function behave consistently when running on real-time data as well as on completed captures.
  • Loading branch information
Marcus10110 committed Jan 16, 2024
1 parent e09b414 commit 0f6a86d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 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 Expand Up @@ -344,7 +363,7 @@ const char* SMBusAnalyzer::GetAnalyzerName() const

const char* GetAnalyzerName()
{
return "SMBus";
return "SMBus2";
}

Analyzer* CreateAnalyzer()
Expand Down

0 comments on commit 0f6a86d

Please sign in to comment.