summaryrefslogtreecommitdiff
path: root/map65
diff options
context:
space:
mode:
Diffstat (limited to 'map65')
-rw-r--r--map65/CMakeLists.txt3
-rw-r--r--map65/bandmap.cpp8
-rw-r--r--map65/commons.h2
-rw-r--r--map65/decode_label.h1
-rw-r--r--map65/devsetup.cpp29
-rw-r--r--map65/devsetup.ui3
-rw-r--r--map65/getsvn.cmake16
-rw-r--r--map65/libm65/CMakeLists.txt27
-rw-r--r--map65/libm65/decode0.f902
-rw-r--r--map65/libm65/decode1a.f9030
-rw-r--r--map65/libm65/display.f90283
-rw-r--r--map65/libm65/filbig.f9020
-rw-r--r--map65/libm65/ftninit.f901
-rw-r--r--map65/libm65/m65_mod.f9021
-rw-r--r--map65/libm65/map65a.f90105
-rw-r--r--map65/libm65/message_history_mod.f90109
-rw-r--r--map65/libm65/npar_ptrs_mod.f9059
-rw-r--r--map65/libm65/ptt.c138
-rw-r--r--map65/libm65/ptt.h19
-rw-r--r--map65/libm65/ptt_unix.c185
-rw-r--r--map65/libm65/q65b.F90120
-rw-r--r--map65/libm65/tmoonsub.c2
-rw-r--r--map65/liveCQSender.cpp150
-rw-r--r--map65/liveCQSender.hpp53
-rw-r--r--map65/livecq_decode.cpp143
-rw-r--r--map65/livecq_decode.hpp39
-rw-r--r--map65/mainwindow.cpp287
-rw-r--r--map65/mainwindow.h8
-rw-r--r--map65/map65_config.h.in4
-rw-r--r--map65/messages.cpp210
-rw-r--r--map65/messages.h11
-rw-r--r--map65/widegraph.cpp20
-rw-r--r--map65/widegraph.h13
33 files changed, 1048 insertions, 1073 deletions
diff --git a/map65/CMakeLists.txt b/map65/CMakeLists.txt
index 00de39fd..24437faa 100644
--- a/map65/CMakeLists.txt
+++ b/map65/CMakeLists.txt
@@ -12,7 +12,7 @@ set (map65_CXXSRCS
fortran_mutex.cpp
getdev.cpp
# getfile.cpp
- liveCQSender.cpp
+ livecq_decode.cpp
# map65_paths.cpp
main.cpp
mainwindow.cpp
@@ -24,6 +24,7 @@ set (map65_CXXSRCS
pskreporter_settings.cpp
Radio.cpp
runtime_paths.cpp
+ ../Network/LiveCQUpload.cpp
../Network/PSKReporter.cpp
../Network/PSKReporterIPFIX.cpp
set570.cpp
diff --git a/map65/bandmap.cpp b/map65/bandmap.cpp
index 3c4daecb..eba90c0f 100644
--- a/map65/bandmap.cpp
+++ b/map65/bandmap.cpp
@@ -56,8 +56,8 @@ void BandMap::setText(QString t)
tfreq=lines[i].mid(0,3);
tspace=lines[i].mid(4,1);
if(tspace==" ") tspace=bg;
- tcall=lines[i].mid(5,7);
- int n=lines[i].mid(13,1).toInt();
+ tcall=lines[i].mid(5,13);
+ int n=lines[i].mid(19,1).toInt();
if(n==0) t0 += s0;
if(n==1) t0 += s1;
if(n==2) t0 += s2;
@@ -71,8 +71,8 @@ void BandMap::setText(QString t)
tfreq=lines[i].mid(0,3);
tspace=lines[i].mid(4,1);
if(tspace==" ") tspace=bg;
- tcall=lines[i].mid(5,7);
- int n=lines[i].mid(13,1).toInt();
+ tcall=lines[i].mid(5,13);
+ int n=lines[i].mid(19,1).toInt();
if(n==0) t0 += s0;
if(n==1) t0 += s1;
if(n==2) t0 += s2;
diff --git a/map65/commons.h b/map65/commons.h
index 888e922b..8938348e 100644
--- a/map65/commons.h
+++ b/map65/commons.h
@@ -155,9 +155,7 @@ extern struct { //This is "common/datcom/..." in Fortran
void snapshot_buffers();
}
-extern QStringList allDecodes;
extern QStringList allDecodes2;
-extern QString guiDate;
extern bool m_w3szUrl;
extern QString m_otherUrl;
diff --git a/map65/decode_label.h b/map65/decode_label.h
index ecf63145..daf6cd0c 100644
--- a/map65/decode_label.h
+++ b/map65/decode_label.h
@@ -21,6 +21,7 @@ struct DecodeLabel {
qint64 last_seen_ms; // wall-clock of most recent fresh decode
int hits; // for tie-breaking when stacking
bool is_jt65; // true = JT65 (orange label); false = Q65 (yellow)
+ int last_utc = -1; // UTC (hhmm) of the Band Map decode last seen, or -1
DecodeLabel(double f, const QString& c, qint64 t, int h, bool jt65)
: freq_khz(f), callsign(c), last_seen_ms(t), hits(h), is_jt65(jt65) {}
diff --git a/map65/devsetup.cpp b/map65/devsetup.cpp
index 4fae12ea..3815c6ca 100644
--- a/map65/devsetup.cpp
+++ b/map65/devsetup.cpp
@@ -12,12 +12,7 @@
#include <QSignalBlocker>
#include <QSettings>
#include "SettingsGroup.hpp"
-
-#if !defined(Q_OS_WIN)
-extern "C" {
- void ptt_set_override(const char *path);
-}
-#endif
+#include "libm65/ptt.h"
static QStringList enumeratePorts()
{
@@ -215,17 +210,13 @@ for (id = 0; id < numDevices; id++) {
// restore saved selection
QString saved = mw->m_pttPath;
int idx = ui.pttComboBox->findText(saved);
+ if (idx < 0) {
+ ui.pttComboBox->addItem(saved);
+ idx = ui.pttComboBox->count() - 1;
+ }
if (idx >= 0)
ui.pttComboBox->setCurrentIndex(idx);
- // backend override (Linux/macOS only)
- #if !defined(Q_OS_WIN)
- if (ui.pttComboBox->currentText() != "NONE")
- ptt_set_override(ui.pttComboBox->currentText().toUtf8().constData());
- else
- ptt_set_override(nullptr);
- #endif
-
if (mw->m_fs96000 == 2)
oldSampleRate = 192000;
else if (mw->m_fs96000 == 1)
@@ -336,10 +327,12 @@ void DevSetup::accept()
mw->m_idInt=ui.idIntSpinBox->value();
mw->m_pttPath = ui.pttComboBox->currentText();
- if (mw->m_pttPath.startsWith("COM"))
- mw->m_pttPortNumber = mw->m_pttPath.mid(3).toInt();
- else
- mw->m_pttPortNumber = 1;
+ if (mw->m_pttPath == "NONE")
+ mw->m_pttPortNumber = 0;
+ else if (mw->m_pttPath.startsWith("COM"))
+ mw->m_pttPortNumber = mw->m_pttPath.mid(3).toInt();
+ else
+ mw->m_pttPortNumber = 1;
#if !defined(Q_OS_WIN)
if (ui.pttComboBox->currentText() != "NONE")
diff --git a/map65/devsetup.ui b/map65/devsetup.ui
index fa87164a..3fc2e3c3 100644
--- a/map65/devsetup.ui
+++ b/map65/devsetup.ui
@@ -279,6 +279,9 @@
</item>
<item>
<widget class="QSpinBox" name="timeoutSpinBox">
+ <property name="minimum">
+ <number>10</number>
+ </property>
<property name="maximum">
<number>40</number>
</property>
diff --git a/map65/getsvn.cmake b/map65/getsvn.cmake
deleted file mode 100644
index d1007b2c..00000000
--- a/map65/getsvn.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-find_package (Subversion)
-if (Subversion_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.svn)
- # the FindSubversion.cmake module is part of the standard distribution
- include (FindSubversion)
- # extract working copy information for SOURCE_DIR into MY_XXX variables
- Subversion_WC_INFO (${SOURCE_DIR} MY)
- # write a file with the SVNVERSION define
- file (WRITE svnversion.h.txt "#define SVNVERSION ${MY_WC_REVISION}\n")
-else (Subversion_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.svn)
- file (WRITE svnversion.h.txt "#define SVNVERSION local\n")
-endif (Subversion_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.svn)
-
-# copy the file to the final header only if the version changes
-# reduces needless rebuilds
-execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different
- svnversion.h.txt svnversion.h)
diff --git a/map65/libm65/CMakeLists.txt b/map65/libm65/CMakeLists.txt
index c0361b44..9ae45c54 100644
--- a/map65/libm65/CMakeLists.txt
+++ b/map65/libm65/CMakeLists.txt
@@ -5,6 +5,7 @@ set (libm65_FSRCS
decodes_mod.f90
extract_shared_mod.f90
gran_interface.f90
+ message_history_mod.f90
m65_mod.f90
map65_polarization_score.f90
four2a_legacy_wrap.f90
@@ -209,6 +210,8 @@ wsjt_link_common_fortran (m65impl)
if (WSJT_ENABLE_TESTS)
add_subdirectory (${CMAKE_SOURCE_DIR}/tests/unit/map65/decode_history
${CMAKE_CURRENT_BINARY_DIR}/decode_history)
+ add_subdirectory (${CMAKE_SOURCE_DIR}/tests/unit/map65/messages_retention
+ ${CMAKE_CURRENT_BINARY_DIR}/messages_retention)
add_executable (test_map65_deep_search_cache
${CMAKE_SOURCE_DIR}/tests/unit/map65/test_map65_deep_search_cache.f90)
@@ -240,6 +243,16 @@ if (WSJT_ENABLE_TESTS)
add_test (NAME test_map65_jt65_handoff COMMAND test_map65_jt65_handoff)
set_tests_properties (test_map65_jt65_handoff PROPERTIES TIMEOUT 180)
+ add_executable (test_map65_filbig_boundary
+ ${CMAKE_SOURCE_DIR}/tests/unit/map65/test_map65_filbig_boundary.f90)
+ target_include_directories (test_map65_filbig_boundary PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries (test_map65_filbig_boundary PRIVATE m65impl)
+ foreach (rate IN ITEMS 96000 192000)
+ add_test (NAME test_map65_filbig_boundary_${rate} COMMAND test_map65_filbig_boundary ${rate})
+ set_tests_properties (test_map65_filbig_boundary_${rate} PROPERTIES
+ PASS_REGULAR_EXPRESSION "MAP65 filter boundary tests passed" TIMEOUT 30)
+ endforeach ()
+
add_executable (test_q65_waveform_generator
${CMAKE_SOURCE_DIR}/tests/unit/q65/test_q65_waveform_generator.f90)
target_include_directories (test_q65_waveform_generator PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
@@ -314,6 +327,20 @@ if (WSJT_ENABLE_TESTS)
RUN_SERIAL TRUE
TIMEOUT 180)
+ add_executable (test_map65_symspec_contract
+ ${CMAKE_SOURCE_DIR}/tests/unit/map65/test_map65_symspec_contract.f90)
+ target_include_directories (test_map65_symspec_contract PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries (test_map65_symspec_contract PRIVATE m65impl)
+ add_test (NAME test_map65_symspec_96 COMMAND test_map65_symspec_contract 96000)
+ add_test (NAME test_map65_symspec_192 COMMAND test_map65_symspec_contract 192000)
+
+ add_executable (test_map65_q65_handoff
+ ${CMAKE_SOURCE_DIR}/tests/unit/map65/test_map65_q65_handoff.f90)
+ target_include_directories (test_map65_q65_handoff PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries (test_map65_q65_handoff PRIVATE m65impl)
+ add_test (NAME test_map65_q65_handoff COMMAND test_map65_q65_handoff)
+ set_tests_properties (test_map65_q65_handoff PROPERTIES TIMEOUT 180)
+
endif ()
if (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
diff --git a/map65/libm65/decode0.f90 b/map65/libm65/decode0.f90
index 26a90366..cdb8799b 100644
--- a/map65/libm65/decode0.f90
+++ b/map65/libm65/decode0.f90
@@ -60,7 +60,7 @@ contains
' nhsym0=' // itoa(nhsym0) // ' nagain=' // itoa(nagain))
endif
- nkeep = 20
+ nkeep = min(max(ntimeout, 10), 40)
call sec0(0, tquick)
call timer('decode0 ', 0)
diff --git a/map65/libm65/decode1a.f90 b/map65/libm65/decode1a.f90
index 691593fd..e55a760b 100644
--- a/map65/libm65/decode1a.f90
+++ b/map65/libm65/decode1a.f90
@@ -1,7 +1,23 @@
module decode1a_mod
+ use iso_fortran_env, only: real64
implicit none
+
+ real(real64), parameter :: jt65_demod_sample_rate = 1378.125_real64
+ integer, parameter :: jt65_fft_size = 512
+ integer, parameter :: jt65c_center_bin_offset = 132
+ real(real64), parameter :: jt65c_center_offset = &
+ jt65c_center_bin_offset * jt65_demod_sample_rate / jt65_fft_size
contains
+pure integer function jt65_demod_bin(mode65, tone) result(bin)
+ integer, intent(in) :: mode65, tone
+
+ bin = tone
+ if(mode65.eq.2) bin=2*tone-1
+ if(mode65.eq.4) bin=modulo(4*(tone-1)-jt65c_center_bin_offset, &
+ jt65_fft_size)+1
+end function jt65_demod_bin
+
subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, &
mycall,hiscall,hisgrid,neme,ndepth,nqd,dphi,ndphi, &
nutc,nkhz,ndf,ipol,ntol,sync2,a,dt,pol,nkv,nhist,nsum,nsave, &
@@ -145,6 +161,16 @@ call afc65b(c5x(i0), c5y(i0), nz, fsample, nflip, ipol, xpol, ndphi, a, ccfbest,
sq0=aa*aa*sqa + bb*bb*sqb
sync2=3.7*ccfbest/sq0
+ ! AFC follows the sync-centered stream; JT65C message tones need the
+ ! separately centered stream to keep its full 700 Hz bandwidth.
+ if(mode65.eq.4) then
+ call timer('filbig ',0)
+ call filbig(dd, nsmax_active, f0+jt65c_center_offset, newdat, &
+ nfsample, xpol, cx, cy, n5)
+ call timer('filbig ',1)
+ if(xpol) cy(:n5)=z*cy(:n5)
+ endif
+
! TEMP diagnostic 2026-09-10 for the freq/time-sync-vs-false-decode investigation.
call dbg('decode1a: afc65b fit at t=' // rtoa(sec_midn()) // &
' f0=' // rtoa(real(f0)) // ' dt00=' // rtoa(dt00) // ' dtbest=' // rtoa(dtbest) // &
@@ -185,9 +211,7 @@ call afc65b(c5x(i0), c5y(i0), nz, fsample, nflip, ipol, xpol, ndphi, a, ccfbest,
if(n.eq.1) then
do i=1,66
! s2(i,k)=real(c5a(i))**2 + aimag(c5a(i))**2
- jj=i
- if(mode65.eq.2) jj=2*i-1
- if(mode65.eq.4) jj=4*i-3
+ jj=jt65_demod_bin(mode65,i)
s2(i,k)=real(c5a(jj))**2 + aimag(c5a(jj))**2
enddo
else
diff --git a/map65/libm65/display.f90 b/map65/libm65/display.f90
index 901313c8..182384de 100644
--- a/map65/libm65/display.f90
+++ b/map65/libm65/display.f90
@@ -2,255 +2,116 @@ module display_mod
implicit none
contains
-subroutine display(nkeep, ftol)
+subroutine display(nkeep, ftol, nutc)
use stdout_channel_mod, only: write_stdout
- use iso_fortran_env, only: real64
+ use message_history_mod, only: message_record, expire_messages, recent_messages
use indexx_mod, only: indexx
- use debug_log, only: dbg, itoa, rtoa
- use sec_midn_mod, only: sec_midn
implicit none
! Arguments
integer, intent(in) :: nkeep
real, intent(in) :: ftol
+ integer, intent(in) :: nutc
- ! Parameters
- integer, parameter :: MAXLINES = 400
- integer, parameter :: MX = 400
- integer, parameter :: MAXCALLS = 500
+ ! A busy band may retain more history than the Messages window can display.
+ integer, parameter :: MAXLINES = 800
- ! Locals
- integer :: indx(MAXLINES), indx2(MX)
- character(len=83) :: line(MAXLINES), line2(MX), line3(MAXLINES)
+ ! Keep large buffers off the decoder thread's stack.
+ integer, save :: indx(MAXLINES), group_order(MAXLINES), call_order(MAXLINES)
+ character(len=83), save :: line(MAXLINES)
character(len=63) :: out, out0
- character(len=3) :: cfreq0
- character(len=6) :: callsign, callsign0
- ! N6NU 2026-05-24: bumped 12 ? 18 to carry the 5-char ndf (signed
- ! Hz offset within kHz) alongside cfreq0 in the "&" bandmap line.
- ! The C++ overlay handler (mainwindow.cpp processStdOut) reads
- ! both fields and places the tick at nkHz + ndf/1000 instead of
- ! integer kHz, which was up to �500 Hz off on signals with
- ! non-zero ndf.
- character(len=18) :: freqcall(MAXCALLS)
-
- real :: freqkHz(MAXLINES)
- integer :: utc(MAXLINES), utc2(MX), utcz
- real(real64) :: f0
+ ! 12 characters hold the longest compound calls (e.g. ER/EA8DBM, up to 11)
+ ! plus a trailing space.
+ character(len=12) :: callsign, seen_calls(MAXLINES)
+ ! Then the record's mode (# JT65, : Q65) and UTC (hhmm), so the GUI can
+ ! color the waterfall callsign label and age it from the call's latest
+ ! decode rather than from each redisplay.
+ character(len=28) :: freqcall(MAXLINES)
+
+ real, save :: freqkHz(MAXLINES), call_freqkHz(MAXLINES)
+ type(message_record), allocatable :: records(:)
+ integer :: now
character(len=83) :: livecq2, livecq3
character(len=128) :: linenew
character(len=64) :: linenew2
- integer :: io_status
- integer :: ndf, nh, nm
- integer :: i, j, j0, k, k3, kz
+ integer :: i, j, group_first, group_last, group_size
integer :: nz, nage, iage, nquad
- integer :: i0, i1, i2, len, nc, m, nstart
+ integer :: i1, i2, len, nc
! Initialize some scalars/arrays defensively
out0 = ' '
- cfreq0 = ' '
- callsign0 = ' '
freqcall = ' '
- ! TEMP diagnostic 2026-09-10 for the "decode reaches map65_rx.log but not
- ! the Messages window" investigation -- this is the entry point for the
- ! ENTIRE "@"/"&" (Messages/Band Map window) pipeline; nothing gets to
- ! those windows except through here.
- call dbg('display: ENTRY at t=' // rtoa(sec_midn()) // ' nkeep=' // itoa(nkeep))
-
- !------------------ Read and filter valid lines ---------------------
- rewind(26)
- nz = 0
-
- do i = 1, MAXLINES
- read(26,1010,end=10) line(i)
-1010 format(a83)
- read(line(i),1020,iostat=io_status) f0, ndf, nh, nm
-1020 format(f8.3,i5,25x,i3,i2)
-
- if (io_status /= 0) cycle
-
- utc(i) = 60*nh + nm
- freqkHz(i) = 1000.d0*(f0 - 144.d0) + 0.001d0*ndf
- enddo
-
-10 backspace(26)
- nz = i -1
- call dbg('display: read from unit 26, raw record count nz=' // itoa(nz))
- if (nz >= 1) utcz = utc(nz)
- nz=nz-1
+ call expire_messages(nutc, nkeep)
+ call recent_messages(MAXLINES, records)
+ call write_stdout('<Map65DisplayBegin>'//new_line('a'))
+ nz = size(records)
if (nz < 1) then
- call dbg('display: EARLY RETURN, nz<1 after decrement -- no records to emit')
return
endif
+
+ now = 60*(nutc/100) + mod(nutc, 100)
nquad = max(nkeep/4, 3)
do i = 1, nz
- nage = utcz - utc(i)
- if (nage < 0) nage = nage + 1440
+ line(i) = records(i)%line
+ freqkHz(i) = records(i)%frequency_khz
+ nage = modulo(now - records(i)%utc, 1440)
iage = nage / nquad
write(line(i)(79:80),1021) iage
1021 format(i2)
enddo
-
- nage = utcz - utc(1)
- if (nage < 0) nage = nage + 1440
- if (nage > nkeep) then
- do i = 1, nz
- nage = utcz - utc(i)
- if (nage < 0) nage = nage + 1440
- if (nage <= nkeep) go to 20
- enddo
-20 i0 = i
- nz = nz - i0 + 1
- rewind(26)
- if (nz < 1) return
- do i = 1, nz
- j = i + i0 - 1
- line(i) = line(j)
- utc(i) = utc(j)
- freqkHz(i) = freqkHz(j)
- write(26,1022) line(i)
-1022 format(a83)
- enddo
- ! Rewriting fewer records than the file previously held does not
- ! shrink it -- the old, longer tail stays on disk past this point.
- ! Without truncating here, a later rewind+read pass reads straight
- ! through into that stale leftover data and resurrects entries this
- ! trim was supposed to drop for good, causing unbounded growth of
- ! the Messages window over a long session regardless of nkeep.
- ! endfile leaves the file positioned after the EOF marker it just
- ! wrote, and Fortran forbids further sequential I/O from there
- ! without repositioning first -- backspace moves back onto that
- ! marker so the next append (map65a.f90/q65b.F90) can write there.
- endfile(26)
- backspace(26)
- endif
-
- flush(26)
call indexx(freqkHz, nz, indx)
- nstart = 1
- k3 = 0
- k = 1
- m = indx(1)
+ group_first = 1
+ do while (group_first <= nz)
+ group_last = group_first
+ do while (group_last < nz)
+ if (freqkHz(indx(group_last+1)) - freqkHz(indx(group_last)) > 2.0*ftol) exit
+ group_last = group_last + 1
+ enddo
- if (m < 1 .or. m > MAXLINES) then
- write(linenew,'(A,1X,I0,1X,I0)') 'Error in display.f90:', nz, m
- call write_stdout(trim(linenew)//new_line('a'))
- m = 1
- endif
- line2(1) = line(m)
- utc2(1) = utc(m)
- do i = 2, nz
- j0 = indx(i-1)
- j = indx(i)
- if (freqkHz(j) - freqkHz(j0) > 2.0*ftol) then
- if (nstart == 0) then
- k = k + 1
- line2(k) = ""
- utc2(k) = -1
- endif
- kz = k
- if(nstart.eq.1) then
- call indexx(float(utc2(1:kz)), kz, indx2)
- k3=0
- do k = 1, kz
- k3 = min(k3+1, MAXLINES)
- line3(k3) = line2(indx2(k))
- enddo
- nstart = 0
- else
- call indexx(float(utc2(1:kz)),kz,indx2)
- do k=1,kz
- k3=min(k3+1,400)
- line3(k3)=line2(indx2(k))
- enddo
- endif
- k= 0
- endif
- if (i == nz) then
- k = k + 1
- line2(k) = ""
- utc2(k) = -1
- endif
- k = k + 1
- line2(k) = line(j)
- utc2(k) = utc(j)
- j0=j
- enddo
- kz = k
- call indexx(float(utc2(1:kz)), kz, indx2)
- do k = 1, kz
- k3 = min(k3+1, MAXLINES)
- line3(k3) = line2(indx2(k))
+ group_size = group_last - group_first + 1
+ call indexx(real(indx(group_first:group_last)), group_size, group_order)
+ do i = 1, group_size
+ j = indx(group_first + group_order(i) - 1)
+ out = line(j)(1:13)//line(j)(28:31)//line(j)(39:45)// &
+ line(j)(35:38)//line(j)(46:80)
+ if (out(6:8) == ' ') cycle
+ if (out(19:22) == out0(19:22) .and. out(31:55) == out0(31:55) .and. &
+ out(6:8) == out0(6:8)) cycle
+ livecq2 = line(j)
+ livecq3 = out(1:61)//' '//livecq2(23:27)//' '//livecq2(79:83)
+ write(linenew,'("@",A)') trim(livecq3)
+ call write_stdout(trim(linenew)//new_line('a'))
+ out0 = out
+ enddo
+ group_first = group_last + 1
enddo
- rewind 19
- rewind 20
- cfreq0=' '
nc = 0
- callsign0=' '
- call dbg('display: about to walk k3=' // itoa(k3) // ' sorted records for "@" emission')
- do k = 1, k3
- out = line3(k)(1:13)//line3(k)(28:31)//line3(k)(39:45)// &
- line3(k)(35:38)//line3(k)(46:80)
- livecq2 = line3(k)
- if (out(6:8) /= ' ') then
- cfreq0 = out(6:8)
-
-! Suppress listing duplicate (same time, decoded message, and frequency)
- if (out(19:22) /= out0(19:22) .or. out(31:55) /= out0(31:55) .or. &
- out(6:8) /= out0(6:8)) then
- livecq3 = out(1:61)//' '//livecq2(23:27)//' '//livecq2(79:83)
- write(linenew,'("@",A)') trim(livecq3)
- call write_stdout(trim(linenew)//new_line('a'))
- call dbg('display: k=' // itoa(k) // ' "@" EMITTED freq=' // out(6:8) // &
- ' utc=' // out(19:22) // ' msg="' // trim(out(31:55)) // '"')
- out0 = out
- else
- call dbg('display: k=' // itoa(k) // ' "@" SUPPRESSED (matches out0) freq=' // out(6:8) // &
- ' utc=' // out(19:22) // ' msg="' // trim(out(31:55)) // &
- '" -- out0 was freq=' // out0(6:8) // ' utc=' // out0(19:22) // &
- ' msg="' // trim(out0(31:55)) // '"')
- endif
-
- i1 = index(out(31:), ' ')
- callsign = out(i1+31:)
- i2 = index(callsign, ' ')
- if (i2 > 1) callsign(i2:) = ' '
- if (callsign /= ' ' .and. callsign /= callsign0) then
- len = i2 - 1
- if (len < 0) len = 6
- if (len >= 3) then
- if (nc < MAXCALLS) nc = nc + 1
- freqcall(nc) = cfreq0//line3(k)(9:13)//' '//callsign//line3(k)(79:80)
- callsign0=callsign
- endif
- endif
- if (callsign /= ' ' .and. callsign == callsign0) then
- if (nc > 0 .and. nc <= MAXCALLS) then
- freqcall(nc) = cfreq0//line3(k)(9:13)//' '//callsign//line3(k)(79:80)
- endif
- endif
- else
- call dbg('display: k=' // itoa(k) // ' SKIPPED entirely (out(6:8) blank -- not a frequency record)')
- endif
+ do i = nz, 1, -1
+ out = line(i)(1:13)//line(i)(28:31)//line(i)(39:45)// &
+ line(i)(35:38)//line(i)(46:80)
+ if (out(6:8) == ' ') cycle
+ i1 = index(out(31:), ' ')
+ if (i1 == 0) cycle
+ callsign = out(i1+31:)
+ i2 = index(callsign, ' ')
+ if (i2 > 1) callsign(i2:) = ' '
+ len = i2 - 1
+ if (len < 0) len = 6
+ if (len < 3 .or. callsign == ' ') cycle
+ if (any(seen_calls(1:nc) == callsign)) cycle
+ nc = nc + 1
+ seen_calls(nc) = callsign
+ freqcall(nc) = out(6:8)//line(i)(9:13)//' '//callsign//line(i)(79:81)//line(i)(40:43)
+ call_freqkHz(nc) = freqkHz(i)
enddo
- call dbg('display: done, nc(bandmap entries)=' // itoa(nc))
-
-if(nc.lt.MAXCALLS) nc=nc+1
-freqcall(nc)=' '
-
-if(nc.lt.MAXCALLS) nc=nc+1
-freqcall(nc)=' '
-
-if (nc+1 <= MAXCALLS) freqcall(nc+1) = ' '
-if (nc+2 <= MAXCALLS) freqcall(nc+2) = ' '
-
-
+ if (nc > 0) call indexx(call_freqkHz, nc, call_order)
do i = 1, nc
- write(linenew2,'("&",A)') trim(freqcall(i))
+ write(linenew2,'("&",A)') trim(freqcall(call_order(i)))
call write_stdout(trim(linenew2)//new_line('a'))
enddo
diff --git a/map65/libm65/filbig.f90 b/map65/libm65/filbig.f90
index bfbaf7a5..2e967034 100644
--- a/map65/libm65/filbig.f90
+++ b/map65/libm65/filbig.f90
@@ -172,21 +172,19 @@ contains
endif
enddo
- ! Upper half of filter, with wrap-around and bounds check
+ ! Upper half of filter, wrapping negative-frequency bins
do i = nh + 1, nfft2
j = i0 + i - 1 - nfft2
if (j .lt. 1) j = j + nfft1
- if (j < 1 .or. j > size(ca)) then
- write (dbg_unit, *) 'FILBIG OOB: i=', i, ' j=', j, ' nh=', nh, &
- ' nfft1=', nfft1, ' nfft2=', nfft2, ' i0=', i0
- flush(dbg_unit)
- stop 'FILBIG index OOB'
- end if
-
- filtval = real(cfilt_buf(i)) - base
- c4a_buf(i) = filtval*ca(j)
- if (xpol) c4b_buf(i) = filtval*cb(j)
+ if (j .ge. 1 .and. j .le. nfft1) then
+ filtval = real(cfilt_buf(i)) - base
+ c4a_buf(i) = filtval*ca(j)
+ if (xpol) c4b_buf(i) = filtval*cb(j)
+ else
+ c4a_buf(i) = 0.0
+ if (xpol) c4b_buf(i) = 0.0
+ endif
enddo
! Do the short reverse transform, to go back to time domain.
diff --git a/map65/libm65/ftninit.f90 b/map65/libm65/ftninit.f90
index 28f95fd4..789d7f93 100644
--- a/map65/libm65/ftninit.f90
+++ b/map65/libm65/ftninit.f90
@@ -19,7 +19,6 @@ subroutine ftninit(appd)
open(13,file=appd//'/map65.log',status='unknown')
! open(19,file=appd//'/livecq.txt',status='unknown') ! not written with new livecq code
open(21, file=appd//'/map65_rx.log', status='unknown', position='append', err=950)
- open(26,file=appd//'/tmp26.txt',status='unknown')
! Import FFTW wisdom, if available:
iret=fftwf_init_threads() !Initialize FFTW threading
diff --git a/map65/libm65/m65_mod.f90 b/map65/libm65/m65_mod.f90
index 7710293f..a7b8b581 100644
--- a/map65/libm65/m65_mod.f90
+++ b/map65/libm65/m65_mod.f90
@@ -11,6 +11,7 @@ subroutine m65c() bind(C)
use decode0_mod
use npar_ptrs_mod, only: nhsym, nrxlog, datetime, active_input_generation, nagain, ndiskdat, manualDecodeFlag
use debug_log, only: dbg, itoa, rtoa
+ use message_history_mod, only: clear_messages
use sec_midn_mod, only: sec_midn
integer :: npatience, nstandalone
integer, save :: nhsym_prev_m65c = -1
@@ -32,30 +33,16 @@ subroutine m65c() bind(C)
nrxlog = ibclr(nrxlog,1)
endif
if(iand(nrxlog,4).ne.0) then
- ! rewind alone only repositions to record 1 for writing; it does not
- ! shrink the file, so old history beyond whatever gets written this
- ! cycle would stay on disk and could resurface via display.f90's own
- ! rewind+read the same way the missing endfile there did (see
- ! set_map65RxLog in npar_ptrs_mod.f90 for how Erase reaches here).
- ! endfile makes this an immediate, real truncation to empty -- but it
- ! leaves the file positioned after the EOF marker it just wrote, and
- ! Fortran forbids further sequential I/O from there without
- ! repositioning first, so backspace right away to land back on that
- ! marker, ready for the next append.
- !
! An expired final request must not hide the next accumulation cycle.
if(nhsym.eq.nhsym1 .and. (nhsym_prev_m65c.ne.nhsym1 .or. &
previous_input_generation.ne.active_input_generation)) then
- call dbg('m65c: UNIT26 TRUNCATED (endfile) at t=' // rtoa(sec_midn()) // &
+ call dbg('m65c: message history cleared at t=' // rtoa(sec_midn()) // &
' nhsym=' // itoa(nhsym) // ' nrxlog=' // itoa(nrxlog))
- rewind(26)
- endfile(26)
- backspace(26)
+ call clear_messages()
else if (nhsym.eq.nhsym1) then
- call dbg('m65c: UNIT26 truncation SKIPPED (repeat call at nhsym1) at t=' // &
+ call dbg('m65c: message history clear skipped (repeat call at nhsym1) at t=' // &
rtoa(sec_midn()) // ' nrxlog=' // itoa(nrxlog))
endif
- if(nhsym.eq.nhsym2) backspace(26)
endif
nhsym_prev_m65c = nhsym
if(nagain.eq.0 .and. ndiskdat.eq.0 .and. manualDecodeFlag.eq.0) &
diff --git a/map65/libm65/map65a.f90 b/map65/libm65/map65a.f90
index cece6ec9..90326477 100644
--- a/map65/libm65/map65a.f90
+++ b/map65/libm65/map65a.f90
@@ -23,6 +23,7 @@ contains
use stdout_channel_mod, only: write_stdout
use decodes_mod, only: nhsym1, ldecoded, ljt65decoded, ndecodes, mcall3a, decodes_init
use display_mod
+ use message_history_mod, only: append_message, has_message
use timf2_mod
use getdphi_mod
use datcom_ptrs_mod, only: ss_old, savg_old
@@ -86,6 +87,7 @@ contains
type(candidate) :: cand(MAX_CANDIDATES)
real(real64) :: f00
character(len=256) :: line
+ character(len=83) :: history_line
integer :: n_rms, i2
real*8 :: rms, sumsq, v
real*4 :: tsec_mod
@@ -99,6 +101,9 @@ contains
integer :: best_i, best_ipol2
real :: sync1_tmp, dt_tmp, flipk_tmp, syncshort_tmp, snr2_tmp, dt2_tmp
integer :: ipol_tmp, ipol2_tmp,ftol_bins, manualDecodeFlag_initial
+ integer :: i_click, il, iu, jsep, sh_j, sh_il, sh_iu, sh_ipol2
+ real :: sh_sync, sh_snr2, sh_dt2, u_snr2, u_dt2
+ integer :: u_ipol2
real :: freq_q65
integer :: nhsym_prev_call
integer(c_int64_t) :: previous_input_generation = -1
@@ -221,6 +226,7 @@ contains
i = nint(freq*1000.0/df) + icenter ! bin corresponding to that RF
i = max(51, min(nfft_active - 51, i))
+ i_click = i
! --- local search around clicked bin within ftol ---
ftol = real(ntol)
@@ -284,25 +290,59 @@ contains
!===========================
! SHORTHAND DETECTION (JT65)
!===========================
+ ! Same rule as the wideband quick decode (nqd=1).
shorthand_detected = .false.
-
thresh0 = 1.0
- if (syncshort > thresh0 .and. mode65 > 0) then
+ if (ntol .le. 100) thresh0 = 0.
+ sh_j = 0
+ if (mode65 > 0) then
+ sh_sync = thresh0
+ do j = 2, 4
+ jsep = nint(j*mode65*10.0*(11025.0/4096.0)/df)
+ do ii = -ftol_bins, ftol_bins
+ il = i_click + ii
+ iu = il + jsep
+ if (il < 51 .or. iu > nfft_active - 51) cycle
+ ssmax = 1.e30
+ call ccf65(ss_dec(:,:,iu), nhsym, ssmax, sync1_tmp, ipol_tmp, jpz, dt_tmp, flipk_tmp, &
+ syncshort_tmp, u_snr2, u_ipol2, u_dt2)
+ if (syncshort_tmp <= sh_sync) cycle
+ syncshort = syncshort_tmp
+ ssmax = 1.e30
+ call ccf65(ss_dec(:,:,il), nhsym, ssmax, sync1_tmp, ipol_tmp, jpz, dt_tmp, flipk_tmp, &
+ syncshort_tmp, snr2_tmp, ipol2_tmp, dt2_tmp)
+ if (syncshort_tmp <= thresh0) cycle
+ sh_sync = syncshort
+ sh_j = j
+ sh_il = il
+ sh_iu = iu
+ sh_snr2 = u_snr2
+ sh_ipol2 = u_ipol2
+ sh_dt2 = u_dt2
+ enddo
+ enddo
+ endif
+ call dbg('map65a manual: shorthand search thresh0=' // rtoa(thresh0) // ' found=' // itoa(sh_j) // &
+ ' syncshort=' // rtoa(merge(sh_sync, -99.0, sh_j > 0)))
+
+ if (sh_j > 0) then
shorthand_detected = .true.
km = 1
sig(1,1) = nfile
sig(1,2) = nutc
- sig(1,3) = freq
- sig(1,4) = syncshort
- sig(1,5) = dt2
- sig(1,6) = 45*(ipol2 - 1)/57.2957795
+ sig(1,3) = 0.001*(sh_il - icenter)*df + 0.5*(nfa + nfb)
+ sig(1,4) = sh_sync
+ sig(1,5) = sh_dt2
+ sig(1,6) = 45*(sh_ipol2 - 1)/57.2957795
sig(1,7) = 0
- sig(1,8) = snr2
+ sig(1,8) = sh_snr2
sig(1,9) = 0
sig(1,10)= 0
- sig(1,12)= savg_dec(ipol2,i)
- msg(1) = shmsg0(1)
+ sig(1,12)= savg_dec(sh_ipol2, sh_iu)
+ sig(1,13:16) = 0
+ sig(1,18) = 0
+ msg(1) = shmsg0(sh_j)
endif
! Bin frequency for this click (for decode1a’s f00)
@@ -313,11 +353,12 @@ contains
noffset = nint(1000.0*(freq - fqso) - mousedf)
- ! JT65-specific rejects only when JT65 is active
+ ! JT65-specific rejects only when JT65 is active. A detected
+ ! shorthand is still reported even though sync1 failed.
if (mode65 > 0) then
if (sync1 <= thresh1) then
- if (.not. bq65) then
+ if (.not. bq65 .and. .not. shorthand_detected) then
! JT65-only mode → real reject
newdat = 0
km = 0
@@ -336,7 +377,7 @@ contains
if (abs(noffset) > ntol) then
- if (.not. bq65) then
+ if (.not. bq65 .and. .not. shorthand_detected) then
! JT65-only mode → real reject
newdat = 0
@@ -463,9 +504,9 @@ contains
q65_success = (nsnr0 .gt. -99)
! On success, q65b has already written the decoded text itself
- ! (write_stdout, plus units 26/21/12) because nqd=1 and the result
- ! is within ntol of mousedf -- the same mechanism the wideband
- ! quick-decode pass uses. Nothing further to add to km/msg/sig here.
+ ! (write_stdout, plus the history and units 21/12) because nqd=1
+ ! and the result is within ntol of mousedf. The wideband quick
+ ! decode uses the same path. Nothing further to add to km/msg/sig.
endif
!===========================
@@ -522,9 +563,35 @@ contains
write (line, '("!",I3,I5,I4,I6.4,F5.1,I5,1X,A1,1X,A22,I2,I5,I5,1X,A1)') &
nkHz, ndf, npol, nutc, dt, nsync2, cm, decoded, nkv, nqual, ntxpol, cp
call write_stdout(trim(line)//new_line('a'))
+
+ ! Keep manual decodes out of both histories when the wideband
+ ! pass or an earlier click already recorded the same decode.
+ if (.not. has_message(f0, nutc, decoded)) then
+ do j = 1, 5
+ a(j) = sig(k, 12 + j)
+ enddo
+ ndf0 = nint(a(1))
+ ndf1 = nint(a(2))
+ ndf2 = nint(a(3))
+ cmode = '#A'
+ if (mode65 .eq. 2) cmode = '#B'
+ if (mode65 .eq. 4) cmode = '#C'
+ write (history_line, 1014) f0, ndf, ndf0, ndf1, ndf2, dt, npol, nsync1, &
+ nsync2, nutc, decoded, '#', cp, cmode
+ call append_message(history_line, nutc, f0, ndf)
+ ndecodes = ndecodes + 1
+ write (21, 1100) f0, ndf, dt, npol, nsync2, nutc, decoded, '#', cp, &
+ cmode(1:1), cmode(2:2)
+ endif
endif
enddo ! k=1,km
+ ! Refresh Messages and Band Map after the manual pass.
+ ! 0.010 is the wideband pass's ftol (kHz); the ftol above is
+ ! the click tolerance in Hz.
+ flush (21)
+ call display(nkeep, 0.010, nutc)
+
manualDecodeFlag = 0
return
endif
@@ -1141,9 +1208,10 @@ endif
cmode = '#A'
if (mode65 .eq. 2) cmode = '#B'
if (mode65 .eq. 4) cmode = '#C'
- write (26, 1014) f0, ndf, ndf0, ndf1, ndf2, dt, npol, nsync1, &
+ write (history_line, 1014) f0, ndf, ndf0, ndf1, ndf2, dt, npol, nsync1, &
nsync2, nutc, decoded, '#', cp, cmode ! was decoded,cp,
1014 format(f8.3, i5, 3i3, f5.1, i4, i3, i4, i5.4, 4x, a22, 7x, 2a1, 2x, a2) ! was a22,2x,a1,3x,a2
+ call append_message(history_line, nutc, f0, ndf)
ndecodes = ndecodes + 1
write (21, 1100) f0, ndf, dt, npol, nsync2, nutc, decoded, '#', cp, &
cmode(1:1), cmode(2:2)! was decoded,cp,
@@ -1151,11 +1219,8 @@ endif
endif
enddo
- write (26, 1015) nutc
-1015 format(37x, i6.4, ' ')
flush (21)
- flush (26)
- call display(nkeep, ftol)
+ call display(nkeep, ftol, nutc)
ndecdone = 2
900 close (23)
diff --git a/map65/libm65/message_history_mod.f90 b/map65/libm65/message_history_mod.f90
new file mode 100644
index 00000000..155cfaed
--- /dev/null
+++ b/map65/libm65/message_history_mod.f90
@@ -0,0 +1,109 @@
+module message_history_mod
+ use iso_fortran_env, only: int64, real64
+ implicit none
+ private
+
+ type, public :: message_record
+ character(len=83) :: line
+ integer :: utc
+ real :: frequency_khz
+ integer(int64) :: inserted_tick
+ end type message_record
+
+ type(message_record), allocatable :: history(:)
+ integer :: history_count = 0
+
+ public :: append_message, clear_messages, expire_messages, recent_messages, has_message, message_expired
+
+contains
+
+ subroutine append_message(line, nutc, frequency_mhz, ndf)
+ character(len=*), intent(in) :: line
+ integer, intent(in) :: nutc, ndf
+ real(real64), intent(in) :: frequency_mhz
+ type(message_record), allocatable :: larger(:)
+ integer :: capacity
+
+ if (.not. allocated(history)) allocate(history(128))
+ if (history_count == size(history)) then
+ capacity = 2*size(history)
+ allocate(larger(capacity))
+ larger(:history_count) = history
+ call move_alloc(larger, history)
+ endif
+
+ history_count = history_count + 1
+ history(history_count)%line = line
+ history(history_count)%utc = 60*(nutc/100) + mod(nutc, 100)
+ history(history_count)%frequency_khz = &
+ real(1000.0_real64*(frequency_mhz - 144.0_real64) + 0.001_real64*ndf)
+ call system_clock(count=history(history_count)%inserted_tick)
+ end subroutine append_message
+
+ subroutine clear_messages()
+ history_count = 0
+ end subroutine clear_messages
+
+ subroutine expire_messages(nutc, nkeep)
+ integer, intent(in) :: nutc, nkeep
+ integer :: i, kept, now
+ integer(int64) :: now_tick, tick_rate, stored_s
+
+ now = 60*(nutc/100) + mod(nutc, 100)
+ call system_clock(count=now_tick, count_rate=tick_rate)
+ kept = 0
+ do i = 1, history_count
+ stored_s = -1
+ if (tick_rate > 0 .and. now_tick >= history(i)%inserted_tick) &
+ stored_s = (now_tick - history(i)%inserted_tick)/tick_rate
+ if (message_expired(modulo(now - history(i)%utc, 1440), stored_s, nkeep)) cycle
+ kept = kept + 1
+ if (kept /= i) history(kept) = history(i)
+ enddo
+ history_count = kept
+ end subroutine expire_messages
+
+ ! utc_age_min decides expiry. stored_s (seconds since the record was
+ ! stored, -1 if unknown) only guards against the same UTC minute on a
+ ! later day, so it allows a margin: a record can be stored up to a pass
+ ! length before the display that ages it, so at the nkeep edge its
+ ! wall-clock age exceeds 60*nkeep.
+ logical function message_expired(utc_age_min, stored_s, nkeep)
+ integer, intent(in) :: utc_age_min, nkeep
+ integer(int64), intent(in) :: stored_s
+ message_expired = utc_age_min > nkeep .or. stored_s > 60_int64*(nkeep + 2)
+ end function message_expired
+
+ subroutine recent_messages(max_records, records)
+ integer, intent(in) :: max_records
+ type(message_record), allocatable, intent(out) :: records(:)
+ integer :: count
+
+ count = min(history_count, max_records)
+ allocate(records(count))
+ if (count > 0) records = history(history_count-count+1:history_count)
+ end subroutine recent_messages
+
+ logical function has_message(frequency_mhz, nutc, decoded)
+ real(real64), intent(in) :: frequency_mhz
+ integer, intent(in) :: nutc
+ character(len=*), intent(in) :: decoded
+ character(len=83) :: probe
+ integer :: i
+
+ probe = ' '
+ write(probe(1:8), '(f8.3)') frequency_mhz
+ write(probe(39:43), '(i5.4)') nutc
+ probe(48:69) = decoded
+
+ has_message = .false.
+ do i = history_count, 1, -1
+ if (history(i)%line(1:8) /= probe(1:8)) cycle
+ if (history(i)%line(39:43) /= probe(39:43)) cycle
+ if (history(i)%line(48:69) /= probe(48:69)) cycle
+ has_message = .true.
+ return
+ enddo
+ end function has_message
+
+end module message_history_mod
diff --git a/map65/libm65/npar_ptrs_mod.f90 b/map65/libm65/npar_ptrs_mod.f90
index f33a92fc..10c9b904 100644
--- a/map65/libm65/npar_ptrs_mod.f90
+++ b/map65/libm65/npar_ptrs_mod.f90
@@ -40,7 +40,56 @@ module npar_ptrs_mod
character(len=20) :: datetime = ''
end type
- ! GUI setters prepare draft; only the decoder changes active after claiming a request.
+ ! ---------------------------------------------------------------------------
+ ! Decode parameters: draft vs. active
+ !
+ ! Two copies of decode_parameters exist, and which one you touch matters.
+ !
+ ! draft Owned by the GUI thread. Every set_xxx()/get_xxx() bind(C)
+ ! routine in this module reads or writes draft, under
+ ! lock_decode_requests(). It holds the *pending* GUI state, not
+ ! necessarily what the decoder is using right now.
+ !
+ ! active Owned by the decode thread. The module pointers below (nkeep,
+ ! ntimeout, mycall, ...) alias fields of active, so Fortran decode
+ ! code that says "ntimeout" is reading active%ntimeout.
+ !
+ ! Flow:
+ ! MainWindow::decode() -> set_xxx() writes draft
+ ! publish_decode_request() copies draft into a queued request (forcing
+ ! newdat = 1 in that copy) and clears
+ ! draft%manualDecodeFlag
+ ! claim_decode_request() copies the oldest request into active; an
+ ! automatic live request whose input generation
+ ! is out of date is marked expired, and run_m65
+ ! skips it (<DecodeSkipped>)
+ ! initialize_decode_parameters() copies draft into active once, at startup
+ ! The decoder then sees a consistent snapshot for the whole pass, even if
+ ! the GUI changes draft meanwhile.
+ !
+ ! Why a lock alone is not enough: a decode pass runs for many seconds and
+ ! reads its parameters throughout. The lock only protects the instant of a
+ ! write, so if setters wrote the decoder's own variables directly, a GUI
+ ! change mid-pass would still alter values partway through the decode. The
+ ! draft/active copy is what freezes the parameters for a pass and lets
+ ! requests queue; the lock keeps publish_decode_request from copying a
+ ! half-written draft.
+ !
+ ! Rules:
+ ! * C++ callers: a get_xxx() returns draft, i.e. the pending GUI value,
+ ! not the value the running decode is using.
+ ! * A parameter only reaches the decoder if the GUI writes it to draft
+ ! before a request is published. Setting it once and never re-pushing
+ ! works only if nothing else overwrites it (decode() currently re-pushes
+ ! most values every cycle).
+ ! * Fortran code may write active fields only for state it owns (e.g.
+ ! manualDecodeFlag = 0, nkeep = ...). Such writes do NOT flow back to
+ ! draft, so the next published request will carry draft's old value.
+ ! If a value must persist across requests, change it in draft too.
+ ! * Never add a second variable for the same setting (cf. the old
+ ! map65RxLog vs. nrxlog bug, where the setter wrote one variable and the
+ ! decoder read the other).
+ ! ---------------------------------------------------------------------------
type(decode_parameters), target, save :: active
type(decode_parameters), save :: draft
type :: decode_request
@@ -475,14 +524,6 @@ contains
subroutine set_map65RxLog(val) bind(C, name="set_map65RxLog")
use iso_c_binding
integer(c_int), value :: val
- ! map65RxLog is read back by get_map65RxLog() for debug logging only.
- ! nrxlog is the variable m65c()/decode0.f90 actually check (iand bits
- ! 1/2/4/8) to write the date header, erase map65_rx.log, clear the
- ! decode-history file on Erase, and force manual dPhi. Before this fix
- ! nrxlog was never assigned anywhere, so all four of those flag bits
- ! were permanently dead -- e.g. Erase Band Map and Messages never
- ! actually cleared unit 26, so the next display() cycle just replayed
- ! the full decode history back into the Messages window.
call lock_decode_requests()
draft%map65RxLog = val
draft%nrxlog = val
diff --git a/map65/libm65/ptt.c b/map65/libm65/ptt.c
index b2c6cb48..3fb06d3c 100644
--- a/map65/libm65/ptt.c
+++ b/map65/libm65/ptt.c
@@ -1,49 +1,105 @@
#include <windows.h>
#include <stdio.h>
+#include "ptt.h"
+
+static HANDLE ptt_handle = INVALID_HANDLE_VALUE;
+static enum { PTT_IDLE, PTT_KEYED, PTT_UNCERTAIN } ptt_state = PTT_IDLE;
+
+static int control_line(DWORD operation)
+{
+ DWORD error;
+ if (EscapeCommFunction(ptt_handle, operation))
+ return PTT_OK;
+ error = GetLastError();
+ return error == ERROR_DEVICE_NOT_CONNECTED || error == ERROR_NO_SUCH_DEVICE
+ ? PTT_DEVICE_LOST : PTT_ERROR;
+}
+
+static void close_port(void)
+{
+ if (ptt_handle != INVALID_HANDLE_VALUE)
+ CloseHandle(ptt_handle);
+ ptt_handle = INVALID_HANDLE_VALUE;
+ ptt_state = PTT_IDLE;
+}
+
+static int release_lines(void)
+{
+ int rts = control_line(CLRRTS);
+ int dtr = control_line(CLRDTR);
+ EscapeCommFunction(ptt_handle, CLRBREAK);
+ if (rts == PTT_DEVICE_LOST || dtr == PTT_DEVICE_LOST)
+ return PTT_DEVICE_LOST;
+ return rts || dtr ? PTT_ERROR : PTT_OK;
+}
+
+static int control_failure(int result, int *iptt)
+{
+ if (result == PTT_DEVICE_LOST) {
+ close_port();
+ *iptt = 0;
+ } else {
+ ptt_state = PTT_UNCERTAIN;
+ }
+ return result;
+}
int ptt_(int *nport, int *ntx, int *iptt)
{
- static HANDLE hFile;
- static int open=0;
- char s[64];
- int i3=0,i4=0,i5=0,i6=0,i9=0,i00=0;
-
- if(*nport==0) {
- *iptt=*ntx;
- return(0);
- }
-
- if(*ntx && (!open)) {
- if (*nport < 10)
- snprintf(s, sizeof(s), "COM%d", *nport);
- else
- snprintf(s, sizeof(s), "\\\\.\\COM%d", *nport);
-
- hFile = CreateFileA(s, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,NULL);
-
- if(hFile==INVALID_HANDLE_VALUE) {
- // printf("PTT: Cannot open COM port %d.\n",*nport);
- return 1;
+ int result;
+ char path[64];
+
+ if (!*ntx) {
+ if (ptt_handle != INVALID_HANDLE_VALUE) {
+ result = release_lines();
+ if (result != PTT_OK)
+ return control_failure(result, iptt);
+ *iptt = 0;
+ if (!CloseHandle(ptt_handle)) {
+ ptt_state = PTT_UNCERTAIN;
+ return PTT_ERROR;
+ }
+ ptt_handle = INVALID_HANDLE_VALUE;
+ }
+ ptt_state = PTT_IDLE;
+ *iptt = 0;
+ return PTT_OK;
+ }
+
+ if (ptt_state == PTT_UNCERTAIN)
+ return PTT_ERROR;
+ if (ptt_state == PTT_KEYED) {
+ *iptt = 1;
+ return PTT_OK;
+ }
+ if (!*nport) {
+ *iptt = *ntx;
+ return PTT_OK;
}
- open=1;
- }
-
- if(*ntx && open) {
- EscapeCommFunction(hFile,3);
- EscapeCommFunction(hFile,5);
- *iptt=1;
- }
-
- else {
- EscapeCommFunction(hFile,4);
- EscapeCommFunction(hFile,6);
- EscapeCommFunction(hFile,9);
- i00=CloseHandle(hFile);
- *iptt=0;
- open=0;
- }
- if((i00+i3+i4+i5+i6+i9)==-99) return -1; //Silence compiler warning
- return 0;
+ if (*nport < 10)
+ snprintf(path, sizeof(path), "COM%d", *nport);
+ else
+ snprintf(path, sizeof(path), "\\\\.\\COM%d", *nport);
+ ptt_handle = CreateFileA(path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (ptt_handle == INVALID_HANDLE_VALUE)
+ return PTT_ERROR;
+
+ result = control_line(SETRTS);
+ if (result == PTT_OK)
+ result = control_line(SETDTR);
+ if (result != PTT_OK)
+ return control_failure(result, iptt);
+ ptt_state = PTT_KEYED;
+ *iptt = 1;
+ return PTT_OK;
+}
+
+void ptt_close(void)
+{
+ if (ptt_handle != INVALID_HANDLE_VALUE) {
+ release_lines();
+ close_port();
+ }
}
diff --git a/map65/libm65/ptt.h b/map65/libm65/ptt.h
new file mode 100644
index 00000000..150c1545
--- /dev/null
+++ b/map65/libm65/ptt.h
@@ -0,0 +1,19 @@
+#ifndef MAP65_PTT_H
+#define MAP65_PTT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Device loss resets logical PTT but does not confirm physical release. */
+enum { PTT_OK = 0, PTT_ERROR = 1, PTT_DEVICE_LOST = 2 };
+
+int ptt_(int *nport, int *ntx, int *iptt);
+void ptt_close(void);
+void ptt_set_override(const char *path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/map65/libm65/ptt_unix.c b/map65/libm65/ptt_unix.c
index 0787308b..d287f1d3 100644
--- a/map65/libm65/ptt_unix.c
+++ b/map65/libm65/ptt_unix.c
@@ -15,132 +15,117 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
+#include <unistd.h>
#include <fcntl.h>
-# include <sys/ioctl.h>
-#include <errno.h>
+#include <sys/ioctl.h>
#include <string.h>
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if (defined(__unix__) || defined(unix)) && !defined(USG)
-# include <sys/param.h>
-#endif
-
-#include <string.h>
-
-int ptt_serial(int fd, int *ntx, int *iptt);
-
-/*
- * ptt_
- *
- * generic unix PTT routine called from Fortran
- *
- * Inputs
- * unused Unused, to satisfy old windows calling convention
- * ptt_port device name
- * ntx pointer to fortran command on or off
- * iptt pointer to fortran command status on or off
- * Returns - non 0 if error
-*/
+#include <poll.h>
+#include "ptt.h"
static char ptt_override[256] = {0};
-static int ptt_override_valid = 0;
+static char opened_path[256] = {0};
+static int fd = -1;
+static enum { PTT_IDLE, PTT_KEYED, PTT_UNCERTAIN } ptt_state = PTT_IDLE;
void ptt_set_override(const char *path)
{
- if (path && *path) {
- strncpy(ptt_override, path, sizeof(ptt_override)-1);
- ptt_override_valid = 1;
- } else {
- ptt_override_valid = 0;
- }
+ strncpy(ptt_override, path ? path : "", sizeof(ptt_override) - 1);
+ ptt_override[sizeof(ptt_override) - 1] = '\0';
}
-static int fd = -1;
-
-int ptt_(int *nport, int *ntx, int *iptt)
+int ptt_serial(int port_fd, int *ntx, int *iptt)
{
- (void)nport;
-// ptt_log("ptt_unix: entry nport=%d ntx=%d iptt=%d", *nport, *ntx, *iptt);
-
- // PTT disabled
- if (!ptt_override_valid) {
- *iptt=*ntx;
- return 0;
- }
-
- const char *ptt_port = ptt_override;
-
- // Open once, keep open
- if (fd < 0) {
- fd = open(ptt_port, O_RDWR | O_NONBLOCK);
- if (fd < 0) {
-// ptt_log("ptt_unix: open failed errno=%d (%s)", errno, strerror(errno));
- return 1;
- }
-// ptt_log("ptt_unix: open OK fd=%d", fd);
-
- // *** PATCH: Force RTS+DTR LOW immediately after open ***
int status = 0;
- if (ioctl(fd, TIOCMGET, &status) == 0) {
- status &= ~(TIOCM_RTS | TIOCM_DTR);
- ioctl(fd, TIOCMSET, &status);
-// ptt_log("ptt_unix: forced RTS/DTR LOW after open, status=0x%x", status);
- }
- }
- ptt_serial(fd, ntx, iptt);
- return 0;
- }
+ if (ioctl(port_fd, TIOCMGET, &status) < 0)
+ return PTT_ERROR;
+ if (*ntx)
+ status |= TIOCM_RTS | TIOCM_DTR;
+ else
+ status &= ~(TIOCM_RTS | TIOCM_DTR);
-/*
- * ptt_serial
- *
- * generic serial unix PTT routine called indirectly from Fortran
- *
- * fd - already opened file descriptor
- * ntx - pointer to fortran command on or off
- * iptt - pointer to fortran command status on or off
- */
+ if (ioctl(port_fd, TIOCMSET, &status) < 0)
+ return PTT_ERROR;
+ *iptt = *ntx;
+ return PTT_OK;
+}
-int
-ptt_serial(int fd, int *ntx, int *iptt)
+static void close_port(void)
{
-int status;
-
-if (ioctl(fd, TIOCMGET, &status) < 0) {
-// ptt_log("TIOCMGET failed errno=%d (%s)", errno, strerror(errno));
- return 1;
+ if (fd >= 0)
+ close(fd);
+ fd = -1;
+ opened_path[0] = '\0';
+ ptt_state = PTT_IDLE;
}
- if(*ntx) {
- status |= (TIOCM_RTS | TIOCM_DTR); // PTT ON
- } else {
- status &= ~(TIOCM_RTS | TIOCM_DTR); // PTT OFF
+static int control_error(int *iptt)
+{
+ struct pollfd port = {fd, 0, 0};
+ /* EIO alone can be transient; hangup identifies a dead connection. */
+ if (poll(&port, 1, 0) > 0 && (port.revents & POLLHUP)) {
+ close_port();
+ *iptt = 0;
+ return PTT_DEVICE_LOST;
+ }
+ ptt_state = PTT_UNCERTAIN;
+ return PTT_ERROR;
}
-if (ioctl(fd, TIOCMSET, &status) < 0) {
-// ptt_log("TIOCMSET failed errno=%d (%s)", errno, strerror(errno));
- return 1;
-}
+int ptt_(int *nport, int *ntx, int *iptt)
+{
+ (void)nport;
+
+ /* Always release the open port, even when the next selection is disabled. */
+ if (!*ntx) {
+ if (fd >= 0 && ptt_serial(fd, ntx, iptt))
+ return control_error(iptt);
+ ptt_state = PTT_IDLE;
+ *iptt = 0;
+ if (fd >= 0 && strcmp(opened_path, ptt_override))
+ close_port();
+ return PTT_OK;
+ }
-//ptt_log("TIOCMSET OK status=0x%x", status);
-*iptt = *ntx;
-return 0;
+ /* A failed operation must be followed by a confirmed release before TX. */
+ if (ptt_state == PTT_UNCERTAIN)
+ return PTT_ERROR;
+ if (ptt_state == PTT_KEYED) {
+ *iptt = 1;
+ return PTT_OK;
+ }
+
+ if (fd >= 0 && strcmp(opened_path, ptt_override))
+ close_port();
+ if (!*ptt_override) {
+ *iptt = *ntx;
+ return PTT_OK;
+ }
+ if (fd < 0) {
+ fd = open(ptt_override, O_RDWR | O_NONBLOCK | O_NOCTTY);
+ if (fd < 0)
+ return PTT_ERROR;
+ strcpy(opened_path, ptt_override);
+ int off = 0;
+ int status = 0;
+ if (ptt_serial(fd, &off, &status))
+ return control_error(iptt);
+ }
+
+ if (ptt_serial(fd, ntx, iptt))
+ return control_error(iptt);
+ ptt_state = PTT_KEYED;
+ return PTT_OK;
}
void ptt_close(void)
{
if (fd >= 0) {
- close(fd);
- fd = -1;
-// ptt_log("ptt_unix: closed fd");
+ int off = 0;
+ int status = 0;
+ ptt_serial(fd, &off, &status);
+ close_port();
}
}
-
diff --git a/map65/libm65/q65b.F90 b/map65/libm65/q65b.F90
index 7f28f0f3..94ee0fb8 100644
--- a/map65/libm65/q65b.F90
+++ b/map65/libm65/q65b.F90
@@ -6,9 +6,61 @@
! on stdout.
module q65b_mod
+ use iso_fortran_env, only: int16, real64
implicit none
+ integer, parameter, private :: MAXFFT2 = 336000*2
contains
+ subroutine build_q65_samples(k0, nfft2, df, xpol, configured_dphi_deg, combine_poldeg, iwave)
+ use cacb_mod, only: ca, cb
+ use four2a_mod, only: four2a
+ integer, intent(in) :: k0, nfft2, configured_dphi_deg
+ real, intent(in) :: df, combine_poldeg
+ logical, intent(in) :: xpol
+ integer(int16), intent(out) :: iwave(:)
+ real(real64), parameter :: RAD = 57.2957795
+ complex :: cx(0:MAXFFT2-1), cy(0:MAXFFT2-1), cz(0:MAXFFT2)
+ save cx, cy, cz
+ integer :: i, j, ja, jb
+ real :: dphi, fac, r
+
+ fac = 1.0/nfft2
+ cx(0:nfft2 - 1) = ca(k0:k0 + nfft2 - 1)
+ cx = fac*cx
+ if (xpol) then
+ cy(0:nfft2 - 1) = cb(k0:k0 + nfft2 - 1)
+ cy = fac*cy
+ if (configured_dphi_deg .ne. 0) then
+ dphi = configured_dphi_deg/RAD
+ cy(0:nfft2 - 1) = cmplx(cos(dphi), sin(dphi))*cy(0:nfft2 - 1)
+ endif
+ endif
+
+ if (xpol) then
+ cz(0:MAXFFT2 - 1) = cos(combine_poldeg/RAD)*cx + sin(combine_poldeg/RAD)*cy
+ else
+ cz(0:MAXFFT2 - 1) = cx
+ endif
+
+ cz(MAXFFT2) = 0.
+ ja = nint(500.0/df)
+ jb = nint(2500.0/df)
+ do i = 0, ja
+ r = 0.5*(1.0 + cos(i*3.14159/ja))
+ cz(ja - i) = r*cz(ja - i)
+ cz(jb + i) = r*cz(jb + i)
+ enddo
+ cz(ja + jb + 1:) = 0.
+
+ call four2a(cz, 2*nfft2, 1, 1, -1)
+ do i = 0, nfft2 - 1
+ j = nfft2 - 1 - i
+ iwave(2*i + 2) = int(max(-32768, min(32767, nint(real(cz(j))))), kind=2)
+ iwave(2*i + 1) = int(max(-32768, min(32767, nint(aimag(cz(j))))), kind=2)
+ enddo
+ iwave(2*nfft2 + 1:) = 0
+ end subroutine build_q65_samples
+
subroutine write_wav_header(unit, nsamp, fs)
integer, intent(in) :: unit, nsamp, fs
integer :: datasize, file_size
@@ -41,6 +93,7 @@
use timer_module, only: timer
use debug_log
use stdout_channel_mod, only: write_stdout
+ use message_history_mod, only: append_message
use decodes_mod, only: ldecoded, ndecodes
use cacb_mod
use four2a_mod
@@ -84,13 +137,10 @@
! MAXFFT1 must be = nfft_big_active; MAXFFT2 must be = the
! downsampled-FFT length at the highest supported rate.
integer, parameter :: MAXFFT1 = 56*192000
- integer, parameter :: MAXFFT2 = 336000*2
integer, parameter :: NMAX = 60*12000
- real(real64), parameter :: RAD = 57.2957795
!==== Local variables =====================================================
integer(int16) :: iwave(300*12000)
- complex :: cx(0:MAXFFT2-1), cy(0:MAXFFT2-1), cz(0:MAXFFT2)
integer :: ipk1(1)
! Small, fixed bin radius for the automatic-candidate ipk search (see
! the note below at "for a wideband candidate"). Deliberately
@@ -98,13 +148,13 @@
! wb_sync's own low-SNR bin-selection noise, not accommodate arbitrary
! user-configured search widths.
integer, parameter :: IPK_LOCAL_BINS = 5
- integer :: i, ia, ib, ifreq, ikhz1, ipk, ipol
- integer :: j, ja, jb, k0, mhz, ndf, nfft1, nfft2
+ integer :: ia, ib, ifreq, ikhz1, ipk, ipol
+ integer :: k0, mhz, ndf, nfft1, nfft2
integer :: npol, nq65df, nsubmode, ntxpol, nutc00, nh
integer :: nfa, nfb
integer :: k0_click, mousedf_gate
- real :: df, df3, dphi, f_ipk, f_mouse, fac
- real :: combine_poldeg, freq1_00, frx, fsked, poldeg, r, snr1
+ real :: df, df3, f_ipk, f_mouse
+ real :: combine_poldeg, freq1_00, frx, fsked, poldeg, snr1
real(real64) :: freq0, freq1
character(len=12) :: mycall, hiscall
character(len=4) :: grid4
@@ -112,6 +162,7 @@
character(len=1) :: cp
character(len=2) :: cmode
character(len=256) :: linenew
+ character(len=83) :: history_line
integer :: t_now, t_rate
logical :: search_cursor
@@ -272,62 +323,16 @@
! (below) determine success or failure instead.
if (snr1 .lt. 1.5 .and. manualDecodeFlag .eq. 0) go to 900 !### Threshold needs work? ###
- fac = 1.0/nfft2
- cx(0:nfft2 - 1) = ca(k0:k0 + nfft2 - 1)
- cx = fac*cx
- if (xpol) then
- cy(0:nfft2 - 1) = cb(k0:k0 + nfft2 - 1)
- cy = fac*cy
- if (configured_dphi_deg .ne. 0) then
- dphi = configured_dphi_deg/RAD
- ! The sync weights describe the phase-corrected basis from symspec.
- cy(0:nfft2 - 1) = cmplx(cos(dphi), sin(dphi))*cy(0:nfft2 - 1)
- endif
- endif
-
-! Here cx and cy (if xpol) are frequency-domain data around the selected
-! QSO frequency, taken from the full-length FFT computed in filbig().
-! Values for fsample, nfft1, nfft2, df, and the downsampled data rate
-! are as follows:
-
-! fSample nfft1 df nfft2 fDownSampled
-! (Hz) (Hz) (Hz)
-!----------------------------------------------------
-! 96000 5376000 0.017857143 336000 6000.000
-! 95238 5120000 0.018601172 322560 5999.994
-
poldeg = 0.
+ combine_poldeg = 0.
if (xpol) then
! NB: still uses the (possibly wrong-bin, see k0 above) ipk for
! manual clicks in xpol mode -- not exercised by current testing,
! but worth revisiting if xpol manual decode misbehaves similarly.
poldeg = sync(ipk)%pol
combine_poldeg = sync(ipk)%combine_pol
- cz(0:MAXFFT2 - 1) = cos(combine_poldeg/RAD)*cx + sin(combine_poldeg/RAD)*cy
- else
- cz(0:MAXFFT2 - 1) = cx
endif
-
- cz(MAXFFT2) = 0.
-! Roll off below 500 Hz and above 2500 Hz.
- ja = nint(500.0/df)
- jb = nint(2500.0/df)
- do i = 0, ja
- r = 0.5*(1.0 + cos(i*3.14159/ja))
- cz(ja - i) = r*cz(ja - i)
- cz(jb + i) = r*cz(jb + i)
- enddo
- cz(ja + jb + 1:) = 0.
-
-!Transform to time domain (real), fsample=12000 Hz
- call four2a(cz, 2*nfft2, 1, 1, -1)
- do i = 0, nfft2 - 1
- j = nfft2 - 1 - i
- iwave(2*i + 2) = int(max(-32768, min(32767, nint(real(cz(j))))), kind=2)
- iwave(2*i + 1) = int(max(-32768, min(32767, nint(aimag(cz(j))))), kind=2)
- enddo
-
- iwave(2*nfft2 + 1:) = 0
+ call build_q65_samples(k0, nfft2, df, xpol, configured_dphi_deg, combine_poldeg, iwave)
nsubmode = mode_q65 - 1
nfa = 990 !Tight limits around ipk for the wideband decode
@@ -394,13 +399,14 @@
call write_stdout(trim(linenew)//new_line('a'))
endif
-! Write to lu 26, for Messages and Band Map windows
+! Retain wideband decodes for Messages and Band Map.
cmode = ': '
cmode(2:2) = char(ichar('A') + mode_q65 - 1)
freq1 = freq0 + 0.001d0*(ikhz1 - ikhz)
- write (26, 1014) freq1, ndf, 0, 0, 0, xdt0, npol, 0, nsnr0, nutc, msg0(1:28), &
+ write (history_line, 1014) freq1, ndf, 0, 0, 0, xdt0, npol, 0, nsnr0, nutc, msg0(1:28), &
':', cp, cmode ! was 1:22
1014 format(f8.3, i5, 3i3, f5.1, i4, i3, i4, i5.4, 4x, a28, 1x, 2a1, 2x, a2) ! was a22
+ call append_message(history_line, nutc, freq1, ndf)
! Suppress writing duplicates (same time, decoded message, and frequency)
! to map65_rx.log
diff --git a/map65/libm65/tmoonsub.c b/map65/libm65/tmoonsub.c
index f33dec0e..a7b4eaae 100644
--- a/map65/libm65/tmoonsub.c
+++ b/map65/libm65/tmoonsub.c
@@ -56,7 +56,7 @@ void getargs(int argc, char *argv[], int *y, int *m, double *tz,
/* if not right number of arguments, then print example command line */
if (argc !=5) {
- fprintf(stderr, usage);
+ fputs(usage, stderr);
exit(EXIT_FAILURE);
}
diff --git a/map65/liveCQSender.cpp b/map65/liveCQSender.cpp
deleted file mode 100644
index c2e27780..00000000
--- a/map65/liveCQSender.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "liveCQSender.hpp"
-#include <QSettings>
-#include "SettingsGroup.hpp"
-#include "mainwindow.h"
-#include "qt_helpers.hpp"
-#include "../revision_utils.hpp"
-
-#include <fstream>
-#include <iostream>
-#include <cmath>
-#include <QObject>
-#include <QString>
-#include <QDateTime>
-#include <QSharedPointer>
-#include <QSslSocket>
-#include <QHostInfo>
-#include <QQueue>
-#include <QByteArray>
-#include <QDataStream>
-#include <QTimer>
-#include <QDir>
-#include <QSettings>
-#include <QDebug>
-#include <QMetaType>
-#include <QUrl>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
-#include <QRandomGenerator>
-#endif
-
-#include "devsetup.h"
-
-# define DEBUGPSK 1;
-
-namespace
-{
- //quint16 SERVICE_PORT {80}; //this is http port
- quint16 SERVICE_PORT {443}; //this is https test port
-}
-
-liveCQSender::liveCQSender(QString const& myCall,
- QString const& myGrid,
- QString const& theUrl)
- :
- m_myCall{myCall},
- m_myGrid{myGrid},
- m_theUrl{theUrl}
-{
-}
-
- void liveCQSender::init() {
- // qDebug() << "liveCQSender::init running on thread: " << QThread::currentThread();
- socket.reset(new QSslSocket(this));
-
- // Connect signals before connecting
- connect(socket.data(), &QAbstractSocket::connected, this, &liveCQSender::onConnected);
- connect(socket.data(), &QAbstractSocket::readyRead, this, &liveCQSender::onReadyRead);
- connect(this, &liveCQSender::dataReady, this, &liveCQSender::sendData);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
- connect(socket.data(), &QAbstractSocket::errorOccurred, this, &liveCQSender::handle_socket_error);
-#else
- connect(socket.data(), static_cast<void(QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
- this, &liveCQSender::handle_socket_error);
-#endif
- QString host = "";
- if (m_theUrl.contains("https://")) {
- QUrl parsed(m_theUrl);
- host = parsed.host();
- }
- else return;
- // Start connection (non-blocking
- socket->connectToHostEncrypted(host, SERVICE_PORT);
- }
-
- void liveCQSender::onConnected() {
-
- qDebug() << "LiveCQSender onConnected Connected securely!";
-
- for(const QByteArray &ba : onConnectedRequests) {
- qDebug() << "liveCQSender::onConnected request: " << ba;
- socket->write(ba);
- }
- onConnectedRequests.clear();
- }
-
- void liveCQSender::onReadyRead() {
- QByteArray data = socket->readAll();
- // Parse headers, then handle chunks
- while (!data.isEmpty()) {
- int pos = data.indexOf("\r\n");
- bool ok;
- int size = data.left(pos).trimmed().toInt(&ok, 16);
- if (!ok || size == 0) break;
- data = data.mid(pos + 2);
- qDebug() << "Chunk:" << data.left(size);
- data = data.mid(size + 2); // skip \r\n
- }
- qDebug() << "liveCQSender Response:" << data;
-}
-
- void liveCQSender::handle_socket_error(QAbstractSocket::SocketError error)
- {
- qDebug() << "liveCQSender Socket error:" << error << socket->errorString();
- }
-
- void liveCQSender::addRemoteStation (QByteArray const& postByteArray, QString const& theUrl)
- {
- qDebug() << theUrl;
- emit dataReady(postByteArray);
- }
-
- void liveCQSender::sendData(const QByteArray &payload1) {
- QByteArray request;
- QByteArray body;
- QString host = "";
- QString webpage = "";
- if(!payload1.isEmpty())
- {
- body.append(payload1); // Your data here
- }
- qDebug() << "m_theUrl is: " << m_theUrl;
- if (m_theUrl.contains("https://")) {
- QUrl parsed(m_theUrl);
- host = parsed.host();
- webpage = parsed.path();
- }
- else return;
- request.append(("POST " + webpage + " HTTP/1.1\r\n").toUtf8());
- request.append(("Host: " + host + "\r\n").toUtf8());
- request.append("Content-Type: application/x-www-form-urlencoded\r\n");
- request.append("Connection: keep-alive\r\n");
- request.append("Content-Length: " + QByteArray::number(body.size()) + "\r\n\r\n");
- if(!payload1.isEmpty())
- {
- request.append(body);
- }
- qDebug() << "LiveCQ sendData request: " << request;
- if (socket->state() == QAbstractSocket::ConnectedState) {
- socket->write(request);
- qDebug() << "liveCQSender::sendData request2: " << request;
- }
- else {
- onConnectedRequests.append(request);
- request.clear();
- socket->connectToHostEncrypted(host, SERVICE_PORT);
- // Data will be sent in onConnected()
- }
- }
-
- liveCQSender::~liveCQSender() = default; // Define it, even as default
-
diff --git a/map65/liveCQSender.hpp b/map65/liveCQSender.hpp
deleted file mode 100644
index afb96665..00000000
--- a/map65/liveCQSender.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef LIVECQSENDER_HPP_
-#define LIVECQSENDER_HPP_
-#include <QObject>
-#include <QTimer>
-#include <QSslSocket>
-#include <QScopedPointer>
-#include "../qt_helpers.hpp"
-#include "commons.h"
-
-class QString;
-
-class liveCQSender : public QObject
-{
- Q_OBJECT
-
-signals:
- void dataReady(const QByteArray &payload);
-
-public slots:
- void init(); // Slot to initialize timers/sockets
-
-
-public:
- explicit liveCQSender (QString const& myCall, QString const& myGrid, QString const& theUrl);
- ~liveCQSender ();
-
- void reconnect ();
-
- //
- // Returns false if PSK Reporter connection is not available
- //
- void addRemoteStation (QByteArray const& postByteArray, QString const& theUrl);
-
- Q_SIGNAL void errorOccurred (QString const& reason);
-
-private slots:
- void handle_socket_error(QAbstractSocket::SocketError error);
- void onConnected();
- void onReadyRead();
- void sendData(const QByteArray &payload);
-
-private:
- QString m_myCall;
- QString m_myGrid;
- QString m_theUrl;
- QScopedPointer<QSslSocket> socket; // Or: std::unique_ptr<QSslSocket
- QList<QByteArray> onConnectedRequests;
-
- // Copy constructor and assignment operator disabled
- Q_DISABLE_COPY(liveCQSender)
-};
-
-#endif
diff --git a/map65/livecq_decode.cpp b/map65/livecq_decode.cpp
new file mode 100644
index 00000000..2cecdef9
--- /dev/null
+++ b/map65/livecq_decode.cpp
@@ -0,0 +1,143 @@
+#include "livecq_decode.hpp"
+
+#include "../Network/DecodedTime.hpp"
+#include "../validators/LiveCQCallsign.hpp"
+
+namespace
+{
+ bool isReportableMessageType(QString const& messageType)
+ {
+ return messageType == "CQ" || messageType == "QRZ"
+ || messageType == "CQV" || messageType == "CQH"
+ || messageType == "QRT";
+ }
+
+ bool parseMode(QString const& modeToken, QString& mode)
+ {
+ if (modeToken.contains('#')) {
+ mode = QString {"JT65"} + modeToken.back();
+ return true;
+ }
+ if (modeToken.contains(':')) {
+ mode = QString {"Q65-60"} + modeToken.back();
+ return true;
+ }
+ return false;
+ }
+}
+
+namespace Map65LiveCQ
+{
+ QList<Spot> parseSpots(QStringList const& decodeLines,
+ QString const& receiverCallsign,
+ QString const& receiverLocator,
+ bool crossPolarization,
+ QDateTime const& nowUtc,
+ QStringList& seenDecodes)
+ {
+ QList<Spot> spots;
+ if (receiverCallsign.length() < 3 || receiverLocator.length() < 4) {
+ return spots;
+ }
+
+ for (auto const& line : decodeLines) {
+ auto const tokens = line.split(' ', Qt::SkipEmptyParts);
+ if (tokens.size() < 6
+ || !isReportableMessageType(tokens.at(5).trimmed())
+ || !seenDecodes.filter(line.left(53)).isEmpty()) {
+ continue;
+ }
+ seenDecodes.append(line);
+
+ Spot spot;
+ spot.scheduledFrequency = tokens.at(0).trimmed();
+ spot.receiveFrequency = tokens.at(1).trimmed();
+ spot.snr = tokens.at(4).trimmed();
+ spot.messageType = tokens.at(5).trimmed().toUpper();
+
+ QString callsign;
+ QString modeToken;
+ QString grid {"--"};
+ QString polarization {"--"};
+ QString transmitPolarization {"--"};
+
+ if (tokens.size() >= 9 && tokens.at(7).contains('.')) {
+ callsign = tokens.at(6).trimmed().toUpper();
+ spot.deltaTime = tokens.at(7).trimmed();
+ modeToken = tokens.at(8).trimmed();
+ if (crossPolarization) {
+ polarization = tokens.at(2).trimmed();
+ }
+ } else if (tokens.size() >= 10 && tokens.at(8).contains('.')) {
+ auto const firstCandidate = tokens.at(6).trimmed().toUpper();
+ if (LiveCQ::isValidCallsign(firstCandidate)) {
+ callsign = firstCandidate;
+ grid = tokens.at(7).trimmed();
+ } else {
+ callsign = tokens.at(7).trimmed().toUpper();
+ }
+ spot.deltaTime = tokens.at(8).trimmed();
+ modeToken = tokens.at(9).trimmed();
+ if (crossPolarization) {
+ polarization = tokens.at(2).trimmed();
+ if (tokens.size() == 11) {
+ transmitPolarization = tokens.at(10).trimmed();
+ }
+ }
+ } else if (tokens.size() >= 11 && tokens.at(9).contains('.')) {
+ callsign = tokens.at(7).trimmed().toUpper();
+ grid = tokens.at(8).trimmed();
+ spot.deltaTime = tokens.at(9).trimmed();
+ modeToken = tokens.at(10).trimmed();
+ if (crossPolarization) {
+ polarization = tokens.at(2).trimmed();
+ if (tokens.size() == 12) {
+ transmitPolarization = tokens.at(11).trimmed();
+ }
+ }
+ } else {
+ continue;
+ }
+
+ if (!LiveCQ::isValidCallsign(callsign)
+ || !parseMode(modeToken, spot.mode)) {
+ continue;
+ }
+
+ spot.utcDateTime = DecodedTime::spotTime(tokens.at(3).trimmed(), nowUtc, 60);
+ if (!spot.utcDateTime.isValid()) {
+ continue;
+ }
+
+ spot.callsign = callsign;
+ spot.grid = grid;
+ spot.polarization = polarization;
+ spot.transmitPolarization = transmitPolarization;
+ spots.append(spot);
+ }
+ return spots;
+ }
+
+ QUrlQuery spotQuery(Spot const& spot,
+ QString const& receiverCallsign,
+ QString const& receiverLocator)
+ {
+ QUrlQuery query;
+ query.addQueryItem("skedfreq", spot.scheduledFrequency);
+ query.addQueryItem("rxfreq", spot.receiveFrequency);
+ query.addQueryItem("rpol", spot.polarization);
+ query.addQueryItem("dt", spot.deltaTime);
+ query.addQueryItem("dB", spot.snr);
+ query.addQueryItem("msgtype", spot.messageType);
+ query.addQueryItem("callsign", spot.callsign);
+ query.addQueryItem("grid", spot.grid.toUpper());
+ query.addQueryItem("mode", spot.mode);
+ query.addQueryItem("utcdatetime",
+ spot.utcDateTime.toUTC().toString("yyyy-MM-ddTHH:mm:ss") + "Z");
+ query.addQueryItem("spotter", receiverCallsign.toUpper());
+ query.addQueryItem("spottergrid", receiverLocator.toUpper());
+ query.addQueryItem("txpol", spot.transmitPolarization);
+ query.addQueryItem("apptype", "MAP65");
+ return query;
+ }
+}
diff --git a/map65/livecq_decode.hpp b/map65/livecq_decode.hpp
new file mode 100644
index 00000000..8ab89eea
--- /dev/null
+++ b/map65/livecq_decode.hpp
@@ -0,0 +1,39 @@
+#ifndef MAP65_LIVECQ_DECODE_HPP
+#define MAP65_LIVECQ_DECODE_HPP
+
+#include <QDateTime>
+#include <QList>
+#include <QString>
+#include <QStringList>
+#include <QUrlQuery>
+
+namespace Map65LiveCQ
+{
+ struct Spot
+ {
+ QString scheduledFrequency;
+ QString receiveFrequency;
+ QString polarization {"--"};
+ QString deltaTime;
+ QString snr;
+ QString messageType;
+ QString callsign;
+ QString grid {"--"};
+ QString mode;
+ QString transmitPolarization {"--"};
+ QDateTime utcDateTime;
+ };
+
+ QList<Spot> parseSpots(QStringList const& decodeLines,
+ QString const& receiverCallsign,
+ QString const& receiverLocator,
+ bool crossPolarization,
+ QDateTime const& nowUtc,
+ QStringList& seenDecodes);
+
+ QUrlQuery spotQuery(Spot const& spot,
+ QString const& receiverCallsign,
+ QString const& receiverLocator);
+}
+
+#endif
diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp
index 3cb1e760..e9a0e6d6 100644
--- a/map65/mainwindow.cpp
+++ b/map65/mainwindow.cpp
@@ -30,11 +30,11 @@
#include <QApplication>
#include <QDebug>
#include <QDateTime>
-#include <QTime>
#include <QFile>
#include <QTextStream>
#include <QString>
#include <QByteArray>
+#include <QElapsedTimer>
//#include <io.h>
#include <stdio.h>
@@ -50,20 +50,7 @@
#include "fortran_mutex.hpp"
#include "pskreporter_settings.h"
#include "runtime_paths.h"
-
-#if !defined(Q_OS_WIN)
-extern "C" {
- void ptt_set_override(const char *path);
-}
-#endif
-
-extern "C" {
- int ptt_(int* nport, int* itx, int* iptt);
-}
-
-#ifdef __unix__
-extern "C" void ptt_close(void);
-#endif
+#include "libm65/ptt.h"
#ifdef MessageBox
#undef MessageBox
@@ -90,8 +77,6 @@ TxTune* g_pTxTune = NULL;
std::atomic<bool> stop_m65{false};
-QString guiDate; //liveCQ
-QStringList allDecodes; //liveCQ
QStringList allDecodes2; //liveCQ
QString m_otherUrl;
bool m_w3szUrl;
@@ -117,34 +102,6 @@ MainWindow::DecoderContext::~DecoderContext()
delete stdoutChan;
}
-// TEMP diagnostic 2026-09-10 for the "decode reaches map65_rx.log but not the
-// Messages window, only on the first decode cycle after MAP65 starts" report.
-// Writes to its own separate log file rather than the shared w3sz_debug.log
-// Fortran's dbg() uses -- the two processes/threads have no lock between
-// them, and sharing a file produces torn, interleaved lines. Timestamps use
-// the same sec_midn()-style local h*3600+m*60+s+ms/1000 format as the
-// Fortran log, so the two can still be correlated by eye. Strip both files'
-// worth of logging before merge.
-//
-// Mirrors run_m65.f90's dbg_enabled flag -- flip to true to re-enable this
-// log without touching any of the cppDbg(...) call sites scattered through
-// this file.
-static bool const cppDbgEnabled = false;
-
-static void cppDbg(const QString &msg)
-{
- if (!cppDbgEnabled) return;
- double const t = [] {
- QTime const now = QTime::currentTime();
- return now.hour() * 3600.0 + now.minute() * 60.0 + now.second() + now.msec() / 1000.0;
- }();
- QFile f("w3sz_debug_cpp.log");
- if (f.open(QIODevice::Append | QIODevice::Text)) {
- QTextStream out(&f);
- out << "mainwindow: " << msg << " at t=" << QString::number(t, 'f', 3) << "\n";
- }
-}
-
//-------------------------------------------------- MainWindow constructor
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -512,21 +469,7 @@ MainWindow::MainWindow(QWidget *parent) :
m_wide_graph_window->m_TxOffset=m_TxOffset;
if(m_initIQplus) m_wide_graph_window->initIQplus();
-// Create "m_worked", a dictionary of all calls in wsjt.log
- QFile f("wsjt.log");
- qDebug() << "MainWindow Constructor File open result:" << f.open(QFileDevice::ReadOnly);
- if(f.isOpen()) {
- QTextStream in(&f);
- QString line,t,callsign;
- for(int i=0; i<99999; i++) {
- line=in.readLine();
- if(line.length()<=0) break;
- t=line.mid(18,12);
- callsign=t.mid(0,t.indexOf(","));
- m_worked[callsign]=true;
- }
- f.close();
- }
+ loadWorkedLog();
if(ui->actionLinrad->isChecked()) on_actionLinrad_triggered();
if(ui->actionCuteSDR->isChecked()) on_actionCuteSDR_triggered();
@@ -643,24 +586,26 @@ void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
// Linux: eventHandle is a void* pointing to posix_event_t
void* ev = ctx->stdoutChan->eventHandle;
- // NEW: start reading from the current writeIndex
StdoutSharedHeader h0 = region->header;
std::uint32_t readIndex = h0.writeIndex;
if (readIndex >= bufSize)
readIndex = 0;
region->header.readIndex = readIndex;
- // TEMP diagnostic 2026-09-10: h0.writeIndex should always be 0 here --
- // StdoutSharedMemory's constructor unconditionally zeroes writeIndex/
- // readIndex right after mapping (see stdout_shared_memory.cpp), and
- // that happens synchronously on the main thread before this reader
- // thread is even spawned. If this ever logs a nonzero value, that
- // assumption is wrong and this "start from current writeIndex" line
- // is silently skipping over real data written before this point.
- cppDbg(QString("stdout reader INIT readIndex=%1 (h0.writeIndex=%2) bufSize=%3")
- .arg(readIndex).arg(h0.writeIndex).arg(bufSize));
-
std::string lineBuffer;
+ QStringList displayLines;
+ auto flushDisplayLines = [this, &displayLines]() {
+ if (displayLines.isEmpty()) return;
+ QStringList lines;
+ lines.swap(displayLines);
+ QMetaObject::invokeMethod(
+ this,
+ [this, lines]() {
+ for (const QString& line : lines) processStdOut(line);
+ },
+ Qt::QueuedConnection
+ );
+ };
while (!stdoutReaderStop.load()) {
@@ -685,6 +630,11 @@ void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
lineBuffer.clear();
QString text = QString::fromStdString(line);
+ if (text.startsWith('@') || text.startsWith('&')) {
+ displayLines.append(text);
+ continue;
+ }
+ flushDisplayLines();
QMetaObject::invokeMethod(
this,
[this, text]() { processStdOut(text); },
@@ -699,6 +649,8 @@ void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
region->header.readIndex = readIndex;
}
+ flushDisplayLines();
+
});
}
@@ -707,17 +659,15 @@ void MainWindow::processStdOut(QString t)
// qDebug().noquote() << QDateTime::currentMSecsSinceEpoch() << "PROCESS STDOUT:" << t;
- // TEMP diagnostic 2026-09-10: confirms whether a decode line that made it
- // into map65_rx.log (written Fortran-side, independent of this whole
- // path) ever actually arrived here on the GUI thread. If a "!"-prefixed
- // line is missing from this log around the time of a report-vs-rx.log
- // mismatch, the loss is upstream (shared-memory ring buffer / reader
- // thread); if it IS here but never appended to the Messages window, the
- // loss is in handleControlLine/shouldDisplay below.
- cppDbg(QString("processStdOut RECV \"%1\"").arg(t.trimmed()));
-
if (m_decodeDisplayFilter.handleControlLine(t)) return;
+ if (t.startsWith("<Map65DisplayBegin>")) {
+ m_messagesText.clear();
+ m_bandmapText.clear();
+ m_widebandDecode = true;
+ return;
+ }
+
if (t.startsWith("<DecodeSkipped>")) {
bool validRequestId = false;
auto requestId = t.trimmed().section(' ', -1).toLongLong(&validRequestId);
@@ -783,9 +733,6 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
return;
}
- // --- same position as legacy ---
- read_log();
-
// --- "!" decoded text lines ---
if (t.startsWith("!")) {
int n = t.length();
@@ -804,11 +751,6 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
if (n >= 30 || t.indexOf("Best-fit") >= 0) {
bool const display = m_decodeDisplayFilter.shouldDisplay(decode_line);
- // TEMP diagnostic 2026-09-10 -- see the matching note at the top
- // of processStdOut(). If display=false here for a line that has
- // no legitimate earlier-pass duplicate, the display filter itself
- // (map65_decode_display_filter.cpp) is the culprit.
- cppDbg(QString("shouldDisplay=%1 for \"%2\"").arg(display ? "true" : "false").arg(decode_line));
if (display)
ui->decodedTextBrowser->append(decode_line);
}
@@ -873,16 +815,13 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
}
}
static const QRegularExpression call_re(
- "^[A-Z0-9]{1,3}[0-9][A-Z0-9]{0,3}[A-Z](/[A-Z0-9]+)?$");
+ "^([A-Z0-9]{1,4}/)?[A-Z0-9]{1,3}[0-9][A-Z0-9]{0,3}[A-Z](/[A-Z0-9]+)?$");
if (freq_khz > 0 && !sender.isEmpty()
&& call_re.match(sender.toUpper()).hasMatch()) {
m_wide_graph_window->addDecodeLabel(freq_khz, sender, is_jt65);
}
}
- // clear snapshots for this decode run, just like legacy
- m_messagesText.clear();
- m_bandmapText.clear();
}
// --- "@" message lines ---
@@ -894,7 +833,9 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
// --- "&" bandmap lines ---
// N6NU 2026-05-24: format widened to include the 5-char ndf from
// line3(k)(9:13). New layout:
- // "&" + I3 kHz + I5 ndf + " " + A6 call + A2 age
+ // "&" + I3 kHz + I5 ndf + " " + A12 call + A2 age + A1 mode + A4 UTC
+ // where mode is '#' (JT65) or ':' (Q65) and UTC (hhmm) is the call's
+ // latest decode; older builds omit both.
// Old layout (pre-260524, used by stock map65):
// "&" + I3 kHz + " " + A6 call + A2 age
// We auto-detect by checking column 4: if it's a digit/space-of-int,
@@ -911,7 +852,7 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
QString callsign = q.mid(call_start);
callsign = callsign.mid(0, callsign.indexOf(" "));
if (callsign.length() > 2) {
- if (m_worked[callsign]) {
+ if (m_worked.contains(callsign)) {
q = q.mid(1,4) + " " + q.mid(call_start);
} else {
q = q.mid(1,4) + " *" + q.mid(call_start);
@@ -919,24 +860,30 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
m_bandmapText += q;
// Fallback overlay tap (N6NU 2026-05-13, DG2YCB feedback r4).
- // We can't know the mode from this line, so pass is_jt65=false
- // and mode_reliable=false. With the new format we now also
- // have ndf precision, so freq_reliable=true. Old format
- // callers still pass freq_reliable=false (integer kHz only).
+ // The mode character, when present, sets the label color;
+ // without it, pass is_jt65=false and mode_reliable=false. With
+ // the new format we now also have ndf precision, so
+ // freq_reliable=true. Old format callers still pass
+ // freq_reliable=false (integer kHz only).
if (m_wide_graph_window) {
+ const QString mode = ndf_ok ? t.mid(call_start + 14, 1) : QString();
+ const bool mode_known = (mode == "#" || mode == ":");
+ bool utc_ok = false;
+ const int utc = mode_known ? t.mid(call_start + 15, 4).toInt(&utc_ok) : -1;
bool ok_khz = false;
const int nkHz = t.mid(1, 3).trimmed().toInt(&ok_khz);
const double freq_khz = ndf_ok
? (nkHz + ndf_hz / 1000.0)
: double(nkHz);
static const QRegularExpression call_re(
- "^[A-Z0-9]{1,3}[0-9][A-Z0-9]{0,3}[A-Z](/[A-Z0-9]+)?$");
+ "^([A-Z0-9]{1,4}/)?[A-Z0-9]{1,3}[0-9][A-Z0-9]{0,3}[A-Z](/[A-Z0-9]+)?$");
if (ok_khz && freq_khz > 0
&& call_re.match(callsign.toUpper()).hasMatch()) {
m_wide_graph_window->addDecodeLabel(
- freq_khz, callsign, /*is_jt65=*/false,
- /*mode_reliable=*/false,
- /*freq_reliable=*/ndf_ok);
+ freq_khz, callsign, /*is_jt65=*/mode == "#",
+ /*mode_reliable=*/mode_known,
+ /*freq_reliable=*/ndf_ok,
+ /*decode_utc=*/utc_ok ? utc : -1);
}
}
}
@@ -1070,10 +1017,12 @@ void MainWindow::readSettings()
m_myCall=settings.value("MyCall","").toString();
m_myGrid=settings.value("MyGrid","").toString();
m_idInt=settings.value("IDint",0).toInt();
- m_pttPath=settings.value("PTTpath",0).toString();
+ m_pttPath=settings.value("PTTpath","NONE").toString();
+ if (m_pttPath.isEmpty() || m_pttPath == "0") m_pttPath = "NONE";
m_pttPortNumber = settings.value("PTTPortNumber",0).toInt();
+ if (m_pttPath == "NONE") m_pttPortNumber = 0;
#if !defined(Q_OS_WIN)
- ptt_set_override(m_pttPath.toUtf8().constData());
+ ptt_set_override(m_pttPath == "NONE" ? nullptr : m_pttPath.toUtf8().constData());
#endif
m_astroFont=settings.value("AstroFont",20).toInt();
m_xpol=settings.value("Xpol",false).toBool();
@@ -1096,7 +1045,7 @@ void MainWindow::readSettings()
}
m_editorCommand=settings.value("Editor","notepad").toString();
m_dxccPfx=settings.value("DXCCpfx","").toString();
- m_timeout=settings.value("Timeout",20).toInt();
+ m_timeout=qBound(10,settings.value("Timeout",20).toInt(),40);
m_applyIQcal=settings.value("ApplyIQcal",0).toInt();
ui->actionApply_IQ_Calibration->setChecked(m_applyIQcal!=0);
m_dPhi=settings.value("dPhi",0).toInt();
@@ -1864,9 +1813,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
}
if (m_wide_graph_window) m_wide_graph_window->close();
-#ifdef __unix__
- ptt_close(); // close persistent Linux serial port
-#endif
+ ptt_close();
if (g_pTxTune) {
g_pTxTune->close();
@@ -2098,11 +2045,7 @@ void MainWindow::on_actionErase_Band_Map_and_Messages_triggered()
{
m_band_map_window->setText("");
m_messages_window->setText("","");
- // m_messagesText/m_bandmapText accumulate across decode cycles and are
- // only reset when a "!" line arrives (processStdOut). Without clearing
- // them here too, the next <EarlyFinished>/<DecodeFinished> redisplay
- // (or a cycle with no fresh decodes) repaints the stale pre-erase text
- // right back into the windows.
+ m_messages_window->clearLiveCQHistory();
m_messagesText.clear();
m_bandmapText.clear();
m_widebandDecode = false;
@@ -2416,6 +2359,10 @@ void MainWindow::guiUpdate()
static bool bMonitoring0=false;
static int nc0=1;
static int nc1=1;
+ static bool pttReleasePending=false;
+ static QElapsedTimer pttReleaseRetry;
+ static QString pttPath;
+ static int pttPortNumber=0;
static char msgsent[23];
static int nsendingsh=0;
int khsym=0;
@@ -2444,25 +2391,46 @@ void MainWindow::guiUpdate()
if(bTune and !bTune0) bMonitoring0=m_monitoring;
bTune0=bTune;
- if(m_auto or bTune) {
- if ((bTxTime or bTune) && iptt == 0 && !m_txMute) {
+ auto stopForPttError = [this] (int error) {
+ bool deviceLost = error == PTT_DEVICE_LOST;
+ pttReleasePending = !deviceLost;
+ pttReleaseRetry.start();
+ nc0 = nc1 = 1;
+ iptt0 = iptt;
+ btxok0 = false;
+ on_stopTxButton_clicked();
+ if (bTune && g_pTxTune) g_pTxTune->accept();
+ bTune = false;
+ soundOutThread.quitExecution = true;
+ m_transmitting = false;
+ if (deviceLost) {
+ m_wide_graph_window->enableSetRxHardware(true);
+ m_pttErrorShown = false;
+ msgBox(tr("Lost connection to PTT port: %1. PTT release could not be confirmed. "
+ "Check that the radio is no longer transmitting before starting another transmission.")
+ .arg(pttPath));
+ } else if (!m_pttErrorShown) {
+ m_pttErrorShown = true;
+ msgBox(tr("Cannot open or control PTT port: %1").arg(pttPath));
+ }
+ };
+
+ if (pttReleasePending) {
+ on_stopTxButton_clicked();
+ if (bTune && g_pTxTune) g_pTxTune->accept();
+ bTune = false;
+ }
- if (m_pttPath != "NONE") {
+ if((m_auto or bTune) && !pttReleasePending) {
+ if ((bTxTime or bTune) && iptt == 0 && !m_txMute) {
+ pttPath = m_pttPath;
+ pttPortNumber = m_pttPortNumber;
int itx = 1;
- int nport = m_pttPortNumber; // the real COM port number
- int ierr = ptt_(&nport, &itx, &iptt);
-
- if (ierr != 0) {
- if (!m_pttErrorShown) {
- char s[256];
- snprintf(s, sizeof(s), "Cannot open Port: %s",
- m_pttPath.toUtf8().constData());
- msgBox(s);
- m_pttErrorShown = true;
- }
- on_stopTxButton_clicked();
+ int ierr = ptt_(&pttPortNumber, &itx, &iptt);
+ if (ierr != PTT_OK) {
+ stopForPttError(ierr);
+ return;
}
- }
if (m_bIQxt)
m_wide_graph_window->tx570();
@@ -2556,15 +2524,19 @@ void MainWindow::guiUpdate()
if(!btxok && btxok0 && iptt==1) nc0=-11; //RxDelay = 1.0 s
btxok0=btxok;
if(nc0 <= 0) nc0++;
- if(nc0 == 0) {
+ if(nc0 == 0 || (pttReleasePending && pttReleaseRetry.hasExpired(1000))) {
if(m_bIQxt) m_wide_graph_window->rx570(); // Set Si570 back to Rx Freq
- int itx = 0;
- int nport = m_pttPortNumber; // the real COM port number
- ptt_(&nport, &itx, &iptt); // Lower PTT
- m_pttErrorShown = false;
+ int itx = 0;
+ int ierr = ptt_(&pttPortNumber, &itx, &iptt);
+ if (ierr != PTT_OK) {
+ stopForPttError(ierr);
+ return;
+ }
+ pttReleasePending = false;
+ m_pttErrorShown = false;
if(!m_txMute) {
- soundOutThread.quitExecution=true;\
+ soundOutThread.quitExecution=true;
}
m_transmitting=false;
m_wide_graph_window->enableSetRxHardware(true);
@@ -2651,7 +2623,6 @@ void MainWindow::guiUpdate()
m_setftx=0;
QString utc = t.date().toString(" yyyy MMM dd \n") + t.time().toString();
ui->labUTC->setText(utc);
- guiDate = ui->labUTC->text().trimmed().mid(0,12); //liveCQ
if((!m_monitoring and !m_diskData) or (khsym==m_hsym0)) {
xSignalMeter->setValue(0);
ySignalMeter->setValue(0);
@@ -2747,7 +2718,7 @@ void MainWindow::selectCall2(bool ctrl) //selectCall2
//doubleClickOnCall
void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl)
{
- if(m_worked[hiscall]) {
+ if(m_worked.contains(hiscall)) {
msgBox("Possible dupe: " + hiscall + " already in log.");
}
ui->dxCallEntry->setText(hiscall);
@@ -2789,7 +2760,7 @@ void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl)
void MainWindow::doubleClickOnMessages(QString hiscall, QString t2, bool ctrl)
{
if(hiscall.length()<3) return;
- if(m_worked[hiscall]) {
+ if(m_worked.contains(hiscall)) {
msgBox("Possible dupe: " + hiscall + " already in log.");
}
ui->dxCallEntry->setText(hiscall);
@@ -3117,8 +3088,13 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button
}
QTextStream out(&f);
out << logEntry;
+ out.flush();
+ if (out.status() != QTextStream::Ok || !f.flush()) {
+ msgBox("Cannot write file \"wsjt.log\".");
+ return;
+ }
f.close();
- m_worked[m_hisCall]=true;
+ m_worked.insert(m_hisCall);
}
void MainWindow::on_actionErase_map65_rx_log_triggered() //Erase Rx log
@@ -3271,7 +3247,7 @@ void MainWindow::on_actionFUNcube_Dongle_triggered()
void MainWindow::on_actionEdit_wsjt_log_triggered()
{
- proc_editor.start (QDir::toNativeSeparators (m_editorCommand), {QDir::toNativeSeparators (m_appDir + "/wsjt.log"), });
+ proc_editor.start (QDir::toNativeSeparators (m_editorCommand), {QDir::toNativeSeparators (m_dataDir + "/wsjt.log"), });
}
void MainWindow::on_actionTx_Tune_triggered()
@@ -3311,25 +3287,18 @@ bool MainWindow::isGrid4(QString g)
return true;
}
-void MainWindow::read_log()
-{
- // Update "m_worked" by reading wsjtx.log
- m_worked.clear(); //Start from scratch
- QFile f("wsjtx.log");
- qDebug() << "MainWindow::read_log File open result:" << f.open(QFileDevice::ReadOnly);
- if(f.isOpen()) {
- QTextStream in(&f);
- QString line,callsign;
- for(int i=0; i<99999; i++) {
- line=in.readLine();
- if(line.length()<=0) break;
- callsign=line.mid(40,6);
- int n=callsign.indexOf(",");
- if(n>0) callsign=callsign.left(n);
- m_worked[callsign]=true;
- }
- f.close();
- }
+void MainWindow::loadWorkedLog()
+{
+ QFile f("wsjt.log");
+ if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) return;
+ QSet<QString> worked;
+ QTextStream in(&f);
+ while (!in.atEnd()) {
+ const QString callsign = in.readLine().section(',', 2, 2).trimmed();
+ if (!callsign.isEmpty()) worked.insert(callsign);
+ }
+ if (in.status() != QTextStream::Ok) return;
+ m_worked.swap(worked);
}
void pa_deinit()
diff --git a/map65/mainwindow.h b/map65/mainwindow.h
index 0262e0ac..d38c269d 100644
--- a/map65/mainwindow.h
+++ b/map65/mainwindow.h
@@ -6,7 +6,7 @@
#include <QScopedPointer>
#include <QLabel>
#include <QDateTime>
-#include <QHash>
+#include <QSet>
#include <QProcess>
#include "soundin.h"
#include "soundout.h"
@@ -319,7 +319,7 @@ private:
char hisgrid[6] = {};
char datetime[17] = {};
- QHash<QString,bool> m_worked;
+ QSet<QString> m_worked;
SignalMeter *xSignalMeter;
SignalMeter *ySignalMeter;
@@ -343,7 +343,7 @@ private:
void stub();
bool isGrid4(QString g);
bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus);
- void read_log();
+ void loadWorkedLog();
void writeCrashData();
void savetf2(QString fname, bool xpol);
void getfile(QString fname, bool m_xpol, int dbDgrd);
@@ -377,8 +377,6 @@ extern "C" {
char* msgsent, short iwave[], int* nwave,
int len1, int len2);
- int ptt_(int* nport, int* itx, int* iptt);
-
void astrosub00_ (int* nyear, int* month, int* nday, double* uth, int* nfreq,
const char* mygrid, int* ndop00, int len1);
}
diff --git a/map65/map65_config.h.in b/map65/map65_config.h.in
deleted file mode 100644
index ffb97175..00000000
--- a/map65/map65_config.h.in
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "svnversion.h"
-
-#define MAP65_VERSION_MAJOR @MAP65_VERSION_MAJOR@
-#define MAP65_VERSION_MINOR @MAP65_VERSION_MINOR@
diff --git a/map65/messages.cpp b/map65/messages.cpp
index 4ded52c2..caa65b4f 100644
--- a/map65/messages.cpp
+++ b/map65/messages.cpp
@@ -6,20 +6,16 @@
#include "qt_helpers.hpp"
#include "../revision_utils.hpp"
#include "../Network/PSKReporter.hpp"
-#include "liveCQSender.hpp"
+#include "../Network/LiveCQUpload.hpp"
+#include "livecq_decode.hpp"
#include "pskreporter_decode.h"
#include "pskreporter_settings.h"
#include <QCoreApplication> //liveCQ
-#include <QNetworkAccessManager> //liveCQ
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QUrl>
-#include <QUrlQuery>
-#include <QEventLoop>
#include <QDateTime>
#include <QString>
-#include <QThread>
+#include <QUrl>
+#include <QUrlQuery>
#include <QDebug>
Messages::Messages (QString const& settings_filename, QString const& eclipse_filename,
@@ -42,42 +38,15 @@ Messages::Messages (QString const& settings_filename, QString const& eclipse_fil
QSettings settings2 {m_settings_filename, QSettings::IniFormat};
auto const pskReporterSettings = readMap65PSKReporterSettings(settings2);
SettingsGroup h {&settings2, "Common"};
- bool m_w3szUrl = settings2.value("w3szUrl",true).toBool();
- QString m_otherUrl = settings2.value("otherUrl","").toString();
- QString m_myCall=settings2.value("MyCall","").toString();
- QString m_myGrid=settings2.value("MyGrid","").toString();
m_spot_to_psk_reporter = pskReporterSettings.enabled;
- QString theUrl;
-
- if(m_w3szUrl) {
- theUrl = w3szUrlAddr;
- } else {
- theUrl = m_otherUrl;
- }
-
+
m_cqOnly=false;
m_cqStarOnly=false;
- QString guiDate;
- QStringList allDecodes = { "" };
- QStringList allDecodes2 = { "" };
connect (ui->messagesTextBrowser, &DisplayText::selectCallsign, this, &Messages::selectCallsign2);
-
- // Create the thread and your liveCQ object
- livecqThread = new QThread(this);
-
- connect(livecqThread, &QThread::started, this, [this, m_myCall, m_myGrid, theUrl]() {
- auto* reporter2 = new liveCQSender(m_myCall, m_myGrid, theUrl);
- reporter2->moveToThread(this->livecqThread);
- connect(reporter2, &liveCQSender::destroyed, livecqThread, &QThread::quit);
- QMetaObject::invokeMethod(reporter2, "init", Qt::QueuedConnection);
-
- // Connect signals for control and communication
- connect(this, &Messages::sendRemoteStationData2, reporter2, &liveCQSender::addRemoteStation);
-
-});
- connect(livecqThread, &QThread::finished, livecqThread, &QObject::deleteLater);
- livecqThread->start();
+ m_livecq = std::make_unique<LiveCQUpload>(this);
+ m_livecq->setUserAgent(http_user_agent().toUtf8());
+ connect(m_livecq.get(), &LiveCQUpload::errorOccurred, this, &Messages::errorOccurred);
m_psk_reporter.reset(new PSKReporter({
pskReporterSettings.use_tcpip,
@@ -141,149 +110,40 @@ void Messages::setPSKReportingEnabled(bool enabled)
}
void Messages::sendLiveCQData(QStringList decodeList) {
- QSettings settings(m_settings_filename, QSettings::IniFormat);
+ QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "Common"};
- bool m_w3szUrl = settings.value("w3szUrl",true).toBool();
- QString m_otherUrl = settings.value("otherUrl","").toString();
- QString m_myCall=settings.value("MyCall","").toString();
- QString m_myGrid=settings.value("MyGrid","").toString();
- bool m_xpol = settings.value("Xpol",false).toBool();
- QString rpol = "--";
- QString theUrl;
+ bool const m_w3szUrl = settings.value("w3szUrl", true).toBool();
+ QString const m_otherUrl = settings.value("otherUrl", "").toString();
+ QString const m_myCall = settings.value("MyCall", "").toString();
+ QString const m_myGrid = settings.value("MyGrid", "").toString();
+ bool const m_xpol = settings.value("Xpol", false).toBool();
+
+ QString const theUrl = m_w3szUrl ? w3szUrlAddr : m_otherUrl;
+ QUrl const endpoint {theUrl};
+ if (!endpoint.isValid()
+ || endpoint.scheme().compare("https", Qt::CaseInsensitive) != 0) {
+ return;
+ }
+ if (!m_livecq->setEndpoint(endpoint)) {
+ return;
+ }
+
+ auto const spots = Map65LiveCQ::parseSpots(
+ decodeList, m_myCall, m_myGrid, m_xpol, QDateTime::currentDateTimeUtc(),
+ m_livecqSeenDecodes);
- if(w3szUrlAddr.contains("https://") && m_w3szUrl) {
- theUrl = w3szUrlAddr;
- } else if (m_otherUrl.contains("https://") && !m_w3szUrl) {
- theUrl = m_otherUrl;
+ while (m_livecqSeenDecodes.size() > maxLiveCQSeenDecodes) {
+ m_livecqSeenDecodes.removeFirst();
}
- else return;
- for (const QString &theLine : decodeList) {
- QStringList thePostLine = theLine.split(" ",SkipEmptyParts);
- if((thePostLine.at(5).trimmed() == "CQ" || thePostLine.at(5).trimmed() == "QRZ" || thePostLine.at(5).trimmed() == "CQV" || thePostLine.at(5) == "CQH" || thePostLine.at(5).trimmed() == "QRT") && m_myCall.length() >=3 && m_myGrid.length()>=4) {
- if(allDecodes.filter(theLine.mid(0,53)).length() == 0) {
- allDecodes.append(theLine);
- QString freq = thePostLine.at(0).trimmed();
- QString dF = thePostLine.at(1).trimmed();
- QString utcdatetimestringOriginal = guiDate + " " + thePostLine.at(3).trimmed() + "00"; //needs 2 spaces between date and time
- QDateTime utcdatetimeUTC = QDateTime::fromString(utcdatetimestringOriginal, "yyyy MMM dd HHmmss");
- utcdatetimeUTC.setTimeZone(QTimeZone::utc());
- QString utcdatetimeUTCString = utcdatetimeUTC.toString("yyyy-MM-ddTHH:mm:ss");
- utcdatetimeUTCString = utcdatetimeUTCString + "Z";
- QString dB = thePostLine.at(4).trimmed();
- QString msgType = thePostLine.at(5).trimmed().toUpper();
- QString callsign = "";
- QString grid = "--";
- QString mode="";
- QString txpol = " ";
- QString dT = "";
- QString modeChar = "";
- // Handle CQ CALL but NO GRID -- dot at 7
- if(thePostLine.at(7).contains(".")) {
- callsign = thePostLine.at(6).trimmed().toUpper();
- bool isCall = Map65PSKReporter::isValidMap65Callsign(callsign);
- if(!isCall) continue;
- dT =thePostLine.at(7).trimmed();
- modeChar = thePostLine.at(8).trimmed();
- if(modeChar.contains("#")) mode = QString("JT65") + modeChar.back();
- else if(modeChar.contains(":")) mode = QString("Q65-60") + modeChar.back();
- if(m_xpol) {
- rpol = thePostLine.at(2).trimmed();
- } else {
- rpol = "--";
- }
- txpol = "--";
-
- // Handle CQ CALL GRID or CQ XXX CALL -- dot at 8
- } else if (thePostLine.at(8).contains(".")) {
- // Test for callsign at thePostLine(6)
- callsign = thePostLine.at(6).trimmed().toUpper();
- bool isCall = Map65PSKReporter::isValidMap65Callsign(callsign);
- if(isCall) {
- grid = thePostLine.at(7).trimmed();
- // Handle CQ XXX CALL
- } else {
- callsign = thePostLine.at(7).trimmed().toUpper();
- bool isCall = Map65PSKReporter::isValidMap65Callsign(callsign);
- if(!isCall) continue;
- }
- dT =thePostLine.at(8).trimmed();
- modeChar = thePostLine.at(9).trimmed();
- if(modeChar.contains("#"))
- {
- mode = QString("JT65") + modeChar.back();
- if (m_xpol) {
- rpol = thePostLine.at(2).trimmed();
- if(thePostLine.length()==11) {
- if(thePostLine.at(10).contains("H")) txpol = "H";
- else if(thePostLine.at(10).contains("V")) txpol = "V";
- else txpol+"--";
- } else txpol="--";
- }
- } else if(modeChar.contains(":")) {
- mode = QString("Q65-60") + modeChar.back();
- if (m_xpol) {
- rpol = thePostLine.at(2).trimmed();
- if(thePostLine.length()==11) {
- if(thePostLine.at(10).contains("H")) txpol = "H";
- else if(thePostLine.at(10).contains("V")) txpol = "V";
- else txpol="--";
- } else txpol="--";
- }
- }
- // Handle CQ XXX CALL GRID
- } else if(thePostLine.at(9).contains(".")) {
- callsign = thePostLine.at(7).trimmed().toUpper();
- bool isCall = Map65PSKReporter::isValidMap65Callsign(callsign);
- if(!isCall) continue;
- grid = thePostLine.at(8).trimmed();
-
- dT =thePostLine.at(9).trimmed();
- modeChar = thePostLine.at(10).trimmed();
- if(modeChar.contains("#"))
- {
- mode = QString("JT65") + modeChar.back();
- if (m_xpol) {
- rpol = thePostLine.at(2).trimmed();
- if(thePostLine.length()==12) {
- if(thePostLine.at(11).contains("H")) txpol = "H";
- else if(thePostLine.at(11).contains("V")) txpol = "V";
- else txpol="--";
- } else txpol="--";
- }
- } else if(modeChar.contains(":")) {
- mode = QString("Q65-60") + modeChar.back();
- if (m_xpol) {
- rpol = thePostLine.at(2).trimmed();
- if(thePostLine.length()==12) {
- if(thePostLine.at(11).contains("H")) txpol = "H";
- else if(thePostLine.at(11).contains("V")) txpol = "V";
- else txpol="--";
- } else txpol="--";
- }
- }
- }
- else {
- continue;
- }
- if(mode.contains("JT65") || mode.contains("Q65")) {
- QString postString = "skedfreq=" + freq + "&rxfreq=" + dF + "&rpol=" + rpol + "&dt=" + dT + "&dB=" + dB + "&msgtype=" + msgType.toUpper() + "&callsign=" + callsign.toUpper() + "&grid=" + grid.toUpper() + "&mode=" + mode + "&utcdatetime=" + utcdatetimeUTCString + "&spotter=" + m_myCall.toUpper() + "&spottergrid=" + m_myGrid.toUpper() + "&txpol=" + txpol + "&apptype=MAP65";
- QByteArray postByteArray = postString.toUtf8();
-
- emit sendRemoteStationData2(postByteArray, theUrl);
- }
- }
- }
+
+ for (auto const& spot : spots) {
+ m_livecq->postSpot(Map65LiveCQ::spotQuery(spot, m_myCall, m_myGrid));
}
}
-void Messages::onFinished(QNetworkReply *reply)
+void Messages::clearLiveCQHistory()
{
- if (reply->error() == QNetworkReply::NoError) {
- qDebug() << "Reply in messages::inFinished is: " << reply->readAll();
- } else {
- qDebug() << "Error message in messages::inFinished is: " << reply->errorString();
- }
- reply->deleteLater();
+ m_livecqSeenDecodes.clear();
}
void Messages::setText(QString t, QString t2)
diff --git a/map65/messages.h b/map65/messages.h
index 5b27157a..a6a5d0eb 100644
--- a/map65/messages.h
+++ b/map65/messages.h
@@ -4,13 +4,13 @@
#include <QDialog>
#include "commons.h"
#include <memory>
-#include <QNetworkReply>
namespace Ui {
class Messages;
}
class PSKReporter;
+class LiveCQUpload;
class Messages : public QDialog
{
@@ -23,14 +23,13 @@ public:
void setColors(QString t);
void setPSKReportingEnabled(bool enabled);
void setClosingForShutdown(bool value) { m_closingForShutdown = value; }
+ void clearLiveCQHistory();
~Messages();
signals:
void click2OnCallsign(QString hiscall, QString t2, bool ctrl);
void errorOccurred(const QString &error); // Emitted on error
- void sendLocalStationData2(QString const& call, QString const& grid, QString const& theUrl);
- void sendRemoteStationData2 (QByteArray const& postByteArray, QString const& theUrl);
protected:
void closeEvent(QCloseEvent *event);
@@ -39,7 +38,6 @@ private slots:
void selectCallsign2(bool ctrl);
void on_cbCQ_toggled(bool checked);
void on_cbCQstar_toggled(bool checked);
- void onFinished(QNetworkReply *reply); // Handles the reply from web request
private:
Ui::Messages *ui;
@@ -52,14 +50,15 @@ private:
QString m_color2;
QString m_color3;
- QThread* livecqThread;
std::unique_ptr<PSKReporter> m_psk_reporter;
+ std::unique_ptr<LiveCQUpload> m_livecq;
+ QStringList m_livecqSeenDecodes;
+ static constexpr int maxLiveCQSeenDecodes {500};
bool m_closingForShutdown = false;
bool m_cqOnly;
bool m_cqStarOnly;
bool doLiveCQ=true; //liveCQ
- void CreateLiveCQ(QStringList cqliveText); //liveCQ
void sendPSKReporterData(QStringList decodeList); //PSKReporter
void sendLiveCQData(QStringList decodeList); // This will trigger the web request
void initializePSKReporting();
diff --git a/map65/widegraph.cpp b/map65/widegraph.cpp
index ff3650b0..fbdf048d 100644
--- a/map65/widegraph.cpp
+++ b/map65/widegraph.cpp
@@ -215,14 +215,15 @@ void WideGraph::saveSettings()
void WideGraph::addDecodeLabel(double freq_khz, const QString& callsign,
bool is_jt65, bool mode_reliable,
- bool freq_reliable)
+ bool freq_reliable, int decode_utc)
{
if (callsign.isEmpty()) return;
if (!m_decodeLabelsEnabled) return;
const qint64 now = QDateTime::currentMSecsSinceEpoch();
for (auto& lab : m_decodeLabels) {
if (lab.callsign == callsign) {
- lab.last_seen_ms = now;
+ if (decode_utc < 0 || decode_utc != lab.last_utc) lab.last_seen_ms = now;
+ if (decode_utc >= 0) lab.last_utc = decode_utc;
// Only overwrite freq when the caller has sub-kHz precision.
// The "&" bandmap tap only has 3-char integer-kHz precision
// (display.f90 cfreq0 is character(3) � no ndf field), so it
@@ -230,24 +231,28 @@ void WideGraph::addDecodeLabel(double freq_khz, const QString& callsign,
// includes ndf, leaving the tick up to ~500 Hz off the signal.
if (freq_reliable) lab.freq_khz = freq_khz;
// Only overwrite the mode flag when the caller knows for sure.
- // The "&" bandmap-line tap has no cmode in its payload, so it
- // would otherwise stomp on an authoritative JT65 mark from the
- // "!" decoder tap and flip the label color.
+ // An "&" bandmap line without the mode character would otherwise
+ // stomp on an authoritative JT65 mark from the "!" decoder tap and
+ // flip the label color.
if (mode_reliable) lab.is_jt65 = is_jt65;
++lab.hits;
if (ui && ui->widePlot) ui->widePlot->setDecodeLabels(m_decodeLabels);
return;
}
}
+ if (decode_utc >= 0 && m_expiredLabelUtc.value(callsign, -1) == decode_utc) return;
+ m_expiredLabelUtc.remove(callsign);
if (m_decodeLabels.size() >= kDecodeLabelMax) {
m_decodeLabels.removeFirst();
}
m_decodeLabels.append(DecodeLabel{freq_khz, callsign, now, 1, is_jt65});
+ m_decodeLabels.last().last_utc = decode_utc;
if (ui && ui->widePlot) ui->widePlot->setDecodeLabels(m_decodeLabels);
}
void WideGraph::clearDecodeLabels()
{
+ m_expiredLabelUtc.clear();
if (m_decodeLabels.isEmpty()) return;
m_decodeLabels.clear();
if (ui && ui->widePlot) ui->widePlot->setDecodeLabels(m_decodeLabels);
@@ -260,6 +265,10 @@ void WideGraph::ageDecodeLabels()
const qint64 ttl_ms = static_cast<qint64>(trp * m_decodeLabelPeriods * 1000.0);
const qint64 cutoff = QDateTime::currentMSecsSinceEpoch() - ttl_ms;
const int before = m_decodeLabels.size();
+ for (const auto& l : m_decodeLabels) {
+ if (l.last_seen_ms < cutoff && l.last_utc >= 0)
+ m_expiredLabelUtc.insert(l.callsign, l.last_utc);
+ }
m_decodeLabels.erase(
std::remove_if(m_decodeLabels.begin(), m_decodeLabels.end(),
[cutoff](const DecodeLabel& l) {
@@ -277,6 +286,7 @@ void WideGraph::setDecodeLabelsEnabled(bool on)
m_decodeLabelsEnabled = on;
if (!on) {
m_decodeLabels.clear();
+ m_expiredLabelUtc.clear();
if (ui && ui->widePlot) ui->widePlot->setDecodeLabels(m_decodeLabels);
}
// Persist immediately so the choice survives a crash before saveSettings runs.
diff --git a/map65/widegraph.h b/map65/widegraph.h
index e96cb2c2..d0df0cb1 100644
--- a/map65/widegraph.h
+++ b/map65/widegraph.h
@@ -2,6 +2,7 @@
#define WIDEGRAPH_H
#include <QDialog>
+#include <QHash>
#include <QList>
#include <QString>
#include <QTimer>
@@ -50,17 +51,20 @@ public:
// parsing the freq + sender callsign out of the "!"-prefix line);
// the list ages out after m_decodeLabelPeriods ? TR period of no
// refresh and gets pushed to the plotter for rendering.
- // mode_reliable=false: caller has no authoritative mode (e.g. "&"
- // bandmap line, where display.f90 writes no cmode). On dedup, the
+ // mode_reliable=false: caller has no authoritative mode (e.g. an "&"
+ // bandmap line without the mode character). On dedup, the
// existing label's is_jt65 is preserved. For brand-new labels the
// caller's is_jt65 is used as a best-guess seed.
// freq_reliable=false: caller only has integer-kHz precision (e.g.
// "&" bandmap line — cfreq0 is 3 chars, no ndf). On dedup, the
// existing label's freq_khz is preserved so a precise "!" tick
// is not stomped by a later imprecise "&" refresh.
+ // decode_utc: UTC (hhmm) of the decode an "&" bandmap line reports, or
+ // -1 if unknown. The Band Map repeats old decodes on every redisplay,
+ // so such a line keeps a label alive only when its UTC is new.
void addDecodeLabel(double freq_khz, const QString& callsign,
bool is_jt65, bool mode_reliable = true,
- bool freq_reliable = true);
+ bool freq_reliable = true, int decode_utc = -1);
void clearDecodeLabels();
bool decodeLabelsEnabled() const { return m_decodeLabelsEnabled; }
void setDecodeLabelsEnabled(bool on);
@@ -132,6 +136,9 @@ private:
// Decoded-callsign overlay state.
QList<DecodeLabel> m_decodeLabels;
+ // Callsign -> UTC of the decode an aged-out label showed. The Band Map
+ // keeps re-sending that decode, which must not bring the label back.
+ QHash<QString, int> m_expiredLabelUtc;
bool m_decodeLabelsEnabled {true};
int m_decodeLabelPeriods {5}; // disappear after N×TRperiod of no decode
// Overlay opacity preset (0..255). UI offers None=255 / Medium=200 /