Skip to content

Commit

Permalink
Convert cerr/cout to ulog.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Nov 23, 2024
1 parent 4f64276 commit 203e2fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ void MainFrame::test2020Mode_()
allowed = false;
}

std::cout << "One second of 2020 decoded in " << timeTaken.count() << " ms" << std::endl;
log_info("One second of 2020 decoded in %d ms", (int)timeTaken.count());
}
#endif // !defined(LPCNET_DISABLED)

std::cout << "2020 allowed: " << allowed << std::endl;
log_info("2020 allowed: %d", (int)allowed);

// Save results to configuration.
wxGetApp().appConfiguration.freedv2020Allowed = allowed;
Expand Down
26 changes: 14 additions & 12 deletions src/rig_control/omnirig/OmniRigController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <cassert>
#include "OmniRigController.h"

#include "../../util/logging/ulog.h"

using namespace std::chrono_literals;

#define OMNI_RIG_WAIT_TIME (200ms)
Expand Down Expand Up @@ -182,8 +184,8 @@ void OmniRigController::setFrequencyImpl_(uint64_t frequencyHz)
{
if (rig_ != nullptr && frequencyHz != currFreq_)
{
std::cerr << "[OmniRig] set frequency to " << frequencyHz << std::endl;

log_info("Set frequency to %" PRIu64, frequencyHz);
HRESULT result = E_FAIL;

// Get current VFO first and try to explicitly set that VFO.
Expand All @@ -192,28 +194,28 @@ void OmniRigController::setFrequencyImpl_(uint64_t frequencyHz)
result = rig_->get_Vfo(&vfo);
if (result == S_OK)
{
std::cerr << "[OmniRig] got VFO = " << vfo << std::endl;
log_info("Got VFO = %d", (int)vfo);

if (vfo == PM_UNKNOWN)
{
std::cerr << "[OmniRig] forcing VFO to VFOA" << std::endl;
log_warn("Forcing VFO to VFOA");
rig_->put_Vfo(PM_VFOA);
vfo = PM_VFOA;
}

if (vfo == PM_VFOA || vfo == PM_VFOAA || vfo == PM_VFOAB)
{
std::cerr << "[OmniRig] setting frequency on VFOA" << std::endl;
log_info("Setting frequency on VFOA");
result = rig_->put_FreqA(frequencyHz);
}
else if (vfo == PM_VFOB || vfo == PM_VFOBB || vfo == PM_VFOBA)
{
std::cerr << "[OmniRig] setting frequency on VFOB" << std::endl;
log_info("Setting frequency on VFOB");
result = rig_->put_FreqB(frequencyHz);
}
else
{
std::cerr << "[OmniRig] neither VFOA nor VFOB are writable" << std::endl;
log_error("Neither VFOA nor VFOB are writable");
result = E_FAIL; // force use of fallback
}

Expand All @@ -225,20 +227,20 @@ void OmniRigController::setFrequencyImpl_(uint64_t frequencyHz)
if (vfo == PM_VFOA || vfo == PM_VFOAA || vfo == PM_VFOAB)
{
result = rig_->get_FreqA(&tmpFreq);
std::cerr << "[OmniRig] got freq for VFOA: " << tmpFreq << std::endl;
log_info("Got freq for VFOA: %" PRIu64, tmpFreq);
}
else if (vfo == PM_VFOB || vfo == PM_VFOBB || vfo == PM_VFOBA)
{
result = rig_->get_FreqB(&tmpFreq);
std::cerr << "[OmniRig] got freq for VFOB: " << tmpFreq << std::endl;
log_info("Got freq for VFOB: %" PRIu64, tmpFreq);
}
}
}

if (result != S_OK || tmpFreq != frequencyHz)
{
// Try VFO-less set in case the first one didn't work.
std::cerr << "[OmniRig] trying frequency set fallback" << std::endl;
log_info("Trying frequency set fallback");
result = rig_->put_Freq(frequencyHz);
std::this_thread::sleep_for(OMNI_RIG_WAIT_TIME);
}
Expand All @@ -251,7 +253,7 @@ void OmniRigController::setFrequencyImpl_(uint64_t frequencyHz)
else
{
std::stringstream errMsg;
errMsg << "Could not change frequency to " << frequencyHz << " Hz (HRESULT = " << result << ")";
log_error("Could not change frequency to %" PRIu64 " Hz (HRESULT = %d)", frequencyHz, result);
onRigError(this, errMsg.str());
}
}
Expand Down Expand Up @@ -323,7 +325,7 @@ void OmniRigController::requestCurrentFrequencyModeImpl_()
rig_->get_Freq(&freq);
rig_->get_Mode(&omniRigMode);

std::cerr << "[OmniRig] got frequency as " << freq << std::endl;
log_info("Got frequency as %ld", freq);;

// Convert OmniRig mode to our mode
IRigFrequencyController::Mode mode;
Expand Down

0 comments on commit 203e2fe

Please sign in to comment.