From 233557543604cf3a8bd4d14ec23ed8a15c4b602e Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Mon, 18 Jan 2021 13:47:54 -0600 Subject: [PATCH 01/10] FST4/W: Disable envelope shaping at start and end of transmission when environment variable FST4_NOSHAPING=1. Works for fst4sim too. --- lib/fst4/fst4sim.f90 | 2 +- lib/fst4/gen_fst4wave.f90 | 156 +++++++++++++++++++------------------- 2 files changed, 80 insertions(+), 78 deletions(-) diff --git a/lib/fst4/fst4sim.f90 b/lib/fst4/fst4sim.f90 index 83ac5baed..28caf2fe0 100644 --- a/lib/fst4/fst4sim.f90 +++ b/lib/fst4/fst4sim.f90 @@ -120,7 +120,7 @@ program fst4sim if(fspread.gt.0.0 .or. delay.ne.0.0) call watterson(c,nwave,NZ,fs,delay,fspread) if(fspread.lt.0.0) call lorentzian_fading(c,nwave,fs,-fspread) c=sig*c - wave=real(c) + wave=aimag(c) if(snrdb.lt.90) then do i=1,nmax !Add gaussian noise at specified SNR xnoise=gran() diff --git a/lib/fst4/gen_fst4wave.f90 b/lib/fst4/gen_fst4wave.f90 index ead00709b..74a9b34c9 100644 --- a/lib/fst4/gen_fst4wave.f90 +++ b/lib/fst4/gen_fst4wave.f90 @@ -1,91 +1,93 @@ subroutine gen_fst4wave(itone,nsym,nsps,nwave,fsample,hmod,f0, & - icmplx,cwave,wave) + icmplx,cwave,wave) - parameter(NTAB=65536) - real wave(nwave) - complex cwave(nwave),ctab(0:NTAB-1) - real, allocatable, save :: pulse(:) - real, allocatable :: dphi(:) - integer hmod - integer itone(nsym) - logical first - data first/.true./ - data nsps0/-99/ - save first,twopi,dt,tsym,nsps0,ctab + use prog_args + parameter(NTAB=65536) + real wave(nwave) + complex cwave(nwave),ctab(0:NTAB-1) + character(len=1) :: cvalue + real, allocatable, save :: pulse(:) + real, allocatable :: dphi(:) + integer hmod + integer itone(nsym) + logical first, lshape + data first/.true./ + data nsps0/-99/ + data lshape/.true./ + save first,twopi,dt,tsym,nsps0,ctab,lshape - if(first) then - twopi=8.0*atan(1.0) - do i=0,NTAB-1 - phi=i*twopi/NTAB - ctab(i)=cmplx(cos(phi),sin(phi)) - enddo - endif + if(first) then + twopi=8.0*atan(1.0) + do i=0,NTAB-1 + phi=i*twopi/NTAB + ctab(i)=cmplx(cos(phi),sin(phi)) + enddo + call get_environment_variable("FST4_NOSHAPING",cvalue,nlen) + if(nlen.eq.1 .and. cvalue.eq."1") lshape=.false. + endif - if(first.or.nsps.ne.nsps0) then - if(allocated(pulse)) deallocate(pulse) - allocate(pulse(1:3*nsps)) - dt=1.0/fsample - tsym=nsps/fsample + if(first.or.nsps.ne.nsps0) then + if(allocated(pulse)) deallocate(pulse) + allocate(pulse(1:3*nsps)) + dt=1.0/fsample + tsym=nsps/fsample ! Compute the smoothed frequency-deviation pulse - do i=1,3*nsps - tt=(i-1.5*nsps)/real(nsps) - pulse(i)=gfsk_pulse(2.0,tt) - enddo - first=.false. - nsps0=nsps - endif + do i=1,3*nsps + tt=(i-1.5*nsps)/real(nsps) + pulse(i)=gfsk_pulse(2.0,tt) + enddo + first=.false. + nsps0=nsps + endif ! Compute the smoothed frequency waveform. ! Length = (nsym+2)*nsps samples, zero-padded - allocate( dphi(0:(nsym+2)*nsps-1) ) - dphi_peak=twopi*hmod/real(nsps) - dphi=0.0 - do j=1,nsym - ib=(j-1)*nsps - ie=ib+3*nsps-1 - dphi(ib:ie) = dphi(ib:ie) + dphi_peak*pulse(1:3*nsps)*itone(j) - enddo + allocate( dphi(0:(nsym+2)*nsps-1) ) + dphi_peak=twopi*hmod/real(nsps) + dphi=0.0 + do j=1,nsym + ib=(j-1)*nsps + ie=ib+3*nsps-1 + dphi(ib:ie) = dphi(ib:ie) + dphi_peak*pulse(1:3*nsps)*itone(j) + enddo ! Calculate and insert the audio waveform - phi=0.0 - dphi = dphi + twopi*(f0-1.5*hmod/tsym)*dt !Shift frequency up by f0 - if(icmplx.eq.0) wave=0. - if(icmplx.eq.1) cwave=0. - k=0 - do j=0,(nsym+2)*nsps-1 - k=k+1 - i=phi*float(NTAB)/twopi - i=iand(i,NTAB-1) - if(icmplx.eq.0) then - wave(k)=real(ctab(i)) - else - cwave(k)=ctab(i) - endif - phi=phi+dphi(j) - if(phi.gt.twopi) phi=phi-twopi - enddo + phi=0.0 + dphi = dphi + twopi*(f0-1.5*hmod/tsym)*dt !Shift frequency up by f0 + if(icmplx.eq.0) wave=0. + if(icmplx.eq.1) cwave=0. + k=0 + do j=nsps,(nsym+1)*nsps-1 + k=k+1 + i=phi*float(NTAB)/twopi + i=iand(i,NTAB-1) + if(icmplx.eq.0) then + wave(k)=aimag(ctab(i)) + else + cwave(k)=ctab(i) + endif + phi=phi+dphi(j) + if(phi.gt.twopi) phi=phi-twopi + enddo ! Compute the ramp-up and ramp-down symbols - kshift=nsps - if(icmplx.eq.0) then - wave(1:nsps)=0.0 - wave(nsps+1:nsps+nsps/4)=wave(nsps+1:nsps+nsps/4) * & - (1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0 - k1=nsym*nsps+3*nsps/4+1 - wave((nsym+1)*nsps+1:)=0.0 - wave(k1:k1+nsps/4)=wave(k1:k1+nsps/4) * & - (1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0 - wave=cshift(wave,kshift) - else - cwave(1:nsps)=0.0 - cwave(nsps+1:nsps+nsps/4)=cwave(nsps+1:nsps+nsps/4) * & - (1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0 - k1=nsym*nsps+3*nsps/4+1 - cwave((nsym+1)*nsps+1:)=0.0 - cwave(k1:k1+nsps/4)=cwave(k1:k1+nsps/4) * & - (1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0 - cwave=cshift(cwave,kshift) - endif + if(icmplx.eq.0) then + if(lshape) then + wave(1:nsps/4)=wave(1:nsps/4) * & + (1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0 + k1=(nsym-1)*nsps+3*nsps/4+1 + wave(k1:k1+nsps/4)=wave(k1:k1+nsps/4) * & + (1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0 + endif + else + if(lshape) then + cwave(1:nsps/4)=cwave(1:nsps/4) * & + (1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0 + k1=(nsym-1)*nsps+3*nsps/4+1 + cwave(k1:k1+nsps/4)=cwave(k1:k1+nsps/4) * & + (1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0 + endif + endif - return + return end subroutine gen_fst4wave From 332ecfebf8e998bf75fc1f0757c8ce7a40834771 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 26 Jan 2021 21:34:10 +0000 Subject: [PATCH 02/10] Leave global FFTW3 clean up to main programs --- lib/four2a.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/four2a.f90 b/lib/four2a.f90 index 337ca15c3..e7e0e8018 100644 --- a/lib/four2a.f90 +++ b/lib/four2a.f90 @@ -107,7 +107,6 @@ subroutine four2a(a,nfft,ndim,isign,iform) !$omp end critical(fftw) end if enddo - call fftwf_cleanup() nplan=0 !$omp end critical(four2a) From 04ef69984136a2260006fe98614ed6362b0df3ad Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 26 Jan 2021 14:36:13 +0000 Subject: [PATCH 03/10] Add some diagnostics to PSKReporter class Sent to the severity channel log source PSKRPRT. --- Audio/soundin.cpp | 4 ++-- Logger.hpp | 14 +++++++------- Network/PSKReporter.cpp | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Audio/soundin.cpp b/Audio/soundin.cpp index 53a29799c..d9bc78446 100644 --- a/Audio/soundin.cpp +++ b/Audio/soundin.cpp @@ -184,13 +184,13 @@ void SoundInput::reset (bool report_dropped_frames) { LOG_WARN ("Detected dropped audio source samples: " << m_stream->format ().framesForDuration (lost_usec) - << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)") + << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)"); } else if (std::abs (lost_usec) > 5 * 48000) { LOG_ERROR ("Detected excessive dropped audio source samples: " << m_stream->format ().framesForDuration (lost_usec) - << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)") + << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)"); } } cummulative_lost_usec_ = elapsed_usecs - m_stream->processedUSecs (); diff --git a/Logger.hpp b/Logger.hpp index 5d497943f..0eed8aae2 100644 --- a/Logger.hpp +++ b/Logger.hpp @@ -35,16 +35,16 @@ namespace Logger BOOST_LOG_SEV (LOGGER, boost::log::trivial::LEVEL) \ << boost::log::add_value ("Line", __LINE__) \ << boost::log::add_value ("File", __FILE__) \ - << boost::log::add_value ("Function", __FUNCTION__) << ARG; + << boost::log::add_value ("Function", __FUNCTION__) << ARG /// System Log macros. /// TRACE < DEBUG < INFO < WARN < ERROR < FATAL -#define LOG_TRACE(ARG) LOG_LOG_LOCATION (sys::get(), trace, ARG); -#define LOG_DEBUG(ARG) LOG_LOG_LOCATION (sys::get(), debug, ARG); -#define LOG_INFO(ARG) LOG_LOG_LOCATION (sys::get(), info, ARG); -#define LOG_WARN(ARG) LOG_LOG_LOCATION (sys::get(), warning, ARG); -#define LOG_ERROR(ARG) LOG_LOG_LOCATION (sys::get(), error, ARG); -#define LOG_FATAL(ARG) LOG_LOG_LOCATION (sys::get(), fatal, ARG); +#define LOG_TRACE(ARG) LOG_LOG_LOCATION (sys::get(), trace, ARG) +#define LOG_DEBUG(ARG) LOG_LOG_LOCATION (sys::get(), debug, ARG) +#define LOG_INFO(ARG) LOG_LOG_LOCATION (sys::get(), info, ARG) +#define LOG_WARN(ARG) LOG_LOG_LOCATION (sys::get(), warning, ARG) +#define LOG_ERROR(ARG) LOG_LOG_LOCATION (sys::get(), error, ARG) +#define LOG_FATAL(ARG) LOG_LOG_LOCATION (sys::get(), fatal, ARG) /// Data Log macros. Does not include LINE, FILE, FUNCTION. /// TRACE < DEBUG < INFO < WARN < ERROR < FATAL diff --git a/Network/PSKReporter.cpp b/Network/PSKReporter.cpp index 35c56f23f..c072860f8 100644 --- a/Network/PSKReporter.cpp +++ b/Network/PSKReporter.cpp @@ -22,6 +22,7 @@ #include #endif +#include "Logger.hpp" #include "Configuration.hpp" #include "pimpl_impl.hpp" @@ -46,9 +47,12 @@ class PSKReporter::impl final { Q_OBJECT + using logger_type = boost::log::sources::severity_channel_logger_mt; + public: impl (PSKReporter * self, Configuration const * config, QString const& program_info) - : self_ {self} + : logger_ {boost::log::keywords::channel = "PSKRPRT"} + , self_ {self} , config_ {config} , sequence_number_ {0u} , send_descriptors_ {0} @@ -72,6 +76,7 @@ public: if (socket_ && QAbstractSocket::UdpSocket == socket_->socketType ()) { + LOG_LOG_LOCATION (logger_, trace, "enable descriptor resend"); // send templates again send_descriptors_ = 3; // three times // send receiver data set again @@ -91,6 +96,7 @@ public: && QAbstractSocket::UnconnectedState != socket_->state () && QAbstractSocket::ClosingState != socket_->state ()) { + LOG_LOG_LOCATION (logger_, trace, "create/recreate socket"); // handle re-opening asynchronously auto connection = QSharedPointer::create (); *connection = connect (socket_.data (), &QAbstractSocket::disconnected, [this, connection] () { @@ -110,6 +116,7 @@ public: void handle_socket_error (QAbstractSocket::SocketError e) { + LOG_LOG_LOCATION (logger_, trace, "err: " << e); switch (e) { case QAbstractSocket::RemoteHostClosedError: @@ -132,12 +139,14 @@ public: // be called from the disconnected handler above. if (config_->psk_reporter_tcpip ()) { + LOG_LOG_LOCATION (logger_, trace, "create TCP/IP socket"); socket_.reset (new QTcpSocket, &QObject::deleteLater); send_descriptors_ = 1; send_receiver_data_ = 1; } else { + LOG_LOG_LOCATION (logger_, trace, "create UDP/IP socket"); socket_.reset (new QUdpSocket, &QObject::deleteLater); send_descriptors_ = 3; send_receiver_data_ = 3; @@ -154,6 +163,7 @@ public: // use this for pseudo connection with UDP, allows us to use // QIODevice::write() instead of QUDPSocket::writeDatagram() socket_->connectToHost (HOST, SERVICE_PORT, QAbstractSocket::WriteOnly); + LOG_LOG_LOCATION (logger_, debug, "remote host: " << HOST << " port: " << SERVICE_PORT); if (!report_timer_.isActive ()) { @@ -169,6 +179,7 @@ public: { if (socket_) { + LOG_LOG_LOCATION (logger_, trace, "disconnecting"); socket_->disconnectFromHost (); } descriptor_timer_.stop (); @@ -180,9 +191,12 @@ public: bool flushing () { - return FLUSH_INTERVAL && !(++flush_counter_ % FLUSH_INTERVAL); + bool flush = FLUSH_INTERVAL && !(++flush_counter_ % FLUSH_INTERVAL); + LOG_LOG_LOCATION (logger_, trace, "flush: " << flush); + return flush; } + logger_type mutable logger_; PSKReporter * self_; Configuration const * config_; QSharedPointer socket_; @@ -267,6 +281,7 @@ void PSKReporter::impl::build_preamble (QDataStream& message) << quint32 (0u) // Export Time (place-holder filled in later) << ++sequence_number_ // Sequence Number << observation_id_; // Observation Domain ID + LOG_LOG_LOCATION (logger_, trace, "#: " << sequence_number_); if (send_descriptors_) { @@ -329,6 +344,7 @@ void PSKReporter::impl::build_preamble (QDataStream& message) // insert Length set_length (out, descriptor); message.writeRawData (descriptor.constData (), descriptor.size ()); + LOG_LOG_LOCATION (logger_, debug, "sent descriptors"); } } @@ -354,11 +370,13 @@ void PSKReporter::impl::build_preamble (QDataStream& message) // insert Length and move to payload set_length (out, data); message.writeRawData (data.constData (), data.size ()); + LOG_LOG_LOCATION (logger_, debug, "sent local information"); } } void PSKReporter::impl::send_report (bool send_residue) { + LOG_LOG_LOCATION (logger_, trace, "sending residue: " << send_residue); if (QAbstractSocket::ConnectedState != socket_->state ()) return; QDataStream message {&payload_, QIODevice::WriteOnly | QIODevice::Append}; @@ -391,9 +409,11 @@ void PSKReporter::impl::send_report (bool send_residue) if (tx_residue_.size ()) { tx_out.writeRawData (tx_residue_.constData (), tx_residue_.size ()); + LOG_LOG_LOCATION (logger_, debug, "sent residue"); tx_residue_.clear (); } + LOG_LOG_LOCATION (logger_, debug, "pending spots: " << spots_.size ()); while (spots_.size () || flush) { auto tx_data_size = tx_data_.size (); @@ -452,6 +472,7 @@ void PSKReporter::impl::send_report (bool send_residue) // Send data to PSK Reporter site socket_->write (payload_); // TODO: handle errors + LOG_LOG_LOCATION (logger_, debug, "sent spots"); flush = false; // break loop message.device ()->seek (0u); payload_.clear (); // Fresh message @@ -462,29 +483,35 @@ void PSKReporter::impl::send_report (bool send_residue) break; } } + LOG_LOG_LOCATION (logger_, debug, "remaining spots: " << spots_.size ()); } } PSKReporter::PSKReporter (Configuration const * config, QString const& program_info) : m_ {this, config, program_info} { + LOG_LOG_LOCATION (m_->logger_, trace, "Started for: " << program_info); } PSKReporter::~PSKReporter () { // m_->send_report (true); // send any pending spots + LOG_LOG_LOCATION (m_->logger_, trace, "Ended"); } void PSKReporter::reconnect () { + LOG_LOG_LOCATION (m_->logger_, trace, ""); m_->reconnect (); } void PSKReporter::setLocalStation (QString const& call, QString const& gridSquare, QString const& antenna) { + LOG_LOG_LOCATION (m_->logger_, trace, "call: " << call << " grid: " << gridSquare << " ant: " << antenna); m_->check_connection (); if (call != m_->rx_call_ || gridSquare != m_->rx_grid_ || antenna != m_->rx_ant_) { + LOG_LOG_LOCATION (m_->logger_, trace, "updating information"); m_->send_receiver_data_ = m_->socket_ && QAbstractSocket::UdpSocket == m_->socket_->socketType () ? 3 : 1; m_->rx_call_ = call; @@ -496,6 +523,7 @@ void PSKReporter::setLocalStation (QString const& call, QString const& gridSquar bool PSKReporter::addRemoteStation (QString const& call, QString const& grid, Radio::Frequency freq , QString const& mode, int snr) { + LOG_LOG_LOCATION (m_->logger_, trace, "call: " << call << " grid: " << grid << " freq: " << freq << " mode: " << mode << " snr: " << snr); m_->check_connection (); if (m_->socket_ && m_->socket_->isValid ()) { @@ -511,6 +539,7 @@ bool PSKReporter::addRemoteStation (QString const& call, QString const& grid, Ra void PSKReporter::sendReport (bool last) { + LOG_LOG_LOCATION (m_->logger_, trace, "last: " << last); m_->check_connection (); if (m_->socket_ && QAbstractSocket::ConnectedState == m_->socket_->state ()) { From 5ec357942404ae80ccb485c0ec2e83f5fc1e582d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 26 Jan 2021 18:22:10 +0000 Subject: [PATCH 04/10] Don't leak exceptions from ExceptionCatchingApplication::notify() --- ExceptionCatchingApplication.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ExceptionCatchingApplication.hpp b/ExceptionCatchingApplication.hpp index 8b23ab4df..04c04d62e 100644 --- a/ExceptionCatchingApplication.hpp +++ b/ExceptionCatchingApplication.hpp @@ -32,13 +32,12 @@ public: catch (std::exception const& e) { LOG_FATAL (e.what ()); - throw; } catch (...) { LOG_FATAL ("Unexpected fatal error"); - throw; } + return false; } }; From 2d6f17241ae532f637a73dec1059da5a76b98669 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 26 Jan 2021 18:28:49 +0000 Subject: [PATCH 05/10] Install correctly for RelWithDebInfo build configurations --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67a9bb827..3621b2897 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1662,7 +1662,7 @@ endif (NOT WIN32 AND NOT APPLE) # -# bundle fixup only done in Release or MinSizeRel configurations +# bundle fixup only done in non-Debug configurations # if (NOT is_debug_build) @@ -1709,7 +1709,7 @@ if (NOT is_debug_build) ${QT_PLUGINS_DIR}/imageformats ${QT_PLUGINS_DIR}/styles DESTINATION ${WSJT_PLUGIN_DESTINATION} - CONFIGURATIONS Release MinSizeRel + CONFIGURATIONS Release MinSizeRel RelWithDebInfo #COMPONENT runtime FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}" PATTERN "*minimal*${CMAKE_SHARED_LIBRARY_SUFFIX}" EXCLUDE @@ -1723,7 +1723,7 @@ if (NOT is_debug_build) FILES ${QT_PLUGINS_DIR}/sqldrivers/libqsqlite${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${WSJT_PLUGIN_DESTINATION}/sqldrivers - CONFIGURATIONS Release MinSizeRel + CONFIGURATIONS Release MinSizeRel RelWithDebInfo #COMPONENT runtime ) # install ( @@ -1767,7 +1767,7 @@ if (NOT is_debug_build) ${QT_PLUGINS_DIR}/audio ${QT_PLUGINS_DIR}/imageformats DESTINATION ${WSJT_PLUGIN_DESTINATION} - CONFIGURATIONS Release MinSizeRel + CONFIGURATIONS Release MinSizeRel RelWithDebInfo #COMPONENT runtime FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}" PATTERN "*minimal*${CMAKE_SHARED_LIBRARY_SUFFIX}" EXCLUDE @@ -1779,7 +1779,7 @@ if (NOT is_debug_build) FILES ${QT_PLUGINS_DIR}/sqldrivers/qsqlite${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${WSJT_PLUGIN_DESTINATION}/sqldrivers - CONFIGURATIONS Release MinSizeRel + CONFIGURATIONS Release MinSizeRel RelWithDebInfo #COMPONENT runtime ) # install ( From 39676602971f4834eda462d8336f387c470548bb Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 27 Jan 2021 18:02:01 +0000 Subject: [PATCH 06/10] Improved handling of exceptions and logging --- WSJTXLogging.cpp | 7 +------ main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/WSJTXLogging.cpp b/WSJTXLogging.cpp index e0ba871bd..d18d938ae 100644 --- a/WSJTXLogging.cpp +++ b/WSJTXLogging.cpp @@ -57,7 +57,7 @@ namespace void operator () (std::logic_error const& e) const { std::cout << "std::logic_error: " << e.what () << std::endl; - //throw; + throw; } }; @@ -103,11 +103,6 @@ namespace << boost::log::add_value ("Function", function) << context.category << ": " << msg.toStdWString (); } - if (QtFatalMsg == type) - { - // bail out - throw std::runtime_error {"Fatal Qt Error"}; - } } } diff --git a/main.cpp b/main.cpp index c6dd0ccbf..85e5cc95f 100644 --- a/main.cpp +++ b/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) auto const env = QProcessEnvironment::systemEnvironment (); - QApplication a(argc, argv); + ExceptionCatchingApplication a(argc, argv); try { // LOG_INfO ("+++++++++++++++++++++++++++ Resources ++++++++++++++++++++++++++++"); @@ -397,7 +397,7 @@ int main(int argc, char *argv[]) a.translate ("main", "Unable to create shared memory segment")); throw std::runtime_error {"Shared memory error"}; } - LOG_INFO ("shmem size:" << mem_jt9.size ()); + LOG_INFO ("shmem size: " << mem_jt9.size ()); } else { From 21b57dbe6fe6b12d551bba51b436dfff77de421b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 27 Jan 2021 18:11:50 +0000 Subject: [PATCH 07/10] Human readable socket error message in log --- Network/PSKReporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Network/PSKReporter.cpp b/Network/PSKReporter.cpp index c072860f8..5543c222b 100644 --- a/Network/PSKReporter.cpp +++ b/Network/PSKReporter.cpp @@ -116,7 +116,7 @@ public: void handle_socket_error (QAbstractSocket::SocketError e) { - LOG_LOG_LOCATION (logger_, trace, "err: " << e); + LOG_LOG_LOCATION (logger_, warning, "socket error: " << socket_->errorString ()); switch (e) { case QAbstractSocket::RemoteHostClosedError: From 3629a4e071543a7086983842354f9a8115c559df Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 27 Jan 2021 21:14:11 +0000 Subject: [PATCH 08/10] Qt <5.8 compatibility --- widgets/mainwindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 7ddeee776..0c94507b8 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -7249,7 +7249,12 @@ void MainWindow::rigFailure (QString const& reason) { if (m_splash && m_splash->isVisible ()) m_splash->hide (); m_rigErrorMessageBox.setDetailedText (reason + "\n\nTimestamp: " - + QDateTime::currentDateTimeUtc ().toString (Qt::ISODateWithMs)); +#if QT_VERSION >= QT_VERSION_CHECK (5, 8, 0) + + QDateTime::currentDateTimeUtc ().toString (Qt::ISODateWithMs) +#else + + QDateTime::currentDateTimeUtc ().toString ("yyyy-MM-ddTHH:mm:ss.zzzZ") +#endif + ); // don't call slot functions directly to avoid recursion m_rigErrorMessageBox.exec (); From 70802f4574e354f8d70900f4db6dd968b9f952ef Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 27 Jan 2021 23:24:07 +0000 Subject: [PATCH 09/10] Set C++ global locale as well as C one, so wide to narrow works --- main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 85e5cc95f..0960789e0 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -129,10 +129,13 @@ int main(int argc, char *argv[]) // LOG_INFO ("--------------------------- Resources ----------------------------"); QLocale locale; // get the current system locale - setlocale (LC_NUMERIC, "C"); // ensure number forms are in - // consistent format, do this after - // instantiating QApplication so - // that GUI has correct l18n + + // Set C/C++ locale used for logging etc. +#if defined (Q_OS_WIN) + std::locale::global (std::locale ("C")); +#else + std::locale::global (std::locale ("en_US.UTF-8")); +#endif // Override programs executable basename as application name. a.setApplicationName ("WSJT-X"); From bbe3d74efbac513c510cd71b21e79a16f69f43d3 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Thu, 28 Jan 2021 00:28:27 +0000 Subject: [PATCH 10/10] Tidy diagnostic messages --- Transceiver/DXLabSuiteCommanderTransceiver.cpp | 10 +++++----- Transceiver/Transceiver.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Transceiver/DXLabSuiteCommanderTransceiver.cpp b/Transceiver/DXLabSuiteCommanderTransceiver.cpp index 7991d3e82..8dca88520 100644 --- a/Transceiver/DXLabSuiteCommanderTransceiver.cpp +++ b/Transceiver/DXLabSuiteCommanderTransceiver.cpp @@ -149,7 +149,7 @@ void DXLabSuiteCommanderTransceiver::do_stop () void DXLabSuiteCommanderTransceiver::do_ptt (bool on) { - CAT_TRACE (on << state ()); + CAT_TRACE (on << ' ' << state ()); if (use_for_ptt_) { simple_command (on ? "CmdTX" : "CmdRX"); @@ -204,7 +204,7 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on) void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/) { - CAT_TRACE (f << state ()); + CAT_TRACE (f << ' ' << state ()); auto f_string = frequency_to_string (f); if (UNK != m && m != get_mode ()) { @@ -223,7 +223,7 @@ void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*n void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*/) { - CAT_TRACE (tx << state ()); + CAT_TRACE (tx << ' ' << state ()); if (tx) { auto f_string = frequency_to_string (tx); @@ -244,7 +244,7 @@ void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, MODE mode, b void DXLabSuiteCommanderTransceiver::do_mode (MODE m) { - CAT_TRACE (m << state ()); + CAT_TRACE (m << ' ' << state ()); auto m_string = map_mode (m); auto params = ("<1:%1>" + m_string).arg (m_string.size ()); simple_command (("CmdSetMode" + params).arg (params.size ())); @@ -444,7 +444,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd) // qDebug () << i << ":" << hex << int (result[i]); // } - CAT_TRACE (cmd << "->" << QString {result}); + CAT_TRACE (cmd << " -> " << QString {result}); return result; // converting raw UTF-8 bytes to QString } diff --git a/Transceiver/Transceiver.cpp b/Transceiver/Transceiver.cpp index e240d151f..5d97f0110 100644 --- a/Transceiver/Transceiver.cpp +++ b/Transceiver/Transceiver.cpp @@ -27,7 +27,7 @@ std::ostream& operator << (std::ostream& os, Transceiver::TransceiverState const { return os << "Transceiver::TransceiverState(online: " << (s.online_ ? "yes" : "no") - << " Frequency {" << s.rx_frequency_ << "Hz, " << s.tx_frequency_ << "Hz} " << s.mode_ + << " Frequency {" << s.rx_frequency_ << "Hz, " << s.tx_frequency_ << "Hz} Mode: " << s.mode_ << "; SPLIT: " << (Transceiver::TransceiverState::Split::on == s.split_ ? "on" : Transceiver::TransceiverState::Split::off == s.split_ ? "off" : "unknown") << "; PTT: " << (s.ptt_ ? "on" : "off") << ')';