Skip to content

Commit

Permalink
Merge pull request #766 from bvernoux/master
Browse files Browse the repository at this point in the history
Replace usleep(..) by std::this_thread::sleep_for(std::chrono::microseconds(..)) to fix issue #765
  • Loading branch information
azonenberg committed Mar 26, 2023
2 parents 4210df3 + 66d371f commit 66719f3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scopehal/RSRTO6Oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ bool RSRTO6Oscilloscope::AcquireData()
if (len_bytes != (this_length*sizeof(float)))
{
LogError("Unexpected number of bytes back; aborting acquisition");
usleep(100000);
std::this_thread::sleep_for(std::chrono::microseconds(100000));
m_transport->FlushRXBuffer();

delete cap;
Expand Down Expand Up @@ -857,7 +857,7 @@ bool RSRTO6Oscilloscope::AcquireData()
while (m_transport->SendCommandImmediateWithReply("FORM?") != "ASC,0")
{
m_transport->SendCommandImmediate("FORM ASC; *WAI"); //Only possible to get data out in ASCII format
usleep(1000000);
std::this_thread::sleep_for(std::chrono::microseconds(1000000));
}
didAcquireAnyDigitalChannels = true;
}
Expand Down Expand Up @@ -890,7 +890,7 @@ bool RSRTO6Oscilloscope::AcquireData()
if (read_bytes != expected_bytes)
{
LogWarning("Unexpected number of bytes back; aborting acquisiton\n");
usleep(100000);
std::this_thread::sleep_for(std::chrono::microseconds(100000));
m_transport->FlushRXBuffer();

delete cap;
Expand Down Expand Up @@ -973,7 +973,7 @@ bool RSRTO6Oscilloscope::AcquireData()
if(!any_data || !m_triggerOneShot)
{
m_transport->SendCommandImmediate("SINGle");
usleep(100000);
std::this_thread::sleep_for(std::chrono::microseconds(100000));
// If we don't wait here, sending the query for available waveforms will race and return 1 for the exitisting waveform and jam everything up.
m_triggerArmed = true;
}
Expand All @@ -993,7 +993,7 @@ void RSRTO6Oscilloscope::Start()
{
LogDebug("Start\n");
m_transport->SendCommandImmediate("SINGle");
usleep(100000);
std::this_thread::sleep_for(std::chrono::microseconds(100000));
// If we don't wait here, sending the query for available waveforms will race and return 1 for the exitisting waveform and jam everything up.
m_triggerArmed = true;
m_triggerOneShot = false;
Expand All @@ -1003,7 +1003,7 @@ void RSRTO6Oscilloscope::StartSingleTrigger()
{
LogDebug("Start oneshot\n");
m_transport->SendCommandImmediate("SINGle");
usleep(100000);
std::this_thread::sleep_for(std::chrono::microseconds(100000));
// If we don't wait here, sending the query for available waveforms will race and return 1 for the exitisting waveform and jam everything up.
m_triggerArmed = true;
m_triggerOneShot = true;
Expand Down

0 comments on commit 66719f3

Please sign in to comment.