Skip to content

Commit

Permalink
Reduce spamminess of skew-correct's "Lost X us!" messages (#310)
Browse files Browse the repository at this point in the history
* Hide skew-correct's "Lost X us!" messages by default

When enabling skew-correct, the "Lost X us!" messages can overwhelm the
output. Hide the messages behind the verbosity switch.

A single -v switch now shows only uncompensated time, which is what
matters most.

-vv also shows the existing message as well.

* Tweak so message prints only once in normal mode

Co-authored-by: vintagepc <53943260+vintagepc@users.noreply.github.com>
  • Loading branch information
wavexx and vintagepc authored Jun 20, 2021
1 parent 7184194 commit bb0a4e2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions parts/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,21 @@ namespace Boards {
auto tDiff = gsl::narrow<int64_t>(static_cast<uint64_t>(tWall)-tSim);
if (tDiff>1000000) // 1 ms
{
std::cout << "Lost " << std::to_string(tDiff/1000) << " us!\n";
if (tDiff>5000000) // If we lose more than 5ms, don't try to catch up.
{
if(m_pAVR->log > 1 || !m_bLostTimeLogged) {
if (!m_bLostTimeLogged) {
std::cout << "\033[1;31mWARNING: Your system cannot keep up in --skew-correct mode!\033[0m\n";
m_bLostTimeLogged = true;
}
std::cout << "Skipping " << std::to_string(tDiff/1000) << " us!\n";
}
uiLost += tDiff;
} else if(m_pAVR->log > 2)
{
std::cout << "Lost " << std::to_string(tDiff/1000) << " us!\n";
}

}
}
// if (vsim.size()<10000)
Expand Down Expand Up @@ -529,7 +539,11 @@ namespace Boards {
// {
// std::cout << std::to_string(vdC.at(i)) << ',' << std::to_string(vwall.at(i)) << ',' << std::to_string(vsim.at(i)) << '\n';
// }

if (m_bLostTimeLogged) {
std::cout << "\033[1;31mYour system was not able to keep simulation time from falling behind wall time. \033[0m\n";
std::cout << "If this number is big and you had issues with --skew-correct and real-time simulation (e.g. klipper) it's probably not a simulator bug.\n";
std::cout << "Total time lost during simulation: " << std::to_string(uiLost/1000U) << "ms\n";
}
return nullptr;
};

Expand Down
2 changes: 2 additions & 0 deletions parts/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ namespace Boards
std::atomic_bool m_bQuit = {false}, m_bReset = {false};
bool m_bIsPrimary = false, m_bCorrectSkew = false;

bool m_bLostTimeLogged = false;

pthread_t m_thread = 0;
const Wirings::Wiring &m_wiring;
std::string m_strBoard = "";
Expand Down

0 comments on commit bb0a4e2

Please sign in to comment.