Compare commits

...

208 Commits

Author SHA1 Message Date
Daniel Peter Chokola 810a872551 mcpserver: chirpmodem listen mode 2 weeks ago
Daniel Peter Chokola b25fc2aff6 Add ChirpModem modulator channel plugin (libchirpmodem Tx) 2 weeks ago
Daniel Peter Chokola ff6fd110f4 demodchirpmodem: keep the frequency dial in step on sample rate changes 2 weeks ago
Daniel Peter Chokola 693cfacd2e Add ChirpModem demodulator channel plugin (libchirpmodem Rx) 2 weeks ago
f4exb fb24628089 Release v8.1.0 2 weeks ago
Edouard Griffiths 596a3ac938
Merge pull request #3063 from srcejon/fixes 2 weeks ago
Jon Beniston c89bac96c0 Try patched version of jurplel/install-qt-action@v4 to support Qt 6.11. 3 weeks ago
Jon Beniston 66baa99cf5 Update Qt to 6.11.3 on Windows and Mac, as it's version of Chromium has a garbage collection fix, beneficial to 3D map. Note, it's not in 6.12.0. 3 weeks ago
Edouard Griffiths 6fc7716af2
Merge pull request #3061 from srcejon/fixes 3 weeks ago
Jon Beniston 8ddd16cd8f Merge branch 'fixes' of https://github.com/srcejon/sdrangel into fixes 3 weeks ago
Jon Beniston 3d54d65150 Add SECAM. 3 weeks ago
srcejon 33423ace91
Merge branch 'f4exb:master' into fixes 3 weeks ago
Edouard Griffiths 8dbeb0f1dc
Merge pull request #3060 from rgetz/rgetz-add-sdrangel-to-wave 3 weeks ago
Jon Beniston 3f5b79332e Add ATV swagger files. 3 weeks ago
Jon Beniston 0ee3795e4f Update settings image. 3 weeks ago
Jon Beniston f2a57baa54 Merge branch 'fixes' of https://github.com/srcejon/sdrangel into fixes 3 weeks ago
Jon Beniston 7651091b60 ATVDemod: Add some colour. Fix WebAPI. 3 weeks ago
Robin Getz 13449c1926
wavfilerecord: Add software identification to recorded WAV files 3 weeks ago
Edouard Griffiths edd9c352fb
Merge pull request #3058 from rgetz/rgetz-fix-libsgp4 3 weeks ago
Robin Getz 36bea63caf
satellitetrackersgp4: SGP4 range rate API compatibility 3 weeks ago
Edouard Griffiths 598cc15835
Merge pull request #3054 from srcejon/fixes 3 weeks ago
Jon Beniston ecaf2392dc Ignore space in plugins/feature/map/msfsassetconverter/LICENSE.md. 3 weeks ago
Jon Beniston bfb3482f6c Merge branch 'fixes' of https://github.com/srcejon/sdrangel into fixes 3 weeks ago
Jon Beniston 6a1c2154f9 Ignore vendored source. 3 weeks ago
srcejon 1a57b0f95a CI: free disk space (dotnet, ghc) before Linux build 3 weeks ago
Jon Beniston aa07a07bf0 Cesium: Fix height queries that don't complete. 3 weeks ago
Jon Beniston d5a5739179 Only build ACARS demod if LIBACARS_FOUND. 3 weeks ago
Jon Beniston 4b54758bf5 Fix trailing space. 3 weeks ago
Jon Beniston e5b66413b7 Fix clip/clamp to ground for 3D tiles for long runs. 3 weeks ago
Jon Beniston 9bcaa6ab98 Fix MCP bridge build failure on windows. 3 weeks ago
Jon Beniston a9a0b64e15 Fix libacars paths on Mac. 3 weeks ago
Jon Beniston b99139381a Add libacars to flatpak and snap. 3 weeks ago
Jon Beniston afb05e70b2 Remove whitespace. 3 weeks ago
Jon Beniston fc6d29aceb Fix trailing white space. 3 weeks ago
Jon Beniston f41a81cd2d Fix line endings. 3 weeks ago
srcejon 5d3fb916d4
Merge branch 'f4exb:master' into fixes 3 weeks ago
Jon Beniston e1e3eb7aa9 Add note on getting 3D map working on Linux. 3 weeks ago
Jon Beniston 77cb541e34 Fix stats table on Qt5. 3 weeks ago
Jon Beniston dc1d14effe Fix warnings. Select on find. 3 weeks ago
Jon Beniston b171ddccd2 Fix warnings. 3 weeks ago
Jon Beniston 58de186780 Make clear which device has an error. 3 weeks ago
Jon Beniston 7afb9c64e8 Allow FIFO to be made smaller. 3 weeks ago
Jon Beniston f631e51853 ReplayBuffer: Allow buffer to be deallocated. 3 weeks ago
Jon Beniston def859c37a Fix bug. 3 weeks ago
Jon Beniston 77a60e09c1 Fix Kiwi SDR list in map. 3 weeks ago
Jon Beniston b8dc6d3f2b Android Input: Fix cleanup. 3 weeks ago
Jon Beniston 012166b68c RemoteTCPInput: Fix replay buffer size. Reduce number of GUI repaints. Fix leak. 3 weeks ago
Jon Beniston 3461c3fcf0 Optimise performance of GUI components. 3 weeks ago
Jon Beniston 3b21ef248d Update docs. 3 weeks ago
Edouard Griffiths 4a9f7bc625
Merge pull request #3052 from rgetz/rgetz-fix-faad2-in-flatpak 3 weeks ago
Jon Beniston d6cb8f9d8e Fix PFD image. 3 weeks ago
Jon Beniston 24ff4f283f Update Map docs 3 weeks ago
Jon Beniston 4b2772da59 Update ADSB docs. 3 weeks ago
Robin Getz b4ef5da940
CI : Flatpak - update faad2 url, since sourceforge is giving 404 3 weeks ago
Jon Beniston 7b5328a8a2 Avoid duplicate hashes. 3 weeks ago
Jon Beniston 1b7de51c96 Move audio in to downloadable zip file, rather than resources. 3 weeks ago
Jon Beniston ee77798fb9 Remove --disable-frame-rate-limit, as most frames over 60Hz are discarded. 3 weeks ago
Jon Beniston 621ba92eb5 Speed up ACARS demod GUI, as there can be many of them. 3 weeks ago
Jon Beniston d39a7868eb Merge branch 'fixes' of https://github.com/srcejon/sdrangel into fixes 3 weeks ago
Jon Beniston 965fd2b096 Move range rings behind aircraft. 3 weeks ago
srcejon ab5a80be01
Merge branch 'f4exb:master' into fixes 3 weeks ago
Jon Beniston 2cbae8a9c3 Use UTC for times sent to the map, as it avoids timezone conversion, which is surprisingly costly. 3 weeks ago
Jon Beniston f6b1c36ce9 Aircraft feature: Grey/clear old data. Optimise performance. 3 weeks ago
Edouard Griffiths b8996d82af
Merge pull request #3050 from rgetz/rgetz-fix-and-avoid-3042 4 weeks ago
Robin Getz 29bf22f020
ci: Schedule Flatpak builds and notify on regressions 4 weeks ago
Robin Getz e8ebd0584b
flatpak: Update libaio source URL 4 weeks ago
srcejon 701ed14cda
Merge branch 'f4exb:master' into fixes 4 weeks ago
Edouard Griffiths c4d70a7ada
Merge pull request #3049 from rgetz/rgetz-fix-various-coverity-mediums 4 weeks ago
Robin Getz a10fb3a500
mainserver: Handle unavailable default sampling devices 4 weeks ago
Robin Getz 30998df75c
mainwindow: Handle unavailable devices and channel GUIs 4 weeks ago
Robin Getz 145f018fcf
sdrgui/gui: Guard against missing website data in loadResource() 4 weeks ago
Robin Getz 4a172e4033
sdrgui/gui: Guard against missing channel in preset dialog 4 weeks ago
Robin Getz e724c841a0
sdrgui/dsp: Fix swapped scope screen dimensions 4 weeks ago
Robin Getz cae296d8e3
sdrbase/util: Handle unknown replies in downloadFinished() 4 weeks ago
Robin Getz 9d864f70b4
sdrbase/dsp: Fix WAV tag string length encoding 4 weeks ago
Robin Getz b6aff27ebd
sdrbase/dsp: Fix copy-paste error in inverse FFT preallocation 4 weeks ago
Robin Getz cdfe0a7130
sdrbase/channel: Guard against null Web API error messages 4 weeks ago
Robin Getz a7edeafc9b
plugins/samplesource/sdrplayv3: Guard against null SDRplay thread 4 weeks ago
Robin Getz c6f577af14
plugins/samplesource/remotetcpinput: Fix message buffer overrun 4 weeks ago
Robin Getz b1b79b8d12
plugins/samplesource/audioinput: Guard against null worker 4 weeks ago
Robin Getz 3dd928ab3b
plugins/samplemimo/plutosdrmimo: Guard against null PlutoSDR device 4 weeks ago
Robin Getz 3c5d885e53
plugins/samplemimo/audiocatsiso: Return when rig initialization fails 4 weeks ago
Robin Getz cdef890433
plugins/samplemimo/audiocatsiso: Guard against null input worker 4 weeks ago
Robin Getz d5f0c19d26
plugins/feature/sid: Guard against null channel in getChannels() 4 weeks ago
Robin Getz 30ee35595d
plugins/feature/aprs: Fix copy-paste error in message column settings 4 weeks ago
Robin Getz 4d4489f4f9
plugins/channeltx/moddatv: Guard channel power report access 4 weeks ago
Robin Getz b56c36fed5
plugins/channelrx/remotetcpsink: Fix message buffer overrun 4 weeks ago
Robin Getz f470949674
plugins/channelrx/freqtracker: Fix applyChannelSettings argument order 4 weeks ago
Robin Getz 4806f20d03
plugins/channelrx/demodwefax: Clamp FFT bin indices 4 weeks ago
Robin Getz b86f8e8a1d
plugins/channelrx/demodm17: Avoid negative indexing in checksum extraction 4 weeks ago
Robin Getz 5f05876c54
plugins/channelrx/demoddatv: Guard against oversized shift in deconvolution 4 weeks ago
Robin Getz 321518f456
plugins/channelrx/demoddatv: Guard against null demodulator in tick() 4 weeks ago
Robin Getz acd3af86ab
modemm17: Restore ostream format after printing AX.25 PID 4 weeks ago
Robin Getz 4abed62ecc
modemdvb: Document LDPCPool::cancel() locking requirement 4 weeks ago
Robin Getz b2e6a5cc8a
modemdvb: Fix data races on input sample rate 4 weeks ago
Robin Getz 154e76b045
modemdvb: Fix negative shift in cell interleaver 4 weeks ago
Robin Getz 1afb509999
modemdvb: Fix data race in DVB-S2 deframing 4 weeks ago
Robin Getz b34caee95c
modemdrm: Guard against missing spectrum parameters 4 weeks ago
Robin Getz 68585cac68
modemdab: Avoid Coverity overflow warning in CRC16 4 weeks ago
Robin Getz bf733989d1
modemdab: Fix integer division in symbol power calculation 4 weeks ago
Robin Getz b2550624e2
httpserver: Guard against null uploaded files in destructor 4 weeks ago
Robin Getz ced7672560
ft8: Fix copy-paste error in 22-bit callsign lookup 4 weeks ago
Jon Beniston ba53523463 Add database download button. Separate flight and aircraft retention settings. 4 weeks ago
Jon Beniston fb3058dea3 Fix warnings 4 weeks ago
Jon Beniston d45dcfdc2a Add MapBox API key setting. Default to osm maps on Linux on Qt 5.15.13 and above. 4 weeks ago
Jon Beniston ed4b51aca0 Fix cesium bug 4 weeks ago
Jon Beniston f9d5825953 Update docs 4 weeks ago
Jon Beniston 389ed017ce Use weak references to avoid mem leak. 4 weeks ago
Jon Beniston ff8890cbcb Use liveries when 3D models not installed. 4 weeks ago
Jon Beniston 068e08a07d Add coverage image. 4 weeks ago
Jon Beniston 259f24ceec Add individual coverage display settings. 4 weeks ago
srcejon de0bddf420
Merge branch 'f4exb:master' into fixes 4 weeks ago
Edouard Griffiths d61e778ad4
Merge pull request #3045 from rgetz/rgetz-fix-qt5-warnings 4 weeks ago
Edouard Griffiths 33e995f12c
Merge pull request #3044 from rgetz/rgetz-fix-cppcheck-issues-external 4 weeks ago
Robin Getz 993d5d2710
glshaderspectrogram: Fix deprecated QOpenGLTexture::setData() call 4 weeks ago
Robin Getz 169fef68a3
glshadercolormap: Fix deprecated QOpenGLTexture::setData() call 4 weeks ago
Robin Getz 8119562b37
wefaxdemodgui: Use QWheelEvent::position() on Qt 5.15+ 4 weeks ago
Edouard Griffiths fdcca2675a
Merge pull request #3043 from f4exb/fix-3039 4 weeks ago
Robin Getz 1286c6d088
spectrummeasurements: Use unsigned mask for bit shifts 4 weeks ago
Robin Getz 738b40ff34
scidoublespinbox: Mark conversion result as unused 4 weeks ago
Robin Getz 091cd9d795
dtvvideoplayer: Initialize video info fields 4 weeks ago
Robin Getz 853309ac6e
sdrbench: Fix memory leaks in FT8 protocol test 4 weeks ago
Robin Getz 39301fc704
osndb: Initialize aircraft ICAO field 4 weeks ago
Robin Getz fcdb5329e1
dtv: Initialize UDP datagram buffer 4 weeks ago
Robin Getz cbaa53b6fb
dtv: Explicitly initialize PAT and PMT section containers 4 weeks ago
Robin Getz 716620960f
dtv: Guard PSI input and partial packet state 4 weeks ago
Robin Getz 789c2a68a0
dtv: Validate carousel descriptor lengths 4 weeks ago
Robin Getz 032751356d
sigmffileinput: Initialize worker metadata and sample count 4 weeks ago
Robin Getz 5fe695a224
sigmffileinput: Set default metadata values 4 weeks ago
Robin Getz e275f029a0
remoteinput: Initialize FEC decoder slot state 4 weeks ago
Robin Getz bfeecb8341
remoteoutput: Initialize FEC device index 4 weeks ago
Robin Getz a386c1eb0e
remoteoutput: Initialize FIFO size and indices 4 weeks ago
Robin Getz 2893cdf5df
samplemimo/limesdrmimo: Initialize output buffer and interpolation 4 weeks ago
Robin Getz 3e8337d343
samplemimo/limesdrmimo: Initialize thread buffers and decimation 4 weeks ago
Robin Getz 0a860a0c2e
startracker: Initialize horizontal coordinate structures 4 weeks ago
Robin Getz fb795bb670
satellitetracker: Initialize previous azimuth 4 weeks ago
Robin Getz 8b67bfa7f8
morsedecoder: Initialize scope GUI pointer 4 weeks ago
Robin Getz 1a8071ec06
morsedecoder: Initialize text report metrics 4 weeks ago
Robin Getz f309fc79e3
plugins/denoiser: Initialize denoiser buffers and levels 4 weeks ago
Robin Getz 11775ea7a7
afc: Fix message leak when GUI message queue is unavailable 4 weeks ago
Robin Getz dfbb3f883e
sigmffilesink: Initialize recording sink parameters 4 weeks ago
Robin Getz d1b888c920
sigmffilesink: Initialize baseband sink state 4 weeks ago
Robin Getz b7a57a4668
remotesink: Initialize FIFO size and indices 4 weeks ago
Robin Getz ff498fa68f
demodmeshtastic: Initialize network manager before settings 4 weeks ago
Robin Getz c7792091d9
demodinmarsat: Initialize channel and bit buffer state 4 weeks ago
Robin Getz df090f119d
demoddvb: Initialize EPG section storage 4 weeks ago
Robin Getz 2060409612
demoddatv/leansdr/dvbs2: Fix FEC decoder writer resource leaks 4 weeks ago
Robin Getz c0029b6332
demodapt: Delete unsupported sink copy operations 4 weeks ago
Robin Getz 84017029f0
demodapt: Reset scan direction to default 4 weeks ago
Robin Getz 90caed020e
demodapt: Initialize APT line message buffer 4 weeks ago
Robin Getz 42ba984941
demodapt: Check satellite name before logging 4 weeks ago
Robin Getz 0c7da6ee0f
demod802.15.4: Initialize demodulator receiver state 4 weeks ago
Robin Getz 02eb254b0c
modemdvb: Initialize DVB-T outer decoder packet buffer 4 weeks ago
Robin Getz e75f7f5e4d
modemdvb: Initialize OFDM demodulator state 4 weeks ago
Robin Getz 7650709aaa
modemdvb: Initialize DVB-T TPS bit buffer 4 weeks ago
Robin Getz ca971f2ff7
modemdvb: Initialize OFDM grid parameters 4 weeks ago
Robin Getz 169a1c1f1a
modemdvb: Initialize DVB-T2 post-LDPC block state 4 weeks ago
Robin Getz 9e757b9c93
modemdr: Validate Journaline data and cleanup iterator 4 weeks ago
Robin Getz d558d0ed43
modemdab: Fix front-end member initialization order 4 weeks ago
Robin Getz 8565aa221f
modemdab: Match MSC decoder member initialization order 4 weeks ago
Robin Getz e428c121d0
modemdab: Avoid complex type warning in FFT output copy 4 weeks ago
Robin Getz 5e7a45df6d
modemdab: Validate FIG 2 label field length 4 weeks ago
Robin Getz 7b10626a20
httpserver: Remove redundant chunked response check 4 weeks ago
Robin Getz 3738cd46a6
devices/perseus: Delete unsupported/unnecessary copy operations 4 weeks ago
Robin Getz e8cdeeda92
devices/limesdr: Use correct format specifier for channel index 4 weeks ago
f4exb 599534307c Fix #3039: MCP: corrected input schema of tune_gain tool 4 weeks ago
Jon Beniston dc67dca7ce Update docs. 4 weeks ago
Edouard Griffiths 24ac613898
Merge pull request #3040 from rgetz/rgetz-fix-some-coverity-highs 4 weeks ago
Robin Getz a5719c9240
ft8/libldpc: Fix Gauss-Jordan row bounds 4 weeks ago
Robin Getz 1f93fa6fc8
modemdvb: Validate constellation in InnerDecoder::configure 4 weeks ago
Robin Getz 3a4a6fb87a
dvbs2: Validate BCH information length before deframing 4 weeks ago
Robin Getz 7f2da76143
modemdvb: Validate constellation in Receiver::analyseBlock 4 weeks ago
Robin Getz bbbcf9260f
demoddvb: Initialize player info before checking player 4 weeks ago
Robin Getz 1c7ad81400
modemdvb: Validate constellation in cellBitMap 4 weeks ago
Robin Getz 1665689b82
mod802.15.4: Prevent out-of-bounds BPSK chip lookup 4 weeks ago
Jon Beniston 8c32d84653 Fix Qt5 support. Fix compiler warnings. Optimise Iridium demod. 4 weeks ago
Jon Beniston fa01bc6bb9 mapviewcoordinator.cpp not needed for server build 4 weeks ago
Jon Beniston 6d334268c1 Fix warnings. 4 weeks ago
Jon Beniston 085a8a36c7 Fix when server enabled. 4 weeks ago
Jon Beniston f5ff904d22 Optimise widgets to avoid repaints/relayouts. 4 weeks ago
srcejon 7d451def3e
Merge branch 'f4exb:master' into fixes 4 weeks ago
Jon Beniston b48deee21c Update map API. 4 weeks ago
Jon Beniston 7da02b165f Map: Update cockpit instruments to churn less memory. Update model convert to produce faster LOD1 models, for aircraft at a distance. Optionally reduce texture size. Improve map startup time. Add CartoDB API key. Fix memory leak. Add distance ambient lighting. 4 weeks ago
Jon Beniston 750d0b3856 ADSB: Add colour aircraft icons. Add API key for CartoDB. Run in server mode. Support Aircraft feature. 4 weeks ago
srcejon 92fa13025a
Merge branch 'f4exb:master' into fixes 4 weeks ago
srcejon 60f13845d7
Merge branch 'f4exb:master' into fixes 4 weeks ago
srcejon 2b0f48c908
Merge branch 'f4exb:master' into fixes 1 month ago
srcejon 54ad02db37
Merge branch 'f4exb:master' into fixes 1 month ago
srcejon 7856270252
Merge branch 'f4exb:master' into fixes 1 month ago
srcejon f0f464e58d
Merge branch 'f4exb:master' into fixes 1 month ago
srcejon e7f6eceec2
Merge branch 'f4exb:master' into fixes 1 month ago
srcejon a8b2ab8233
Merge branch 'f4exb:master' into fixes 1 month ago
Jon Beniston 2c7d57d9cc Merge branch 'master' into fixes 1 month ago
srcejon c41f818e4b Regenerate swagger 3 months ago
srcejon 926b07f68a Regenerate swagger 3 months ago
Jon Beniston 80feb24d40 Update map yaml for ND 3 months ago
srcejon f41af1ebb2 Regenerate swagger 3 months ago
Jon Beniston 1f9b0b810d Add group option to MapItem. 3 months ago
Jon Beniston a874cbbe16 Don't clip aircraft images when rotated 3 months ago
Jon Beniston e08ceedaf1 Use real for zoomLevel, so we don't get a jump in aircraft size when zooming. 3 months ago
srcejon 5424ffdb95 Regenerate swagger 3 months ago
Jon Beniston 54da83a378 Support multiple way points having the same name. Choose the closest. 3 months ago
Jon Beniston 5042d75931 Fix memory leak. 3 months ago
Jon Beniston bdf410d11d Don't hash aircraft with no registration. 3 months ago
Jon Beniston 394224ed42 Log profile data on exit. 3 months ago
Jon Beniston 2b9cda833a Workspace GUI: Add ability to start all features and all devices & features in all workspaces 3 months ago
Jon Beniston 068cfca547 Add Aircraft feature 3 months ago
Jon Beniston 275176da87 Add ACARS demodulator 3 months ago
  1. 5
      .gitattributes
  2. 100
      .github/workflows/flatpak.yml
  3. 4
      .github/workflows/mac.yml
  4. 12
      .github/workflows/sdrangel.yml
  5. 7
      .github/workflows/windows.yml
  6. 12
      CHANGELOG
  7. 12
      CMakeLists.txt
  8. 17
      CMakePresets.json
  9. 1
      app/main.cpp
  10. 32
      cmake/Modules/FindLibAcars.cmake
  11. 11
      cmake/cpack/CMakeLists.txt
  12. 12
      debian/changelog
  13. 6
      devices/limesdr/devicelimesdr.cpp
  14. 4
      devices/perseus/deviceperseus.h
  15. BIN
      doc/img/ADSBDemod_plugin.png
  16. BIN
      doc/img/ADSBDemod_plugin_settings.png
  17. BIN
      doc/img/ATVDemod_pluginB.png
  18. BIN
      doc/img/AcarsDemod_chart.png
  19. BIN
      doc/img/AcarsDemod_decode.png
  20. BIN
      doc/img/AcarsDemod_plugin.png
  21. BIN
      doc/img/AcarsDemod_table.png
  22. BIN
      doc/img/AircraftFeature_aircraft_tab.png
  23. BIN
      doc/img/AircraftFeature_aircraft_table.png
  24. BIN
      doc/img/AircraftFeature_atc_labels.png
  25. BIN
      doc/img/AircraftFeature_atc_tab.png
  26. BIN
      doc/img/AircraftFeature_chart.png
  27. BIN
      doc/img/AircraftFeature_clearance.png
  28. BIN
      doc/img/AircraftFeature_coverage.png
  29. BIN
      doc/img/AircraftFeature_flight_plan.png
  30. BIN
      doc/img/AircraftFeature_flight_profile.png
  31. BIN
      doc/img/AircraftFeature_flights_table.png
  32. BIN
      doc/img/AircraftFeature_loadsheet.png
  33. BIN
      doc/img/AircraftFeature_map.jpg
  34. BIN
      doc/img/AircraftFeature_plugin.png
  35. BIN
      doc/img/AircraftFeature_settings.png
  36. BIN
      doc/img/AircraftFeature_statistics.png
  37. BIN
      doc/img/Map_plugin_aircraft.png
  38. BIN
      doc/img/Map_plugin_dcdu.png
  39. BIN
      doc/img/Map_plugin_efis.png
  40. BIN
      doc/img/Map_plugin_nd.png
  41. BIN
      doc/img/Map_plugin_pfd.png
  42. BIN
      doc/img/Map_plugin_rmp.png
  43. 27
      external/CMakeLists.txt
  44. 21
      flatpak/org.sdrangel.SDRangel.yaml
  45. 4
      ft8/libldpc.cpp
  46. 2
      ft8/packing.cpp
  47. 3
      gitdiff.sh
  48. 3
      httpserver/httprequest.cpp
  49. 13
      httpserver/httpresponse.cpp
  50. 4
      modemdab/dabensemble.cpp
  51. 2
      modemdab/dabfft.cpp
  52. 4
      modemdab/dabmsc.cpp
  53. 6
      modemdab/dabofdm.cpp
  54. 2
      modemdab/dabtables.cpp
  55. 12
      modemdr/journaline.cpp
  56. 3
      modemdrm/drmchannelestimator.cpp
  57. 6
      modemdvb/dvbs2receiver.cpp
  58. 20
      modemdvb/dvbt2fec.cpp
  59. 5
      modemdvb/dvbt2ofdm.cpp
  60. 14
      modemdvb/dvbt2receiver.cpp
  61. 13
      modemdvb/dvbtinner.cpp
  62. 1
      modemdvb/dvbtmodulator.cpp
  63. 9
      modemdvb/dvbtofdm.cpp
  64. 1
      modemdvb/dvbtouter.cpp
  65. 13
      modemdvb/dvbtreceiver.cpp
  66. 1
      modemdvb/ldpcpool.cpp
  67. 2
      modemm17/ax25_frame.h
  68. 24
      plugins/channelrx/CMakeLists.txt
  69. 2
      plugins/channelrx/demod802.15.4/ieee_802_15_4_demodplugin.cpp
  70. 22
      plugins/channelrx/demod802.15.4/ieee_802_15_4_demodreceiver.cpp
  71. 124
      plugins/channelrx/demodacars/CMakeLists.txt
  72. 3426
      plugins/channelrx/demodacars/acarsaero.h
  73. 769
      plugins/channelrx/demodacars/acarsdemod.cpp
  74. 322
      plugins/channelrx/demodacars/acarsdemod.h
  75. 196
      plugins/channelrx/demodacars/acarsdemodbaseband.cpp
  76. 104
      plugins/channelrx/demodacars/acarsdemodbaseband.h
  77. 6
      plugins/channelrx/demodacars/acarsdemoddata.qrc
  78. 2105
      plugins/channelrx/demodacars/acarsdemodgui.cpp
  79. 244
      plugins/channelrx/demodacars/acarsdemodgui.h
  80. 1149
      plugins/channelrx/demodacars/acarsdemodgui.ui
  81. 8
      plugins/channelrx/demodacars/acarsdemodicons.qrc
  82. 92
      plugins/channelrx/demodacars/acarsdemodplugin.cpp
  83. 49
      plugins/channelrx/demodacars/acarsdemodplugin.h
  84. 279
      plugins/channelrx/demodacars/acarsdemodsettings.cpp
  85. 150
      plugins/channelrx/demodacars/acarsdemodsettings.h
  86. 523
      plugins/channelrx/demodacars/acarsdemodsink.cpp
  87. 193
      plugins/channelrx/demodacars/acarsdemodsink.h
  88. 52
      plugins/channelrx/demodacars/acarsdemodwebapiadapter.cpp
  89. 50
      plugins/channelrx/demodacars/acarsdemodwebapiadapter.h
  90. 2586
      plugins/channelrx/demodacars/acarsdemodworker.cpp
  91. 276
      plugins/channelrx/demodacars/acarsdemodworker.h
  92. 3114
      plugins/channelrx/demodacars/acarshfdl.h
  93. 894
      plugins/channelrx/demodacars/acarsiridium.h
  94. 443
      plugins/channelrx/demodacars/acarsiridiumchannelizer.h
  95. 373
      plugins/channelrx/demodacars/acarsiridiumdetector.h
  96. 147
      plugins/channelrx/demodacars/acarsiridiumfft.h
  97. 173
      plugins/channelrx/demodacars/acarsiridiumfftengine.h
  98. 1118
      plugins/channelrx/demodacars/acarsiridiumframe.h
  99. 347
      plugins/channelrx/demodacars/acarsiridiumscanner.h
  100. 366
      plugins/channelrx/demodacars/acarsmessagemodel.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

5
.gitattributes vendored

@ -5,6 +5,11 @@ @@ -5,6 +5,11 @@
# Vendored Cesium content: preserve upstream line endings.
plugins/feature/map/Cesium/** -text
# Vendor source
plugins/channelrx/demodacars/atn/** -text
plugins/channelrx/demodacars/vdl2gs.txt -text
plugins/feature/map/msfsassetconverter/LICENSE.md -text
# Generated Swagger UI files
sdrbase/resources/webapi/doc/swagger-ui/** -text

100
.github/workflows/flatpak.yml

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
name: SDRangel Flatpak Build
on:
schedule:
- cron: '23 6 * * 1' # Mondays at 06:23 UTC; periodically check code and flatpack infrastructure
push:
branches:
- flatpak
tags:
- 'v*'
workflow_dispatch:
@ -29,8 +29,6 @@ jobs: @@ -29,8 +29,6 @@ jobs:
run: |
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
version="${GITHUB_REF_NAME#v}"
elif [[ "$GITHUB_REF_NAME" == "flatpak" ]]; then
version="${GITHUB_SHA::8}"
else
version="${GITHUB_REF_NAME//\//-}-${GITHUB_SHA::8}"
fi
@ -43,6 +41,7 @@ jobs: @@ -43,6 +41,7 @@ jobs:
manifest-path: flatpak/org.sdrangel.SDRangel.yaml
cache-key: flatpak-builder-${{ hashFiles('flatpak/**') }}
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_version.outputs.bundle }}
@ -52,3 +51,96 @@ jobs: @@ -52,3 +51,96 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.get_version.outputs.bundle }}
notify_flatpak_failure:
needs: build_flatpak
# Notify only for scheduled failures, not tag releases or manual runs.
# Ignore reruns to avoid duplicate issues.
if: ${{ failure() && github.event_name == 'schedule' && github.run_attempt == 1 }}
runs-on: ubuntu-latest
permissions:
actions: read
issues: write
steps:
- name: Check SDRangel CI/CD status
id: health
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}
run: |
deadline=$((SECONDS + 2 * 60 * 60))
conclusion=unknown
# Wait up to two hours for CI/CD to finish for this exact commit.
# Any successful run takes precedence over failed runs for the same SHA.
# If no completed run exists, keep waiting; timeout leaves "unknown".
while (( SECONDS < deadline )); do
conclusion=$(gh api \
"repos/$GH_REPO/actions/workflows/sdrangel.yml/runs?branch=master&head_sha=$COMMIT_SHA&per_page=100" \
--jq '[
.workflow_runs[]
| select(.conclusion == "success" or .conclusion == "failure")
| .conclusion
] | if any(.[]; . == "success") then "success"
elif any(.[]; . == "failure") then "failure"
else "unknown" end') || {
echo "Failed to query SDRangel CI/CD; retrying in 5 minutes..." >&2
sleep 300
continue
}
if [[ "$conclusion" != "unknown" ]]; then
break
fi
echo "CI/CD has not completed for $COMMIT_SHA; waiting 5 minutes..."
sleep 300
done
echo "Latest SDRangel CI/CD conclusion: $conclusion"
echo "conclusion=$conclusion" >> "$GITHUB_OUTPUT"
- name: Check previous scheduled build
id: previous
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
CURRENT_RUN_ID: ${{ github.run_id }}
run: |
# Find the most recent completed scheduled Flatpak run, excluding
# this run. Only a success -> failure transition should open an issue.
previous=$(gh api \
"repos/$GH_REPO/actions/workflows/flatpak.yml/runs?branch=master&event=schedule&per_page=20" \
--jq "([.workflow_runs[]
| select(.id != $CURRENT_RUN_ID)
| select(.conclusion != null)]
| sort_by(.created_at)
| last
| .conclusion) // \"unknown\"")
echo "Previous scheduled build: $previous"
echo "conclusion=$previous" >> "$GITHUB_OUTPUT"
- name: Notify on passing-to-failing transition
# Require both a previously successful Flatpak build and healthy CI/CD
# on the current commit before reporting a regression.
if: steps.previous.outputs.conclusion == 'success' && steps.health.outputs.conclusion == 'success'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMIT_SHA: ${{ github.sha }}
run: |
gh issue create \
--repo "$GH_REPO" \
--title "Flatpak build regressed" \
--body "$(cat <<EOF
The Flatpak build on master is now failing.
- Commit: $COMMIT_SHA
- Failed run: $RUN_URL
Please investigate the build failure.
EOF
)"

4
.github/workflows/mac.yml

@ -36,7 +36,7 @@ jobs: @@ -36,7 +36,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.11.2'
version: '6.11.3'
host: 'mac'
arch: 'clang_64'
modules: 'qtcharts qtscxml qt5compat qtlocation qtmultimedia qtpositioning qtserialport qtspeech qtwebsockets qtwebengine qtshadertools qtwebchannel'
@ -111,7 +111,7 @@ jobs: @@ -111,7 +111,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.11.2'
version: '6.11.3'
host: 'mac'
arch: 'clang_64'
modules: 'qtcharts qtscxml qt5compat qtlocation qtmultimedia qtpositioning qtserialport qtspeech qtwebsockets qtwebengine qtshadertools qtwebchannel'

12
.github/workflows/sdrangel.yml

@ -27,7 +27,7 @@ jobs: @@ -27,7 +27,7 @@ jobs:
WIN_ARCH: "x64",
os: windows-latest,
QT_INST_DIR: "C:/",
QTDIR: "C:/Qt/6.9.3/msvc2022_64",
QTDIR: "C:/Qt/6.11.3/msvc2022_64",
QT_ARCH: win64_msvc2022_64,
boost_dl: "${{ github.workspace }}\\downloads\\boost",
lib_dir: "C:\\Libraries",
@ -82,7 +82,8 @@ jobs: @@ -82,7 +82,8 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.9.3'
version: '6.11.3'
aqtsource: git+https://github.com/miurahr/aqtinstall.git@076e1659807d0b362a3ed684d54c2e9c775eb9c7
dir: ${{matrix.config.QT_INST_DIR}}
arch: ${{matrix.config.QT_ARCH}}
setup-python: false
@ -93,7 +94,7 @@ jobs: @@ -93,7 +94,7 @@ jobs:
cmd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
choco install patch
mkdir build && cd build
cmake .. -G "${{ matrix.config.generators }}" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT6=ON -DARCH_OPT=SSE4_2 -DDEBUG_OUTPUT=ON -DENABLE_MIRISDR=OFF -DBUILD_SERVER=OFF -DCMAKE_PREFIX_PATH="C:\Qt\6.9.3\msvc2022_64;C:\Libraries\boost_1_73_0"
cmake .. -G "${{ matrix.config.generators }}" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT6=ON -DARCH_OPT=SSE4_2 -DDEBUG_OUTPUT=ON -DENABLE_MIRISDR=OFF -DBUILD_SERVER=OFF -DCMAKE_PREFIX_PATH="C:\Qt\6.11.3\msvc2022_64;C:\Libraries\boost_1_73_0"
cmake --build . --config Release
cmake --build . --config Release --target package
- name: Check disk space
@ -148,6 +149,11 @@ jobs: @@ -148,6 +149,11 @@ jobs:
with:
submodules: true
fetch-depth: 0
- name: Free disk space
run: |
df -h /
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/.ghcup
df -h /
- name: Install dependencies
run: |
sudo apt-get update

7
.github/workflows/windows.yml

@ -21,7 +21,7 @@ jobs: @@ -21,7 +21,7 @@ jobs:
WIN_ARCH: "x64",
os: windows-latest,
QT_INST_DIR: "C:/",
QTDIR: "C:/Qt/6.9.3/msvc2022_64",
QTDIR: "C:/Qt/6.11.3/msvc2022_64",
QT_ARCH: win64_msvc2022_64,
boost_dl: "${{ github.workspace }}\\downloads\\boost",
lib_dir: "C:\\Libraries",
@ -76,7 +76,8 @@ jobs: @@ -76,7 +76,8 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.9.3'
version: '6.11.3'
aqtsource: git+https://github.com/miurahr/aqtinstall.git@076e1659807d0b362a3ed684d54c2e9c775eb9c7
dir: ${{matrix.config.QT_INST_DIR}}
arch: ${{matrix.config.QT_ARCH}}
setup-python: 'false'
@ -87,7 +88,7 @@ jobs: @@ -87,7 +88,7 @@ jobs:
cmd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
choco install patch
mkdir build && cd build
cmake .. -G "${{ matrix.config.generators }}" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT6=ON -DARCH_OPT=SSE4_2 -DDEBUG_OUTPUT=ON -DENABLE_MIRISDR=OFF -DBUILD_SERVER=OFF -DCMAKE_PREFIX_PATH="C:\Qt\6.9.3\msvc2019_64;C:\Libraries\boost_1_73_0"
cmake .. -G "${{ matrix.config.generators }}" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT6=ON -DARCH_OPT=SSE4_2 -DDEBUG_OUTPUT=ON -DENABLE_MIRISDR=OFF -DBUILD_SERVER=OFF -DCMAKE_PREFIX_PATH="C:\Qt\6.11.3\msvc2019_64;C:\Libraries\boost_1_73_0"
cmake --build . --config Release --target package
- name: Check disk space
run: Get-PSDrive

12
CHANGELOG

@ -1,3 +1,15 @@ @@ -1,3 +1,15 @@
sdrangel (8.1.0-1) unstable; urgency=medium
* See Github release
-- Edouard Griffiths (F4EXB) <f4exb06@gmail.com> Sun, 08 Nov 2026 12:00:00 +0100
sdrangel (8.0.0-1) unstable; urgency=medium
* See Github release
-- Edouard Griffiths (F4EXB) <f4exb06@gmail.com> Sun, 25 Oct 2026 12:00:00 +0100
sdrangel (7.27.2-1) unstable; urgency=medium
* See Github release

12
CMakeLists.txt

@ -23,7 +23,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -23,7 +23,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# configure version
set(sdrangel_VERSION_MAJOR "8")
set(sdrangel_VERSION_MINOR "0")
set(sdrangel_VERSION_MINOR "1")
set(sdrangel_VERSION_PATCH "0")
set(sdrangel_VERSION_SUFFIX "")
@ -177,6 +177,7 @@ option(ENABLE_CHANNELRX_DEMODRTTY "Enable channelrx demodrtty plugin" ON) @@ -177,6 +177,7 @@ option(ENABLE_CHANNELRX_DEMODRTTY "Enable channelrx demodrtty plugin" ON)
option(ENABLE_CHANNELRX_DEMODPSK31 "Enable channelrx demodpsk31 plugin" ON)
option(ENABLE_CHANNELRX_DEMODILS "Enable channelrx demodils plugin" ON)
option(ENABLE_CHANNELRX_DEMODSELCAL "Enable channelrx demodselcal plugin" ON)
option(ENABLE_CHANNELRX_DEMODCHIRPMODEM "Enable channelrx demodchirpmodem plugin (needs libchirpmodem)" ON)
option(ENABLE_CHANNELRX_DEMOD802.15.4 "Enable channelrx demod802.15.4 plugin" ON)
option(ENABLE_CHANNELRX_DEMODDSC "Enable channelrx demoddsc plugin" ON)
option(ENABLE_CHANNELRX_HEATMAP "Enable channelrx heatmap plugin" ON)
@ -185,6 +186,7 @@ option(ENABLE_CHANNELRX_ENDOFTRAIN "Enable channelrx end-of-train plugin" ON) @@ -185,6 +186,7 @@ option(ENABLE_CHANNELRX_ENDOFTRAIN "Enable channelrx end-of-train plugin" ON)
option(ENABLE_CHANNELRX_CHANNELPOWER "Enable channelrx channel power plugin" ON)
option(ENABLE_CHANNELRX_WDSPRX "Enable channelrx WDSP receiver plugin" ON)
option(ENABLE_CHANNELRX_DEMODINMARSAT "Enable channelrx demodinmarsat plugin" ON)
option(ENABLE_CHANNELRX_DEMODACARS "Enable channelrx demodacars plugin" ON)
# Channel Tx enablers
option(ENABLE_CHANNELTX "Enable channeltx plugins" ON)
@ -196,6 +198,7 @@ option(ENABLE_CHANNELTX_MODDATV "Enable channeltx moddatv plugin" ON) @@ -196,6 +198,7 @@ option(ENABLE_CHANNELTX_MODDATV "Enable channeltx moddatv plugin" ON)
option(ENABLE_CHANNELTX_MODAM "Enable channeltx modam plugin" ON)
option(ENABLE_CHANNELTX_MODFREEDV "Enable channeltx modfreedv plugin" ON)
option(ENABLE_CHANNELTX_MODPACKET "Enable channeltx modpacket plugin" ON)
option(ENABLE_CHANNELTX_MODCHIRPMODEM "Enable channeltx modchirpmodem plugin (needs libchirpmodem)" ON)
option(ENABLE_CHANNELTX_MODSSB "Enable channeltx modssb plugin" ON)
option(ENABLE_CHANNELTX_UDPSOURCE "Enable channeltx udpsource plugin" ON)
option(ENABLE_CHANNELTX_MODCHIRPCHAT "Enable channeltx modchirpchat plugin" ON)
@ -229,6 +232,7 @@ option(ENABLE_FEATURE_SATELLITETRACKER "Enable feature satellitetracker plugin" @@ -229,6 +232,7 @@ option(ENABLE_FEATURE_SATELLITETRACKER "Enable feature satellitetracker plugin"
option(ENABLE_FEATURE_APRS "Enable feature aprs plugin" ON)
option(ENABLE_FEATURE_DEMODANALYZER "Enable feature demodanalyzer plugin" ON)
option(ENABLE_FEATURE_AMBE "Enable feature ambe plugin" ON)
option(ENABLE_FEATURE_AIRCRAFT "Enable feature aircraft plugin" ON)
option(ENABLE_FEATURE_AIS "Enable feature ais plugin" ON)
option(ENABLE_FEATURE_AFC "Enable feature afc plugin" ON)
option(ENABLE_FEATURE_STARTRACKER "Enable feature startracker plugin" ON)
@ -527,6 +531,7 @@ elseif (WIN32) @@ -527,6 +531,7 @@ elseif (WIN32)
set(LIBACARS_FOUND ON CACHE INTERNAL "")
set(LIBACARS_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/libacars/include/libacars-2" CACHE INTERNAL "")
set(LIBACARS_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/libacars/lib/acars-2.lib" CACHE INTERNAL "")
set(LIBACARS_DLL_DIR "${EXTERNAL_LIBRARY_FOLDER}/libacars/bin/" CACHE INTERNAL "")
# used on fixup_bundle phase
set(WINDOWS_FIXUP_BUNDLE_LIB_DIRS
@ -1025,6 +1030,7 @@ if (NOT ENABLE_EXTERNAL_LIBRARIES OR (ENABLE_EXTERNAL_LIBRARIES STREQUAL "AUTO") @@ -1025,6 +1030,7 @@ if (NOT ENABLE_EXTERNAL_LIBRARIES OR (ENABLE_EXTERNAL_LIBRARIES STREQUAL "AUTO")
find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
find_package(GGMorse)
find_package(LibInmarsatC)
find_package(LibAcars)
find_package(RNnoise)
find_package(FLAC)
if (ENABLE_CHANNELRX AND ENABLE_CHANNELRX_DEMODDRM)
@ -1344,13 +1350,13 @@ endif() @@ -1344,13 +1350,13 @@ endif()
if (LINUX AND ENABLE_EXTERNAL_LIBRARIES)
install(DIRECTORY ${EXTERNAL_BUILD_LIBRARIES}/lib${LIB_SUFFIX}/ DESTINATION ${INSTALL_LIB_DIR})
endif()
if(WIN32)
if(WIN32 AND BUILD_GUI)
include(DeployQt)
windeployqt(${CMAKE_PROJECT_NAME} ${SDRANGEL_BINARY_BIN_DIR} ${PROJECT_SOURCE_DIR}/sdrgui/resources)
endif()
# Install debug symbols
if (WIN32)
if (WIN32 AND BUILD_GUI)
install(FILES $<TARGET_PROPERTY:${CMAKE_PROJECT_NAME},RUNTIME_OUTPUT_DIRECTORY>/${CMAKE_PROJECT_NAME}stripped.pdb CONFIGURATIONS Release DESTINATION ${INSTALL_LIB_DIR} RENAME ${CMAKE_PROJECT_NAME}.pdb)
install(FILES $<TARGET_PDB_FILE:${CMAKE_PROJECT_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_BIN_DIR} )
endif()

17
CMakePresets.json

@ -53,20 +53,21 @@ @@ -53,20 +53,21 @@
"RX_SAMPLE_24BIT": "ON",
"ARCH_OPT": "SSE4_2",
"HIDE_CONSOLE": "OFF",
"ENABLE_AIRSPY": "ON",
"ENABLE_AIRSPY": "OFF",
"ENABLE_AIRSPYHF": "ON",
"ENABLE_BLADERF": "ON",
"ENABLE_BLADERF": "OFF",
"ENABLE_HACKRF": "ON",
"ENABLE_IIO": "ON",
"ENABLE_MIRISDR": "OFF",
"ENABLE_PERSEUS": "ON",
"ENABLE_PERSEUS": "OFF",
"ENABLE_RTLSDR": "ON",
"ENABLE_SDRPLAY": "ON",
"ENABLE_SOAPYSDR": "ON",
"ENABLE_XTRX": "ON",
"ENABLE_SOAPYSDR": "OFF",
"ENABLE_XTRX": "OFF",
"ENABLE_USRP": "ON",
"BUILD_SERVER": "OFF",
"BUILD_MCP_BUNDLE": "ON",
"ENABLE_PROFILER": "ON",
"CMAKE_PREFIX_PATH": "C:/Qt/5.15.2/msvc2019_64;C:/Applications/boost_1_81_0"
},
"warnings": {
@ -103,7 +104,8 @@ @@ -103,7 +104,8 @@
},
{
"name": "default-windows",
"configurePreset": "default-windows"
"configurePreset": "default-windows",
"jobs": 12
},
{
"name": "default-qt6",
@ -111,7 +113,8 @@ @@ -111,7 +113,8 @@
},
{
"name": "default-qt6-windows",
"configurePreset": "default-qt6-windows"
"configurePreset": "default-qt6-windows",
"jobs": 12
}
]
}

1
app/main.cpp

@ -330,6 +330,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo @@ -330,6 +330,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
int main(int argc, char* argv[])
{
#ifdef __APPLE__
// Request OpenGL 3.3 context, needed for glspectrum and 3D Map feature
// Note that Mac only supports CoreProfile, so any deprecated OpenGL 2 features

32
cmake/Modules/FindLibAcars.cmake

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
IF (NOT LIBACARS_FOUND)
FIND_PATH(
LIBACARS_INCLUDE_DIR
NAMES libacars/libacars.h
HINTS ${LIBACARS_DIR}/include/libacars-2
PATHS /usr/include/libacars-2
/usr/local/include/libacars-2
)
FIND_LIBRARY(
LIBACARS_LIBRARY
NAMES acars-2
HINTS ${LIBACARS_DIR}/lib
${LIBACARS_DIR}/lib64
PATHS /usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
)
if (LIBACARS_INCLUDE_DIR AND LIBACARS_LIBRARY)
set(LIBACARS_LIBRARIES ${LIBACARS_LIBRARY} CACHE INTERNAL "libacars libraries")
set(LIBACARS_FOUND TRUE CACHE INTERNAL "libacars found")
message(STATUS "Found libacars: ${LIBACARS_INCLUDE_DIR}, ${LIBACARS_LIBRARIES}")
else ()
set(LIBACARS_FOUND FALSE CACHE INTERNAL "libacars found")
message(STATUS "libacars not found.")
endif ()
mark_as_advanced(LIBACARS_INCLUDE_DIR LIBACARS_LIBRARIES)
ENDIF (NOT LIBACARS_FOUND)

11
cmake/cpack/CMakeLists.txt

@ -206,6 +206,14 @@ elseif(WIN32 OR MINGW) @@ -206,6 +206,14 @@ elseif(WIN32 OR MINGW)
)
endforeach(hidapi_dll)
file(GLOB ACARS_DLLS "${LIBACARS_DLL_DIR}/acars*${CMAKE_SHARED_LIBRARY_SUFFIX}")
foreach(acars_dll ${ACARS_DLLS})
get_filename_component(acars_dll_name "${acars_dll}" NAME)
add_custom_target(copy_acars_${acars_dll_name} ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${acars_dll}" "${SDRANGEL_BINARY_BIN_DIR}/"
)
endforeach(acars_dll)
if(ENABLE_USRP AND UHD_FOUND)
file(GLOB UHD_DLLS "${UHD_DLL_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}")
foreach(uhd_dll ${UHD_DLLS})
@ -302,6 +310,9 @@ elseif(WIN32 OR MINGW) @@ -302,6 +310,9 @@ elseif(WIN32 OR MINGW)
# hidapi
install(DIRECTORY "${HIDAPI_DLL_DIR}/" DESTINATION "${INSTALL_LIB_DIR}"
FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}")
# acars
install(DIRECTORY "${LIBACARS_DLL_DIR}/" DESTINATION "${INSTALL_LIB_DIR}"
FILES_MATCHING PATTERN "acars*${CMAKE_SHARED_LIBRARY_SUFFIX}")
# uhd
install(DIRECTORY "${UHD_DLL_DIR}/" DESTINATION "${INSTALL_LIB_DIR}"
FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}")

12
debian/changelog vendored

@ -1,3 +1,15 @@ @@ -1,3 +1,15 @@
sdrangel (8.1.0-1) unstable; urgency=medium
* See Github release
-- Edouard Griffiths (F4EXB) <f4exb06@gmail.com> Sun, 08 Nov 2026 12:00:00 +0100
sdrangel (8.0.0-1) unstable; urgency=medium
* See Github release
-- Edouard Griffiths (F4EXB) <f4exb06@gmail.com> Sun, 25 Oct 2026 12:00:00 +0100
sdrangel (7.27.2-1) unstable; urgency=medium
* See Github release

6
devices/limesdr/devicelimesdr.cpp

@ -167,7 +167,7 @@ bool DeviceLimeSDR::SetRFELNA_dB(lms_device_t *device, std::size_t chan, int val @@ -167,7 +167,7 @@ bool DeviceLimeSDR::SetRFELNA_dB(lms_device_t *device, std::size_t chan, int val
{
if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set channel to #%lu\n", chan);
fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set channel to #%zu\n", chan);
return false;
}
@ -207,7 +207,7 @@ bool DeviceLimeSDR::SetRFETIA_dB(lms_device_t *device, std::size_t chan, int val @@ -207,7 +207,7 @@ bool DeviceLimeSDR::SetRFETIA_dB(lms_device_t *device, std::size_t chan, int val
{
if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::SetRFETIA_dB: cannot set channel to #%lu\n", chan);
fprintf(stderr, "DeviceLimeSDR::SetRFETIA_dB: cannot set channel to #%zu\n", chan);
return false;
}
@ -232,7 +232,7 @@ bool DeviceLimeSDR::SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float v @@ -232,7 +232,7 @@ bool DeviceLimeSDR::SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float v
{
if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set channel to #%lu\n", chan);
fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set channel to #%zu\n", chan);
return false;
}

4
devices/perseus/deviceperseus.h

@ -34,8 +34,8 @@ public: @@ -34,8 +34,8 @@ public:
protected:
DevicePerseus();
DevicePerseus(const DevicePerseus&) : m_nbDevices(0) {}
DevicePerseus& operator=(const DevicePerseus& other) { (void) other; return *this; }
DevicePerseus(const DevicePerseus&) = delete;
DevicePerseus& operator=(const DevicePerseus&) = delete;
~DevicePerseus();
private:

BIN
doc/img/ADSBDemod_plugin.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 666 KiB

BIN
doc/img/ADSBDemod_plugin_settings.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 46 KiB

BIN
doc/img/ATVDemod_pluginB.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
doc/img/AcarsDemod_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
doc/img/AcarsDemod_decode.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

BIN
doc/img/AcarsDemod_plugin.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
doc/img/AcarsDemod_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
doc/img/AircraftFeature_aircraft_tab.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
doc/img/AircraftFeature_aircraft_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

BIN
doc/img/AircraftFeature_atc_labels.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
doc/img/AircraftFeature_atc_tab.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
doc/img/AircraftFeature_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
doc/img/AircraftFeature_clearance.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
doc/img/AircraftFeature_coverage.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

BIN
doc/img/AircraftFeature_flight_plan.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

BIN
doc/img/AircraftFeature_flight_profile.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
doc/img/AircraftFeature_flights_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
doc/img/AircraftFeature_loadsheet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
doc/img/AircraftFeature_map.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

BIN
doc/img/AircraftFeature_plugin.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
doc/img/AircraftFeature_settings.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
doc/img/AircraftFeature_statistics.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
doc/img/Map_plugin_aircraft.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

BIN
doc/img/Map_plugin_dcdu.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
doc/img/Map_plugin_efis.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
doc/img/Map_plugin_nd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
doc/img/Map_plugin_pfd.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 KiB

After

Width:  |  Height:  |  Size: 54 KiB

BIN
doc/img/Map_plugin_rmp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

27
external/CMakeLists.txt vendored

@ -1070,6 +1070,33 @@ if(ENABLE_CHANNELRX_DEMODINMARSAT) @@ -1070,6 +1070,33 @@ if(ENABLE_CHANNELRX_DEMODINMARSAT)
endif ()
endif()
# For ACARS decoder
if(ENABLE_CHANNELRX_DEMODACARS AND (NOT LIBACARS_FOUND))
if (LINUX)
set(LIBACARS_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/lib${LIB_SUFFIX}/libacars-2${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
elseif (APPLE)
set(LIBACARS_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/libacars/src/libacars-build/libacars/libacars-2${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
endif()
ExternalProject_Add(libacars
GIT_REPOSITORY https://github.com/szpajder/libacars
GIT_TAG "v2.2.1"
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/libacars"
CMAKE_ARGS ${COMMON_CMAKE_ARGS}
BUILD_BYPRODUCTS "${LIBACARS_LIBRARIES}"
INSTALL_COMMAND ""
TEST_COMMAND ""
)
ExternalProject_Get_Property(libacars source_dir binary_dir)
set(LIBACARS_DEPENDS libacars CACHE INTERNAL "")
set_global_cache(LIBACARS_FOUND ON)
set(LIBACARS_EXTERNAL ON CACHE INTERNAL "")
set(LIBACARS_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/libacars/src/libacars" CACHE INTERNAL "")
if (APPLE)
install(DIRECTORY "${binary_dir}/libacars" DESTINATION "${INSTALL_LIB_DIR}"
FILES_MATCHING PATTERN "libacars-2*${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(MACOS_EXTERNAL_LIBS_FIXUP "${MACOS_EXTERNAL_LIBS_FIXUP};${binary_dir}/libacars")
endif ()
endif()
# For DRM demodulator AAC/xHE-AAC audio
# Built as a static library that only modemdrm links, so
# not clash with the libfdk-aac that FFmpeg may load

21
flatpak/org.sdrangel.SDRangel.yaml

@ -198,8 +198,8 @@ modules: @@ -198,8 +198,8 @@ modules:
- prefix=${FLATPAK_DEST}
sources:
- type: archive
url: https://pagure.io/libaio/archive/libaio-0.3.113/libaio-libaio-0.3.113.tar.gz
sha256: 716c7059703247344eb066b54ecbc3ca2134f0103307192e6c2b7dab5f9528ab
url: https://codeberg.org/jmoyer/libaio/releases/download/libaio-0.3.113/libaio-0.3.113.tar.gz
sha256: 2c44d1c5fd0d43752287c9ae1eb9c023f04ef848ea8d4aafa46e9aedb678200b
- name: cm256cc
buildsystem: cmake-ninja
@ -252,7 +252,7 @@ modules: @@ -252,7 +252,7 @@ modules:
- name: faad2
sources:
- type: archive
url: https://sourceforge.net/projects/faac/files/faad2-src/faad2-2.8.0/faad2-2.8.8.tar.gz
url: https://ftp2.osuosl.org/pub/blfs/conglomeration/faad2/faad2-2.8.8.tar.gz
sha256: 985c3fadb9789d2815e50f4ff714511c79c2710ac27a4aaaf5c0c2662141426d
- name: fdk-aac
@ -540,6 +540,20 @@ modules: @@ -540,6 +540,20 @@ modules:
url: https://github.com/cropinghigh/inmarsatc.git
commit: cda1242e79981d71cd8608e971c8dbc691942b10
- name: libacars
buildsystem: cmake-ninja
config-opts:
- -Wno-dev
sources:
- type: git
url: https://github.com/szpajder/libacars.git
tag: v2.2.1
commit: 9af09a0121d4ec577339cbd4c7420d7519da48fa
cleanup:
- /bin/decode_acars_apps
- /bin/adsc_get_position
- /bin/cpdlc_get_position
- name: rnnoise
sources:
- type: git
@ -565,6 +579,7 @@ modules: @@ -565,6 +579,7 @@ modules:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
- -DENABLE_QT6=ON
- -DRX_SAMPLE_24BIT=ON
- -DLIBACARS_DIR=/app
- -Wno-dev
sources:
- type: dir

4
ft8/libldpc.cpp

@ -409,7 +409,7 @@ void LDPC::gauss_jordan(int rows, int cols, int m[174][2 * 91], int which[91], i @@ -409,7 +409,7 @@ void LDPC::gauss_jordan(int rows, int cols, int m[174][2 * 91], int which[91], i
{
if (m[row][row] != 1)
{
for (int row1 = row + 1; row1 < cols; row1++)
for (int row1 = row + 1; row1 < rows; row1++)
{
if (m[row1][row] == 1)
{
@ -436,7 +436,7 @@ void LDPC::gauss_jordan(int rows, int cols, int m[174][2 * 91], int which[91], i @@ -436,7 +436,7 @@ void LDPC::gauss_jordan(int rows, int cols, int m[174][2 * 91], int which[91], i
// lazy creation of identity matrix in the upper-right quarter
m[row][rows + row] = (m[row][rows + row] + 1) % 2;
// now eliminate
for (int row1 = 0; row1 < cols; row1++)
for (int row1 = 0; row1 < rows; row1++)
{
if (row1 == row)
continue;

2
ft8/packing.cpp

@ -380,7 +380,7 @@ std::string Packing::unpack_5(int a77[], std::string& call1str, std::string& cal @@ -380,7 +380,7 @@ std::string Packing::unpack_5(int a77[], std::string& call1str, std::string& cal
int x22 = un64(a77, 12, 22);
if (hashes22.count(x22) > 0) {
ocall = hashes12[x22];
ocall = hashes22[x22];
} else {
ocall = "<...22>";
}

3
gitdiff.sh

@ -5,5 +5,6 @@ for plugin in $PLUGINS @@ -5,5 +5,6 @@ for plugin in $PLUGINS
do
FILE=$(find $BASEDIR/plugins/$plugin -name "*plugin.cpp")
echo $FILE
sed -i -E "s/QStringLiteral\(\"7\.(.*)\"\)/QStringLiteral\(\"8\.0\.0\"\)/" $FILE
sed -i -E "s/QStringLiteral\(\"8\.(.*)\"\)/QStringLiteral\(\"8\.1\.0\"\)/" $FILE
sed -i -E "s/QStringLiteral\(\"7\.(.*)\"\)/QStringLiteral\(\"8\.1\.0\"\)/" $FILE
done

3
httpserver/httprequest.cpp

@ -544,6 +544,9 @@ HttpRequest::~HttpRequest() @@ -544,6 +544,9 @@ HttpRequest::~HttpRequest()
foreach(QByteArray key, uploadedFiles.keys())
{
QTemporaryFile* file=uploadedFiles.value(key);
if (!file) {
continue;
}
if (file->isOpen())
{
file->close();

13
httpserver/httpresponse.cpp

@ -130,14 +130,11 @@ void HttpResponse::write(QByteArray data, bool lastPart) @@ -130,14 +130,11 @@ void HttpResponse::write(QByteArray data, bool lastPart)
{
if (chunkedMode)
{
if (data.size()>0)
{
QByteArray size=QByteArray::number(data.size(),16);
writeToSocket(size);
writeToSocket("\r\n");
writeToSocket(data);
writeToSocket("\r\n");
}
QByteArray size=QByteArray::number(data.size(),16);
writeToSocket(size);
writeToSocket("\r\n");
writeToSocket(data);
writeToSocket("\r\n");
}
else
{

4
modemdab/dabensemble.cpp

@ -968,6 +968,10 @@ void DABEnsemble::fig2(const uint8_t *data, int length) @@ -968,6 +968,10 @@ void DABEnsemble::fig2(const uint8_t *data, int length)
field.insert(field.end(), label.segments[i].begin(), label.segments[i].end());
}
if (field.size() < 3) {
return;
}
const bool ucs2 = (field[0] & 0x80) != 0;
const uint16_t flags = static_cast<uint16_t>((field[1] << 8) | field[2]);
const int charset = ucs2 ? 6 : 15;

2
modemdab/dabfft.cpp

@ -85,7 +85,7 @@ void DABFFT::transform(const std::complex<float> *in, std::complex<float> *out) @@ -85,7 +85,7 @@ void DABFFT::transform(const std::complex<float> *in, std::complex<float> *out)
// Through the plan's aligned buffers, so any input and output can be used
std::memcpy(m_implementation->in, in, sizeof(fftwf_complex) * m_size);
fftwf_execute(m_implementation->plan);
std::memcpy(out, m_implementation->out, sizeof(fftwf_complex) * m_size);
std::memcpy(static_cast<void*>(out), m_implementation->out, sizeof(fftwf_complex) * m_size);
}
const char *DABFFT::backend()

4
modemdab/dabmsc.cpp

@ -30,8 +30,8 @@ DABSubchannelDecoder::DABSubchannelDecoder() : @@ -30,8 +30,8 @@ DABSubchannelDecoder::DABSubchannelDecoder() :
m_filled(0),
m_lastDamaged(false),
m_bitErrors(0),
m_countErrors(true),
m_comparedBits(0)
m_comparedBits(0),
m_countErrors(true)
{
reset();
}

6
modemdab/dabofdm.cpp

@ -101,9 +101,9 @@ DABFrontEnd::DABFrontEnd() : @@ -101,9 +101,9 @@ DABFrontEnd::DABFrontEnd() :
m_exportCarriers(false),
m_filterFFT(FilterFFTSize, false),
m_filterIFFT(FilterFFTSize, true),
m_haveCarrierPower(false),
m_haveCarrierNoise(false),
m_noiseFrames(0),
m_haveCarrierPower(false)
m_noiseFrames(0)
{
// Kaiser windowed sinc (beta 7.86 for about 80 dB of stop band attenuation)
std::vector<std::complex<float>> taps(FilterFFTSize, 0.0f);
@ -736,7 +736,7 @@ bool DABFrontEnd::processFrame() @@ -736,7 +736,7 @@ bool DABFrontEnd::processFrame()
for (int n = ModeI::NullSize; n < ModeI::FrameSize; n += 7) {
symbolPower += std::norm(m_mixed[Margin + shift + n]);
}
symbolPower /= (ModeI::FrameSize - ModeI::NullSize) / 7;
symbolPower /= ((ModeI::FrameSize - ModeI::NullSize + 6) / 7.0);
m_frame.startSample = frameStart + shift;
m_frame.frequencyOffsetHz = static_cast<float>(m_frequency);

2
modemdab/dabtables.cpp

@ -446,7 +446,7 @@ uint16_t DABTables::crc16(const uint8_t *data, std::size_t length) @@ -446,7 +446,7 @@ uint16_t DABTables::crc16(const uint8_t *data, std::size_t length)
crc = (crc & 0x8000) ? static_cast<uint16_t>((crc << 1) ^ 0x1021) : static_cast<uint16_t>(crc << 1);
}
}
return static_cast<uint16_t>(~crc);
return static_cast<uint16_t>(~crc ^ 0xffff);
}
bool DABTables::crc16Check(const uint8_t *data, std::size_t lengthWithCRC)

12
modemdr/journaline.cpp

@ -178,9 +178,15 @@ bool JournalineDecoder::push(const std::vector<std::uint8_t>& dataUnit) @@ -178,9 +178,15 @@ bool JournalineDecoder::push(const std::vector<std::uint8_t>& dataUnit)
if (crcPresent)
{
if (end < 4U)
{
++m_invalidDataUnits;
return false;
}
const std::uint16_t crc = static_cast<std::uint16_t>((dataUnit[end - 2U] << 8) | dataUnit[end - 1U]);
if (end < 4U || CRC::crc16(dataUnit.data(), end - 2U) != crc)
if (CRC::crc16(dataUnit.data(), end - 2U) != crc)
{
++m_invalidDataUnits;
return false;
@ -231,6 +237,10 @@ bool JournalineDecoder::push(const std::vector<std::uint8_t>& dataUnit) @@ -231,6 +237,10 @@ bool JournalineDecoder::push(const std::vector<std::uint8_t>& dataUnit)
}
}
if (oldest == m_received.end()) {
break;
}
m_objects.erase(oldest->first);
m_received.erase(oldest);
}

3
modemdrm/drmchannelestimator.cpp

@ -1578,6 +1578,9 @@ bool ChannelEstimationContext::estimateFrameWiener( @@ -1578,6 +1578,9 @@ bool ChannelEstimationContext::estimateFrameWiener(
const auto& fftFrames = *m_frames;
const ModeParameters& parameters = Parameters::forMode(mode);
const SpectrumParameters* spectrum = Parameters::forSpectrum(mode, occupancy);
if (!spectrum) {
return false;
}
const int carrierCount = spectrum->maximumCarrier - spectrum->minimumCarrier + 1;
const float temporalCorrelation = m_temporalCorrelation;
const TemporalWeights weights = temporalWeights(temporalCorrelation);

6
modemdvb/dvbs2receiver.cpp

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include <chrono>
#include <cmath>
#include <cstring>
#include <QDebug>
#include "util/profiler.h"
#include "dvbs2receiver.h"
@ -892,6 +893,10 @@ void Receiver::deframe(FrameSlot& slot) @@ -892,6 +893,10 @@ void Receiver::deframe(FrameSlot& slot)
{
const XFECFrame& frame = slot.m_frame;
const int kbch = frame.m_vlsnr >= 0 ? vlsnrKbch(frame.m_vlsnr) : dvbt2::kbch(frame.m_fecType, frame.m_rate, CodeFamily::S2);
if (kbch <= 0) {
qWarning() << "Receiver::deframe: Invalid BCH information length" << kbch;
return;
}
const bool bad = slot.m_corrected < 0;
dvbt2::scrambleBytes(slot.m_packed.data(), kbch / 8);
dvbt2::BBFrameDecoder::Header header;
@ -943,6 +948,7 @@ void Receiver::deframe(FrameSlot& slot) @@ -943,6 +948,7 @@ void Receiver::deframe(FrameSlot& slot)
// Not from a frame of before a reset (still being decoded when it came): the front end's set for the
// signal since
std::lock_guard<std::mutex> lock(m_mutex);
if (slot.m_epoch == m_resetEpoch) {
m_matypeRollOff = header.rollOff() + (m_lowRollOffs ? 4 : 0);
}

20
modemdvb/dvbt2fec.cpp

@ -26,6 +26,8 @@ @@ -26,6 +26,8 @@
#include <stdexcept>
#include <string>
#include <QDebug>
#include "dvbt2fec.h"
#include "dvbt2ldpc.h"
@ -728,6 +730,19 @@ const int *CellMapper::demuxTable(CodeRate rate, Constellation constellation, FE @@ -728,6 +730,19 @@ const int *CellMapper::demuxTable(CodeRate rate, Constellation constellation, FE
void cellBitMap(FECType type, CodeRate rate, Constellation constellation, std::vector<int>& map)
{
switch (constellation)
{
case Constellation::QPSK:
case Constellation::QAM16:
case Constellation::QAM64:
case Constellation::QAM256:
break;
default:
qWarning() << "cellBitMap: Invalid constellation" << static_cast<int>(constellation);
map.clear();
return;
}
const int n = nldpc(type);
const int k = kldpc(type, rate);
const int qldpc = (n - k) / 360;
@ -936,7 +951,7 @@ CellInterleaver::CellInterleaver(int ncells) : @@ -936,7 +951,7 @@ CellInterleaver::CellInterleaver(int ncells) :
r = (r >> 1) | (bit << (m_nd - 2));
}
int value = (int) (((i & 1) << (m_nd - 1)) | r);
int value = m_nd > 0 ? (int) (((i & 1) << (m_nd - 1)) | r) : (int) r;
if (value < ncells) {
m_l0[q++] = value;
@ -1030,7 +1045,8 @@ int L1Codec::postTableIndex(L1Constellation constellation) @@ -1030,7 +1045,8 @@ int L1Codec::postTableIndex(L1Constellation constellation)
L1Codec::L1Codec() :
m_preLDPC(FECType::Short, CodeRate::R1_4),
m_postLDPC(FECType::Short, CodeRate::R1_2),
m_bch(FECType::Short, 12)
m_bch(FECType::Short, 12),
m_postBlock()
{
layout(m_preKsig, m_preKbch, m_preKldpc, 16200 - m_preKldpc, m_preNpunc, m_preGroups, m_preParity, m_preBlock);
}

5
modemdvb/dvbt2ofdm.cpp

@ -108,7 +108,10 @@ OFDMDemod::OFDMDemod(int bandwidthHz, FFTFactory *fftFactory) : @@ -108,7 +108,10 @@ OFDMDemod::OFDMDemod(int bandwidthHz, FFTFactory *fftFactory) :
m_sampleRate(sampleRate(bandwidthHz)),
m_p2Tables(nullptr),
m_tables(nullptr),
m_interpolationSpacing(0)
m_interpolationSpacing(0),
m_gridSpacing(0),
m_gridOffset(0),
m_gridAmplitude(0.0f)
{
m_fft.m_factory = fftFactory;
m_p1Fft.m_factory = fftFactory;

14
modemdvb/dvbt2receiver.cpp

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include <chrono>
#include <cmath>
#include <cstring>
#include <QDebug>
#include "util/profiler.h"
@ -1182,6 +1183,19 @@ void Receiver::analyseBlock(FEC& fec, int block, const uint8_t *packed) @@ -1182,6 +1183,19 @@ void Receiver::analyseBlock(FEC& fec, int block, const uint8_t *packed)
return;
}
switch (fec.m_constellation)
{
case Constellation::QPSK:
case Constellation::QAM16:
case Constellation::QAM64:
case Constellation::QAM256:
break;
default:
qWarning() << "Receiver::analyseBlock: Invalid constellation"
<< static_cast<int>(fec.m_constellation);
return;
}
LDPC& ldpc = *fec.m_ldpc;
const int k = ldpc.k();
const int eta = bitsPerCell(fec.m_constellation);

13
modemdvb/dvbtinner.cpp

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
#include <algorithm>
#include <cmath>
#include <QDebug>
#include "dvbtinner.h"
@ -88,6 +89,18 @@ float InnerDecoder::normalisation(Constellation constellation, Hierarchy hierarc @@ -88,6 +89,18 @@ float InnerDecoder::normalisation(Constellation constellation, Hierarchy hierarc
void InnerDecoder::configure(Mode mode, Constellation constellation, CodeRate codeRate, Hierarchy hierarchy, bool lowPriority)
{
switch (constellation)
{
case Constellation::QPSK:
case Constellation::QAM16:
case Constellation::QAM64:
break;
default:
qWarning() << "InnerDecoder::configure: Invalid constellation"
<< static_cast<int>(constellation);
return;
}
const Tables& tables = Tables::get(mode);
m_mode = mode;

1
modemdvb/dvbtmodulator.cpp

@ -39,6 +39,7 @@ Modulator::Modulator(Mode mode, Constellation constellation, CodeRate codeRate, @@ -39,6 +39,7 @@ Modulator::Modulator(Mode mode, Constellation constellation, CodeRate codeRate,
m_tables(Tables::get(mode)),
m_hierarchy(constellation == Constellation::QPSK ? Hierarchy::None : hierarchy),
m_lpCodeRate(lpCodeRate),
m_tpsBits{},
m_symbolIndex(0),
m_frameNumber(0)
{

9
modemdvb/dvbtofdm.cpp

@ -232,7 +232,14 @@ OFDMDemod::OFDMDemod(int bandwidthHz, FFTFactory *fftFactory) : @@ -232,7 +232,14 @@ OFDMDemod::OFDMDemod(int bandwidthHz, FFTFactory *fftFactory) :
m_guardSize(0),
m_symbolSize(0),
m_kMax(0),
m_backoff(0)
m_backoff(0),
m_ring{},
m_smoothingCutoff(0.0),
m_noiseConstellation(Constellation::QPSK),
m_lastSPPhase(0),
m_spPhaseRun(0),
m_tpsSync(0),
m_tpsBits{}
{
m_fft.m_factory = fftFactory;
m_cirFft.m_factory = fftFactory;

1
modemdvb/dvbtouter.cpp

@ -118,6 +118,7 @@ std::vector<uint8_t> OuterDecoder::makePRBS() @@ -118,6 +118,7 @@ std::vector<uint8_t> OuterDecoder::makePRBS()
}
OuterDecoder::OuterDecoder() :
m_packet{},
m_prbs(makePRBS())
{
for (int j = 0; j < m_interleaverI; j++) {

13
modemdvb/dvbtreceiver.cpp

@ -103,6 +103,8 @@ void Receiver::reset() @@ -103,6 +103,8 @@ void Receiver::reset()
m_ofdm.reset();
m_clockUpdateSymbols = 0;
std::vector<double> notches;
double inputRate;
{
std::lock_guard<std::mutex> lock(m_ofdmMutex);
m_ofdmStatus = m_ofdm.getStatus();
@ -120,9 +122,11 @@ void Receiver::reset() @@ -120,9 +122,11 @@ void Receiver::reset()
}
m_notchesQueued = m_notchFrequencies;
notches = m_notchesQueued;
inputRate = m_inputRate;
}
m_ofdm.setNotches(m_notchesQueued, m_inputRate); // The demodulator thread isn't running
m_ofdm.setNotches(notches, inputRate); // The demodulator thread isn't running
if (m_threaded)
{
@ -334,7 +338,12 @@ void Receiver::correctClock() @@ -334,7 +338,12 @@ void Receiver::correctClock()
m_resampling = true;
m_resampler.setRatioCorrection(1.0);
m_resampler.configure(m_inputRate, m_outputRate, 0.4165 * m_outputRate);
double inputRate;
{
std::lock_guard<std::mutex> lock(m_ofdmMutex);
inputRate = m_inputRate;
}
m_resampler.configure(inputRate, m_outputRate, 0.4165 * m_outputRate);
m_resampler.prime(m_lastInput);
setRatioCorrection(1.0 - ppm * 1e-6); // The measurement is accurate, so start with all of it
return;

1
modemdvb/ldpcpool.cpp

@ -156,6 +156,7 @@ void LDPCPool::run(Job& job, Context& context) @@ -156,6 +156,7 @@ void LDPCPool::run(Job& job, Context& context)
}
}
// Caller must hold m_mutex.
void LDPCPool::cancel(Job& job)
{
job.m_done += job.m_batches - job.m_next;

2
modemm17/ax25_frame.h

@ -256,7 +256,9 @@ void write(std::ostream& os, const ax25_frame& frame) @@ -256,7 +256,9 @@ void write(std::ostream& os, const ax25_frame& frame)
if (frame.pid())
{
std::ios_base::fmtflags flags = os.flags();
os << "PID: " << std::setbase(16) << int(frame.pid()) << std::endl;
os.flags(flags);
}
os << "Info: " << std::endl << frame.info() << std::endl;
}

24
plugins/channelrx/CMakeLists.txt

@ -1,5 +1,11 @@ @@ -1,5 +1,11 @@
project(demod)
if (ENABLE_CHANNELRX_DEMODACARS AND LIBACARS_FOUND)
add_subdirectory(demodacars)
else()
message(STATUS "Not building demodacars (ENABLE_CHANNELRX_DEMODACARS=${ENABLE_CHANNELRX_DEMODACARS} LIBACARS_FOUND=${LIBACARS_FOUND})")
endif()
if (ENABLE_CHANNELRX_DEMODINMARSAT AND INMARSATC_FOUND)
add_subdirectory(demodinmarsat)
else()
@ -18,7 +24,17 @@ if (ENABLE_CHANNELRX_FREQSCANNER) @@ -18,7 +24,17 @@ if (ENABLE_CHANNELRX_FREQSCANNER)
add_subdirectory(freqscanner)
endif()
if (ENABLE_CHANNELRX_DEMODADSB AND Qt${QT_DEFAULT_MAJOR_VERSION}Quick_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}QuickWidgets_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}Positioning_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}TextToSpeech_FOUND)
if (SERVER_MODE)
set(DEMODADSB_GUI_DEPS_FOUND TRUE)
else()
if (Qt${QT_DEFAULT_MAJOR_VERSION}Quick_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}QuickWidgets_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}TextToSpeech_FOUND)
set(DEMODADSB_GUI_DEPS_FOUND TRUE)
else()
set(DEMODADSB_GUI_DEPS_FOUND FALSE)
endif()
endif()
if (ENABLE_CHANNELRX_DEMODADSB AND DEMODADSB_GUI_DEPS_FOUND AND Qt${QT_DEFAULT_MAJOR_VERSION}Positioning_FOUND)
add_subdirectory(demodadsb)
# add_subdirectory(demodvormc)
else()
@ -307,6 +323,12 @@ else() @@ -307,6 +323,12 @@ else()
message(STATUS "Not building demodselcal (ENABLE_CHANNELRX_DEMODSELCAL=${ENABLE_CHANNELRX_DEMODSELCAL})")
endif()
if(ENABLE_CHANNELRX_DEMODCHIRPMODEM)
add_subdirectory(demodchirpmodem)
else()
message(STATUS "Not building demodchirpmodem (ENABLE_CHANNELRX_DEMODCHIRPMODEM=${ENABLE_CHANNELRX_DEMODCHIRPMODEM})")
endif()
if (ENABLE_CHANNELRX_DEMOD802.15.4)
add_subdirectory(demod802.15.4)
else()

2
plugins/channelrx/demod802.15.4/ieee_802_15_4_demodplugin.cpp

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
const PluginDescriptor IEEE_802_15_4_DemodPlugin::m_pluginDescriptor = {
IEEE_802_15_4_Demod::m_channelId,
QStringLiteral("802.15.4 Demodulator"),
QStringLiteral("8.0.0"),
QStringLiteral("8.1.0"),
QStringLiteral("(c) Jon Beniston, M7RCE"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,

22
plugins/channelrx/demod802.15.4/ieee_802_15_4_demodreceiver.cpp

@ -37,6 +37,28 @@ IEEE_802_15_4_DemodReceiver::IEEE_802_15_4_DemodReceiver() : @@ -37,6 +37,28 @@ IEEE_802_15_4_DemodReceiver::IEEE_802_15_4_DemodReceiver() :
m_nonCoherentLane(true),
m_mask(0),
m_n(0),
m_waitMax(0.0f),
m_waitMaxN(0),
m_omega(0.0),
m_ncoRef(0),
m_dNext(0),
m_yNext(0),
m_tau(0.0),
m_phi(0.0),
m_dphi(0.0),
m_phaseInit(false),
m_frameStart(0),
m_powerSum(0.0),
m_powerCount(0),
m_qSum(0.0),
m_qCount(0),
m_ampSum(0.0),
m_ampSumSq(0.0),
m_ampCount(0),
m_acquisitionN(0),
m_detectorCleared(false),
m_framers{},
m_prevECoh(0),
m_crcScopeCount(0)
{
m_stats = Statistics{0, 0, 0, 0, 0, 0};

124
plugins/channelrx/demodacars/CMakeLists.txt

@ -0,0 +1,124 @@ @@ -0,0 +1,124 @@
project(demodacars)
set(demodacars_SOURCES
acarsdemod.cpp
acarsdemodsettings.cpp
acarsdemodbaseband.cpp
acarsdemodsink.cpp
acarsdemodplugin.cpp
acarsdemodwebapiadapter.cpp
acarsdemodworker.cpp
acarsdemoddata.qrc
)
set(demodacars_HEADERS
acarsdemod.h
acarsdemodsettings.h
acarsdemodbaseband.h
acarsdemodsink.h
acarsdemodplugin.h
acarsdemodwebapiadapter.h
acarsdemodworker.h
acarsoqpsk.h
acarsvdl2.h
acarshfdl.h
acarsaero.h
acarsiridium.h
acarsiridiumframe.h
acarsiridiumfft.h
acarsiridiumchannelizer.h
acarsiridiumscanner.h
vdl2atn.h
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${LIBACARS_INCLUDE_DIR}
)
# The ATN decoder for VDL-2 information frames: X.25/CLNP/COTP in vdl2atn.cpp and the
# ICAO ASN.1 applications (CM, CPDLC, ADS-C v2) vendored from dumpvdl2 (GPL-3.0) in
# atn/. Built as a static library so the offline test harness in test/ can link the
# same decoder. Used by the worker, so built in both GUI and server modes.
if(NOT TARGET demodacarsatn)
file(GLOB demodacars_ATN_ASN1_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/atn/asn1/*.c)
add_library(demodacarsatn STATIC
vdl2atn.cpp
vdl2atn.h
atn/icao.c
atn/xid.c
atn/tlv.c
atn/asn1-util.c
atn/asn1-format-icao-text.c
atn/asn1-format-icao-json.c
atn/dumpvdl2shim.c
${demodacars_ATN_ASN1_SOURCES}
)
target_include_directories(demodacarsatn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/atn ${LIBACARS_INCLUDE_DIR})
target_link_libraries(demodacarsatn PRIVATE Qt::Core ${LIBACARS_LIBRARIES})
if(DEFINED LIBACARS_DEPENDS)
add_dependencies(demodacarsatn ${LIBACARS_DEPENDS})
endif()
# The vendored dumpvdl2 sources use C11 designated initializers
set_property(TARGET demodacarsatn PROPERTY C_STANDARD 11)
set_property(TARGET demodacarsatn PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
if(NOT SERVER_MODE)
set(demodacars_SOURCES
${demodacars_SOURCES}
acarsdemodgui.cpp
acarsmessagemodel.cpp
acarsdemodgui.ui
acarsdemodicons.qrc
)
set(demodacars_HEADERS
${demodacars_HEADERS}
acarsdemodgui.h
acarsmessagemodel.h
)
set(TARGET_NAME demodacars)
set(TARGET_LIB "Qt::Widgets" Qt::Quick Qt::QuickWidgets Qt::Positioning Qt::Charts)
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()
set(TARGET_NAME demodacarssrv)
set(TARGET_LIB "")
set(TARGET_LIB_GUI "")
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()
if(NOT Qt6_FOUND)
add_library(${TARGET_NAME} SHARED ${demodacars_SOURCES})
else()
qt_add_plugin(${TARGET_NAME} CLASS_NAME AcarsDemodPlugin)
target_sources(${TARGET_NAME} PRIVATE ${demodacars_SOURCES})
endif()
if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY STATIC_PLUGINS_PROPERTY ${TARGET_NAME})
endif()
if(DEFINED LIBACARS_DEPENDS)
add_dependencies(${TARGET_NAME} ${LIBACARS_DEPENDS})
endif()
target_link_libraries(${TARGET_NAME}
Qt::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
${LIBACARS_LIBRARIES}
)
target_link_libraries(${TARGET_NAME} demodacarsatn)
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
# Install debug symbols
if (WIN32)
install(FILES $<TARGET_PROPERTY:${TARGET_NAME},RUNTIME_OUTPUT_DIRECTORY>/${TARGET_NAME}stripped.pdb CONFIGURATIONS Release DESTINATION ${INSTALL_FOLDER} RENAME ${TARGET_NAME}.pdb )
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} )
endif()

3426
plugins/channelrx/demodacars/acarsaero.h

File diff suppressed because it is too large Load Diff

769
plugins/channelrx/demodacars/acarsdemod.cpp

@ -0,0 +1,769 @@ @@ -0,0 +1,769 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015-2018 Edouard Griffiths, F4EXB. //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "acarsdemod.h"
#include <QTime>
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QBuffer>
#include <QThread>
#include <stdio.h>
#include <complex.h>
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
#include "SWGACARSDemodSettings.h"
#include "SWGACARSDemodReport.h"
//#include "SWGACARSDemodSettings.h"
#include "SWGChannelReport.h"
#include "SWGMapItem.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
#include "feature/feature.h"
#include "util/db.h"
#include "maincore.h"
#include "acarsdemodworker.h"
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgConfigureAcarsDemod, Message)
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgVdl2Frame, Message)
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgAcarsPacket, MainCore::MsgPacket)
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgHfdlFrame, Message)
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgAeroFrame, Message)
MESSAGE_CLASS_DEFINITION(AcarsDemod::MsgProtocolChange, Message)
const char * const AcarsDemod::m_channelIdURI = "sdrangel.channel.acarsdemod";
const char * const AcarsDemod::m_channelId = "ACARSDemod";
AcarsDemod::AcarsDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_basebandSampleRate(0)
{
setObjectName(m_channelId);
m_basebandSink = new AcarsDemodBaseband(this);
m_basebandSink->setFifoLabel(QString("%1 [%2:%3]")
.arg(m_channelId)
.arg(m_deviceAPI->getDeviceSetIndex())
.arg(getIndexInDeviceSet())
);
m_basebandSink->setChannel(this);
m_basebandSink->moveToThread(&m_thread);
// Decoded frames are processed by the worker on its own thread, for the
// channel's lifetime, in both GUI and server builds
m_workerThread = new QThread();
m_worker = new AcarsDemodWorker(this);
m_worker->moveToThread(m_workerThread);
QObject::connect(m_workerThread, &QThread::started, m_worker, &AcarsDemodWorker::startWork);
QObject::connect(m_workerThread, &QThread::finished, m_worker, &QObject::deleteLater);
QObject::connect(m_workerThread, &QThread::finished, m_workerThread, &QThread::deleteLater);
m_workerThread->start();
// The sink sends its frames straight to the worker
m_basebandSink->setMessageQueueToChannel(m_worker->getInputMessageQueue());
applySettings(m_settings, true);
m_deviceAPI->addChannelSink(this);
m_deviceAPI->addChannelSinkAPI(this);
m_networkManager = new QNetworkAccessManager();
QObject::connect(
m_networkManager,
&QNetworkAccessManager::finished,
this,
&AcarsDemod::networkManagerFinished
);
}
AcarsDemod::~AcarsDemod()
{
qDebug("AcarsDemod::~AcarsDemod");
QObject::disconnect(
m_networkManager,
&QNetworkAccessManager::finished,
this,
&AcarsDemod::networkManagerFinished
);
delete m_networkManager;
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, true);
if (m_basebandSink->isRunning()) {
stop();
}
// The sink has stopped, so nothing new reaches the worker - but frames it already
// queued are still being processed, and those read the sink (getMagSq() for the feed
// level). So the worker thread must finish, which also deletes the worker, before the
// sink is deleted
m_workerThread->quit();
m_workerThread->wait();
m_worker = nullptr;
m_workerThread = nullptr;
delete m_basebandSink;
}
void AcarsDemod::setDeviceAPI(DeviceAPI *deviceAPI)
{
if (deviceAPI != m_deviceAPI)
{
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, false);
m_deviceAPI = deviceAPI;
m_deviceAPI->addChannelSink(this);
m_deviceAPI->addChannelSinkAPI(this);
}
}
uint32_t AcarsDemod::getNumberOfDeviceStreams() const
{
return m_deviceAPI->getNbSourceStreams();
}
void AcarsDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
{
(void) firstOfBurst;
m_basebandSink->feed(begin, end);
}
void AcarsDemod::start()
{
qDebug("AcarsDemod::start");
m_basebandSink->reset();
m_basebandSink->startWork();
m_thread.start();
DSPSignalNotification *dspMsg = new DSPSignalNotification(m_basebandSampleRate, m_centerFrequency);
m_basebandSink->getInputMessageQueue()->push(dspMsg);
AcarsDemodBaseband::MsgConfigureAcarsDemodBaseband *msg = AcarsDemodBaseband::MsgConfigureAcarsDemodBaseband::create(m_settings, true);
m_basebandSink->getInputMessageQueue()->push(msg);
}
void AcarsDemod::stop()
{
qDebug("AcarsDemod::stop");
m_basebandSink->stopWork();
m_thread.quit();
m_thread.wait();
}
bool AcarsDemod::handleMessage(const Message& cmd)
{
if (MsgConfigureAcarsDemod::match(cmd))
{
MsgConfigureAcarsDemod& cfg = (MsgConfigureAcarsDemod&) cmd;
qDebug() << "AcarsDemod::handleMessage: MsgConfigureAcarsDemod";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPSignalNotification::match(cmd))
{
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
m_basebandSampleRate = notif.getSampleRate();
m_centerFrequency = notif.getCenterFrequency();
// Forward to the sink
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
qDebug() << "AcarsDemod::handleMessage: DSPSignalNotification";
m_basebandSink->getInputMessageQueue()->push(rep);
// Forward to the worker, which needs the centre frequency for its outputs
if (m_worker) {
m_worker->getInputMessageQueue()->push(new DSPSignalNotification(notif));
}
// Forward to GUI if any
if (m_guiMessageQueue)
{
rep = new DSPSignalNotification(notif);
m_guiMessageQueue->push(rep);
}
return true;
}
else
{
return false;
}
}
void AcarsDemod::setCenterFrequency(qint64 frequency)
{
AcarsDemodSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency;
applySettings(settings, false);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureAcarsDemod *msgToGUI = MsgConfigureAcarsDemod::create(settings, false);
m_guiMessageQueue->push(msgToGUI);
}
}
void AcarsDemod::applySettings(const AcarsDemodSettings& settings, bool force)
{
qDebug() << "AcarsDemod::applySettings:"
<< " m_logEnabled: " << settings.m_logEnabled
<< " m_logFilename: " << settings.m_logFilename
<< " m_streamIndex: " << settings.m_streamIndex
<< " m_useReverseAPI: " << settings.m_useReverseAPI
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
<< " force: " << force;
QList<QString> reverseAPIKeys;
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
reverseAPIKeys.append("inputFrequencyOffset");
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
if ((settings.m_udpEnabled != m_settings.m_udpEnabled) || force) {
reverseAPIKeys.append("udpEnabled");
}
if ((settings.m_udpAddress != m_settings.m_udpAddress) || force) {
reverseAPIKeys.append("udpAddress");
}
if ((settings.m_udpPort != m_settings.m_udpPort) || force) {
reverseAPIKeys.append("udpPort");
}
if ((settings.m_logFilename != m_settings.m_logFilename) || force) {
reverseAPIKeys.append("logFilename");
}
if ((settings.m_logEnabled != m_settings.m_logEnabled) || force) {
reverseAPIKeys.append("logEnabled");
}
if ((settings.m_mode != m_settings.m_mode) || force) {
reverseAPIKeys.append("mode");
}
if ((settings.m_aeroChannel != m_settings.m_aeroChannel) || force) {
reverseAPIKeys.append("aeroChannel");
}
if ((settings.m_iridiumBandwidth != m_settings.m_iridiumBandwidth) || force) {
reverseAPIKeys.append("iridiumBandwidth");
}
if ((settings.m_correlationThreshold != m_settings.m_correlationThreshold) || force) {
reverseAPIKeys.append("correlationThreshold");
}
if ((settings.m_filter != m_settings.m_filter) || force) {
reverseAPIKeys.append("filter");
}
if ((settings.m_filterColumn != m_settings.m_filterColumn) || force) {
reverseAPIKeys.append("filterColumn");
}
if ((settings.m_hideNoInfo != m_settings.m_hideNoInfo) || force) {
reverseAPIKeys.append("hideNoInfo");
}
if ((settings.m_showDate != m_settings.m_showDate) || force) {
reverseAPIKeys.append("showDate");
}
if ((settings.m_displayPhotos != m_settings.m_displayPhotos) || force) {
reverseAPIKeys.append("displayPhotos");
}
if ((settings.m_displayChart != m_settings.m_displayChart) || force) {
reverseAPIKeys.append("displayChart");
}
if ((settings.m_scopeCh1 != m_settings.m_scopeCh1) || force) {
reverseAPIKeys.append("scopeCh1");
}
if ((settings.m_scopeCh2 != m_settings.m_scopeCh2) || force) {
reverseAPIKeys.append("scopeCh2");
}
if ((settings.m_rgbColor != m_settings.m_rgbColor) || force) {
reverseAPIKeys.append("rgbColor");
}
if ((settings.m_title != m_settings.m_title) || force) {
reverseAPIKeys.append("title");
}
if ((settings.m_workspaceIndex != m_settings.m_workspaceIndex) || force) {
reverseAPIKeys.append("workspaceIndex");
}
if (m_settings.m_streamIndex != settings.m_streamIndex)
{
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
{
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, m_settings.m_streamIndex);
m_deviceAPI->addChannelSink(this, settings.m_streamIndex);
m_deviceAPI->addChannelSinkAPI(this);
}
reverseAPIKeys.append("streamIndex");
}
AcarsDemodBaseband::MsgConfigureAcarsDemodBaseband *msg = AcarsDemodBaseband::MsgConfigureAcarsDemodBaseband::create(settings, force);
m_basebandSink->getInputMessageQueue()->push(msg);
if (settings.m_useReverseAPI)
{
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) ||
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
}
// The worker handles the outputs (UDP, log, pipes) and, in later phases,
// the higher layer decode
if (m_worker) {
m_worker->getInputMessageQueue()->push(AcarsDemodWorker::MsgConfigureWorker::create(settings, force));
}
m_settings = settings;
}
QByteArray AcarsDemod::serialize() const
{
return m_settings.serialize();
}
bool AcarsDemod::deserialize(const QByteArray& data)
{
if (m_settings.deserialize(data))
{
MsgConfigureAcarsDemod *msg = MsgConfigureAcarsDemod::create(m_settings, true);
m_inputMessageQueue.push(msg);
return true;
}
else
{
m_settings.resetToDefaults();
MsgConfigureAcarsDemod *msg = MsgConfigureAcarsDemod::create(m_settings, true);
m_inputMessageQueue.push(msg);
return false;
}
}
// NOTE: the API carries these settings in three directions - reading a PATCH,
// writing a GET, and sending an update to a reverse API - and each one now lists
// them out in full below. A setting added to AcarsDemodSettings has to be added to
// ALL THREE: webapiUpdateChannelSettings, webapiFormatChannelSettings and
// webapiFormatChannelSettings(keys, ...). Missing one leaves the setting silently
// unreadable, unreportable or unsynchronised rather than failing to build.
// The strings need their own handling: a generated setter takes ownership of what it is
// given, and the default constructor leaves every pointer null - so assigning in place
// without checking writes through nullptr
static void acarsApiSetString(SWGSDRangel::SWGACARSDemodSettings *swg, QString *held,
void (SWGSDRangel::SWGACARSDemodSettings::*setter)(QString *),
const QString& value)
{
if (held) {
*held = value;
} else {
(swg->*setter)(new QString(value));
}
}
int AcarsDemod::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAcarsDemodSettings(new SWGSDRangel::SWGACARSDemodSettings());
response.getAcarsDemodSettings()->init();
webapiFormatChannelSettings(response, m_settings);
return 200;
}
int AcarsDemod::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
AcarsDemodSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
MsgConfigureAcarsDemod *msg = MsgConfigureAcarsDemod::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureAcarsDemod *msgToGUI = MsgConfigureAcarsDemod::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatChannelSettings(response, settings);
return 200;
}
int AcarsDemod::webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAcarsDemodReport(new SWGSDRangel::SWGACARSDemodReport());
response.getAcarsDemodReport()->init();
webapiFormatChannelReport(response);
return 200;
}
void AcarsDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
SWGSDRangel::SWGACARSDemodReport *swg = response.getAcarsDemodReport();
const double magsqAvg = getMagSq();
swg->setChannelPowerDb(magsqAvg > 0.0 ? 10.0 * log10(magsqAvg) : -200.0);
// Depends on the protocol, and in Aero on the rate tuned - see channelSampleRate()
swg->setChannelSampleRate(AcarsDemodSink::channelSampleRate(m_settings));
// Both are only meaningful in Aero mode, which is the only one with a continuous
// carrier to average over. The other protocols leave them at zero.
double evm = 0.0;
double suRate = 0.0;
getAeroQuality(evm, suRate);
swg->setAeroEvm((float) evm);
swg->setAeroSignalUnitRate((float) suRate);
}
void AcarsDemod::webapiUpdateChannelSettings(
AcarsDemodSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response)
{
SWGSDRangel::SWGACARSDemodSettings *swg = response.getAcarsDemodSettings();
if (!swg) {
return;
}
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = (qint32) swg->getInputFrequencyOffset();
}
// The ranges are the ones AcarsDemodSettings::deserialize() enforces, as the values go
// to the same places - mode and aeroChannel index tables, rfBandwidth becomes a filter
// cutoff. Deserialize falls back to the default; here a value out of range is ignored
// and the current setting kept
if (channelSettingsKeys.contains("mode"))
{
const int mode = swg->getMode();
if ((mode >= 0) && (mode < (int) AcarsDemodSettings::ModeCount)) {
settings.m_mode = mode;
}
}
if (channelSettingsKeys.contains("aeroChannel"))
{
const int aeroChannel = swg->getAeroChannel();
if ((aeroChannel >= 0) && (aeroChannel < AcarsAeroReceiver::SubmodeCount)) {
settings.m_aeroChannel = aeroChannel;
}
}
if (channelSettingsKeys.contains("iridiumBandwidth"))
{
const int iridiumBandwidth = swg->getIridiumBandwidth();
if ((iridiumBandwidth >= 0) && (iridiumBandwidth < AcarsDemodSettings::IridiumScanWidths)) {
settings.m_iridiumBandwidth = iridiumBandwidth;
}
}
if (channelSettingsKeys.contains("rfBandwidth"))
{
const Real rfBandwidth = (Real) swg->getRfBandwidth();
if ((rfBandwidth >= 1000.0f) && (rfBandwidth <= 40000.0f)) {
settings.m_rfBandwidth = rfBandwidth;
}
}
if (channelSettingsKeys.contains("correlationThreshold"))
{
const Real correlationThreshold = (Real) swg->getCorrelationThreshold();
if ((correlationThreshold >= 0.0f) && (correlationThreshold <= 1.0f)) {
settings.m_correlationThreshold = correlationThreshold;
}
}
if (channelSettingsKeys.contains("filterColumn"))
{
const int filterColumn = swg->getFilterColumn();
if ((filterColumn >= 0) && (filterColumn <= 3)) {
settings.m_filterColumn = filterColumn;
}
}
if (channelSettingsKeys.contains("hideNoInfo")) {
settings.m_hideNoInfo = (bool) swg->getHideNoInfo();
}
if (channelSettingsKeys.contains("showDate")) {
settings.m_showDate = (bool) swg->getShowDate();
}
if (channelSettingsKeys.contains("displayPhotos")) {
settings.m_displayPhotos = (bool) swg->getDisplayPhotos();
}
if (channelSettingsKeys.contains("displayChart")) {
settings.m_displayChart = (bool) swg->getDisplayChart();
}
if (channelSettingsKeys.contains("udpEnabled")) {
settings.m_udpEnabled = (bool) swg->getUdpEnabled();
}
if (channelSettingsKeys.contains("udpPort"))
{
const int udpPort = swg->getUdpPort();
if ((udpPort > 1023) && (udpPort < 65535)) {
settings.m_udpPort = (uint16_t) udpPort;
}
}
if (channelSettingsKeys.contains("logEnabled")) {
settings.m_logEnabled = (bool) swg->getLogEnabled();
}
if (channelSettingsKeys.contains("scopeCh1")) {
settings.m_scopeCh1 = (int) swg->getScopeCh1();
}
if (channelSettingsKeys.contains("scopeCh2")) {
settings.m_scopeCh2 = (int) swg->getScopeCh2();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = (quint32) swg->getRgbColor();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = (int) swg->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = (bool) swg->getUseReverseApi();
}
if (channelSettingsKeys.contains("reverseAPIPort"))
{
const int reverseAPIPort = swg->getReverseApiPort();
if ((reverseAPIPort > 1023) && (reverseAPIPort < 65535)) {
settings.m_reverseAPIPort = (uint16_t) reverseAPIPort;
}
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = (uint16_t) qBound(0, swg->getReverseApiDeviceIndex(), 99);
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = (uint16_t) qBound(0, swg->getReverseApiChannelIndex(), 99);
}
if (channelSettingsKeys.contains("workspaceIndex")) {
settings.m_workspaceIndex = (int) swg->getWorkspaceIndex();
}
if (channelSettingsKeys.contains("filter") && swg->getFilter()) {
settings.m_filter = *swg->getFilter();
}
if (channelSettingsKeys.contains("udpAddress") && swg->getUdpAddress()) {
settings.m_udpAddress = *swg->getUdpAddress();
}
if (channelSettingsKeys.contains("logFilename") && swg->getLogFilename()) {
settings.m_logFilename = *swg->getLogFilename();
}
if (channelSettingsKeys.contains("title") && swg->getTitle()) {
settings.m_title = *swg->getTitle();
}
if (channelSettingsKeys.contains("reverseAPIAddress") && swg->getReverseApiAddress()) {
settings.m_reverseAPIAddress = *swg->getReverseApiAddress();
}
}
void AcarsDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const AcarsDemodSettings& settings)
{
SWGSDRangel::SWGACARSDemodSettings *swg = response.getAcarsDemodSettings();
swg->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
swg->setMode(settings.m_mode);
swg->setAeroChannel(settings.m_aeroChannel);
swg->setIridiumBandwidth(settings.m_iridiumBandwidth);
swg->setRfBandwidth(settings.m_rfBandwidth);
swg->setCorrelationThreshold(settings.m_correlationThreshold);
swg->setFilterColumn(settings.m_filterColumn);
swg->setHideNoInfo(settings.m_hideNoInfo);
swg->setShowDate(settings.m_showDate);
swg->setDisplayPhotos(settings.m_displayPhotos);
swg->setDisplayChart(settings.m_displayChart);
swg->setUdpEnabled(settings.m_udpEnabled);
swg->setUdpPort(settings.m_udpPort);
swg->setLogEnabled(settings.m_logEnabled);
swg->setScopeCh1(settings.m_scopeCh1);
swg->setScopeCh2(settings.m_scopeCh2);
swg->setRgbColor(settings.m_rgbColor);
swg->setStreamIndex(settings.m_streamIndex);
swg->setUseReverseApi(settings.m_useReverseAPI);
swg->setReverseApiPort(settings.m_reverseAPIPort);
swg->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
swg->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
swg->setWorkspaceIndex(settings.m_workspaceIndex);
acarsApiSetString(swg, swg->getFilter(), &SWGSDRangel::SWGACARSDemodSettings::setFilter,
settings.m_filter);
acarsApiSetString(swg, swg->getUdpAddress(), &SWGSDRangel::SWGACARSDemodSettings::setUdpAddress,
settings.m_udpAddress);
acarsApiSetString(swg, swg->getLogFilename(), &SWGSDRangel::SWGACARSDemodSettings::setLogFilename,
settings.m_logFilename);
acarsApiSetString(swg, swg->getTitle(), &SWGSDRangel::SWGACARSDemodSettings::setTitle,
settings.m_title);
acarsApiSetString(swg, swg->getReverseApiAddress(), &SWGSDRangel::SWGACARSDemodSettings::setReverseApiAddress,
settings.m_reverseAPIAddress);
}
void AcarsDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const AcarsDemodSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
.arg(settings.m_reverseAPIAddress)
.arg(settings.m_reverseAPIPort)
.arg(settings.m_reverseAPIDeviceIndex)
.arg(settings.m_reverseAPIChannelIndex);
m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgChannelSettings->asJson().toUtf8());
buffer->seek(0);
// Always use PATCH to avoid passing reverse API settings
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
buffer->setParent(reply);
delete swgChannelSettings;
}
// Only what changed, unless forced - and never the reverse API settings themselves,
// which describe this end of the link rather than the channel
void AcarsDemod::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const AcarsDemodSettings& settings,
bool force
)
{
swgChannelSettings->setDirection(0); // Single sink (Rx)
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString(m_channelId));
swgChannelSettings->setAcarsDemodSettings(new SWGSDRangel::SWGACARSDemodSettings());
SWGSDRangel::SWGACARSDemodSettings *swg = swgChannelSettings->getAcarsDemodSettings();
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
swg->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
}
if (channelSettingsKeys.contains("mode") || force) {
swg->setMode(settings.m_mode);
}
if (channelSettingsKeys.contains("aeroChannel") || force) {
swg->setAeroChannel(settings.m_aeroChannel);
}
if (channelSettingsKeys.contains("iridiumBandwidth") || force) {
swg->setIridiumBandwidth(settings.m_iridiumBandwidth);
}
if (channelSettingsKeys.contains("rfBandwidth") || force) {
swg->setRfBandwidth(settings.m_rfBandwidth);
}
if (channelSettingsKeys.contains("correlationThreshold") || force) {
swg->setCorrelationThreshold(settings.m_correlationThreshold);
}
if (channelSettingsKeys.contains("filterColumn") || force) {
swg->setFilterColumn(settings.m_filterColumn);
}
if (channelSettingsKeys.contains("hideNoInfo") || force) {
swg->setHideNoInfo(settings.m_hideNoInfo);
}
if (channelSettingsKeys.contains("showDate") || force) {
swg->setShowDate(settings.m_showDate);
}
if (channelSettingsKeys.contains("displayPhotos") || force) {
swg->setDisplayPhotos(settings.m_displayPhotos);
}
if (channelSettingsKeys.contains("displayChart") || force) {
swg->setDisplayChart(settings.m_displayChart);
}
if (channelSettingsKeys.contains("udpEnabled") || force) {
swg->setUdpEnabled(settings.m_udpEnabled);
}
if (channelSettingsKeys.contains("udpPort") || force) {
swg->setUdpPort(settings.m_udpPort);
}
if (channelSettingsKeys.contains("logEnabled") || force) {
swg->setLogEnabled(settings.m_logEnabled);
}
if (channelSettingsKeys.contains("scopeCh1") || force) {
swg->setScopeCh1(settings.m_scopeCh1);
}
if (channelSettingsKeys.contains("scopeCh2") || force) {
swg->setScopeCh2(settings.m_scopeCh2);
}
if (channelSettingsKeys.contains("rgbColor") || force) {
swg->setRgbColor(settings.m_rgbColor);
}
if (channelSettingsKeys.contains("streamIndex") || force) {
swg->setStreamIndex(settings.m_streamIndex);
}
if (channelSettingsKeys.contains("useReverseAPI") || force) {
swg->setUseReverseApi(settings.m_useReverseAPI);
}
if (channelSettingsKeys.contains("reverseAPIPort") || force) {
swg->setReverseApiPort(settings.m_reverseAPIPort);
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex") || force) {
swg->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex") || force) {
swg->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
}
if (channelSettingsKeys.contains("workspaceIndex") || force) {
swg->setWorkspaceIndex(settings.m_workspaceIndex);
}
if (channelSettingsKeys.contains("filter") || force) {
swg->setFilter(new QString(settings.m_filter));
}
if (channelSettingsKeys.contains("udpAddress") || force) {
swg->setUdpAddress(new QString(settings.m_udpAddress));
}
if (channelSettingsKeys.contains("logFilename") || force) {
swg->setLogFilename(new QString(settings.m_logFilename));
}
if (channelSettingsKeys.contains("title") || force) {
swg->setTitle(new QString(settings.m_title));
}
if (channelSettingsKeys.contains("reverseAPIAddress") || force) {
swg->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
}
void AcarsDemod::networkManagerFinished(QNetworkReply *reply)
{
QNetworkReply::NetworkError replyError = reply->error();
if (replyError)
{
qWarning() << "AcarsDemod::networkManagerFinished:"
<< " error(" << (int) replyError
<< "): " << replyError
<< ": " << reply->errorString();
}
else
{
QString answer = reply->readAll();
answer.chop(1); // remove last \n
qDebug("AcarsDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
}
reply->deleteLater();
}

322
plugins/channelrx/demodacars/acarsdemod.h

@ -0,0 +1,322 @@ @@ -0,0 +1,322 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015-2018 Edouard Griffiths, F4EXB. //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMOD_H
#define INCLUDE_ACARSDEMOD_H
#include <vector>
#include <QNetworkRequest>
#include <QUdpSocket>
#include <QThread>
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include "dsp/basebandsamplesink.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "maincore.h" // MsgAcarsPacket subclasses MainCore::MsgPacket
#include "acarsdemodbaseband.h"
#include "acarsdemodsettings.h"
#include "acarsvdl2.h"
#include "acarshfdl.h"
#include "acarsaero.h"
class QNetworkAccessManager;
class QNetworkReply;
class QThread;
class DeviceAPI;
class AcarsDemodWorker;
class AcarsDemod : public BasebandSampleSink, public ChannelAPI {
public:
class MsgConfigureAcarsDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsDemodSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureAcarsDemod* create(const AcarsDemodSettings& settings, bool force)
{
return new MsgConfigureAcarsDemod(settings, force);
}
private:
AcarsDemodSettings m_settings;
bool m_force;
MsgConfigureAcarsDemod(const AcarsDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
// A demodulated HFDL LPDU or SPDU that does not carry an ACARS message (logons,
// squitters). As with VDL-2, ACARS frames go out as MainCore::MsgPacket instead.
class MsgHfdlFrame : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsHfdlReceiver::Frame& getFrame() const { return m_frame; }
QDateTime getDateTime() const { return m_dateTime; }
static MsgHfdlFrame* create(const AcarsHfdlReceiver::Frame& frame)
{
return new MsgHfdlFrame(frame);
}
private:
AcarsHfdlReceiver::Frame m_frame;
QDateTime m_dateTime;
MsgHfdlFrame(const AcarsHfdlReceiver::Frame& frame) :
Message(),
m_frame(frame),
m_dateTime(QDateTime::currentDateTime())
{ }
};
// A demodulated Aero signal unit that does not carry an ACARS message (log-on and
// log-off, channel control and assignment, acknowledgements, system tables). The
// reassembled ACARS blocks go out as MainCore::MsgPacket instead, as on every other
// protocol, so consumers of that message always see pure ACARS bytes.
// Which protocol the packets that FOLLOW came off, pushed by the sink into the same
// queue the packets themselves go to.
//
// The worker cannot take this from its own settings. The sink and the worker are
// configured through independent queues, so they change mode at different instants,
// and a packet demodulated under the old mode can reach the worker after its
// settings have already moved to the new one - which parses it under the wrong
// protocol, and so under the wrong reassembly rules. Stamping it where the packets are
// produced makes the association exact rather than merely likely.
class MsgProtocolChange : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getMode() const { return m_mode; }
static MsgProtocolChange* create(int mode) {
return new MsgProtocolChange(mode);
}
private:
int m_mode;
MsgProtocolChange(int mode) :
Message(),
m_mode(mode)
{ }
};
class MsgAeroFrame : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsAeroReceiver::Frame& getFrame() const { return m_frame; }
QDateTime getDateTime() const { return m_dateTime; }
static MsgAeroFrame* create(const AcarsAeroReceiver::Frame& frame)
{
return new MsgAeroFrame(frame);
}
private:
AcarsAeroReceiver::Frame m_frame;
QDateTime m_dateTime;
MsgAeroFrame(const AcarsAeroReceiver::Frame& frame) :
Message(),
m_frame(frame),
m_dateTime(QDateTime::currentDateTime())
{ }
};
// An ACARS block, plus what the bearer knew about it that the block itself does not
// say. VDL-2 puts the aircraft's 24 bit ICAO address in the AVLC header of the frame
// the block came out of, where the block names only a registration.
//
// A subclass rather than a separate message so that the address travels WITH its
// packet: there is then no ordering to get right and no way for an address to be
// applied to the wrong block. MainCore::MsgPacket::match() matches this too, because
// Message::matchIdentifier defers to the base class, so the existing packet handling
// - the APRS pipe, the UDP feed, the log - needs no change and sees a plain packet.
class MsgAcarsPacket : public MainCore::MsgPacket {
MESSAGE_CLASS_DECLARATION
public:
//!< 0 when the bearer gave no address, which is every bearer but VDL-2
quint32 getIcao() const { return m_icao; }
static MsgAcarsPacket* create(const QObject *pipeSource, QByteArray packet, quint32 icao)
{
return new MsgAcarsPacket(pipeSource, packet, QDateTime::currentDateTime(), icao);
}
private:
quint32 m_icao;
MsgAcarsPacket(const QObject *pipeSource, QByteArray packet, QDateTime dateTime,
quint32 icao) :
MainCore::MsgPacket(pipeSource, packet, dateTime),
m_icao(icao)
{ }
};
// A demodulated VDL-2 AVLC frame that does not carry an ACARS message (XID/GSIF,
// X.25, supervisory frames). ACARS frames go out as MainCore::MsgPacket instead, so
// downstream consumers of that message always see pure ACARS bytes.
class MsgVdl2Frame : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsVdl2Receiver::Frame& getFrame() const { return m_frame; }
QDateTime getDateTime() const { return m_dateTime; }
static MsgVdl2Frame* create(const AcarsVdl2Receiver::Frame& frame)
{
return new MsgVdl2Frame(frame);
}
private:
AcarsVdl2Receiver::Frame m_frame;
QDateTime m_dateTime;
MsgVdl2Frame(const AcarsVdl2Receiver::Frame& frame) :
Message(),
m_frame(frame),
m_dateTime(QDateTime::currentDateTime())
{ }
};
AcarsDemod(DeviceAPI *deviceAPI);
virtual ~AcarsDemod();
virtual void destroy() { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }
using BasebandSampleSink::feed;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start();
virtual void stop();
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); }
virtual QString getSinkName() { return objectName(); }
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
virtual const QString& getURI() const { return getName(); }
virtual void getTitle(QString& title) { title = m_settings.m_title; }
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset;; }
virtual void setCenterFrequency(qint64 frequency);
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response,
const AcarsDemodSettings& settings);
virtual int webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage);
static void webapiUpdateChannelSettings(
AcarsDemodSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
ScopeVis *getScopeSink() { return m_basebandSink->getScopeSink(); }
double getMagSq() const { return m_basebandSink->getMagSq(); }
void getAeroQuality(double& evm, double& suRate) const {
m_basebandSink->getAeroQuality(evm, suRate);
}
void getMagSqLevels(double& avg, double& peak, int& nbSamples) {
m_basebandSink->getMagSqLevels(avg, peak, nbSamples);
}
/* void setMessageQueueToGUI(MessageQueue* queue) override {
ChannelAPI::setMessageQueueToGUI(queue);
m_basebandSink->setMessageQueueToGUI(queue);
}*/
uint32_t getNumberOfDeviceStreams() const;
// The worker processes decoded frames on its own thread, in both GUI and
// server builds; the GUI connects to it for display events
AcarsDemodWorker *getWorker() { return m_worker; }
static const char * const m_channelIdURI;
static const char * const m_channelId;
private:
DeviceAPI *m_deviceAPI;
QThread m_thread;
AcarsDemodBaseband* m_basebandSink;
QThread *m_workerThread;
AcarsDemodWorker *m_worker;
AcarsDemodSettings m_settings;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
qint64 m_centerFrequency;
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
virtual bool handleMessage(const Message& cmd);
void applySettings(const AcarsDemodSettings& settings, bool force = false);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const AcarsDemodSettings& settings, bool force);
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const AcarsDemodSettings& settings,
bool force
);
private slots:
void networkManagerFinished(QNetworkReply *reply);
};
#endif // INCLUDE_ACARSDEMOD_H

196
plugins/channelrx/demodacars/acarsdemodbaseband.cpp

@ -0,0 +1,196 @@ @@ -0,0 +1,196 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <algorithm>
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "dsp/downchannelizer.h"
#include "acarsdemodbaseband.h"
MESSAGE_CLASS_DEFINITION(AcarsDemodBaseband::MsgConfigureAcarsDemodBaseband, Message)
// Up to 16x the standard policy (10 s of nominal samples): a burst's decode chain
// (multiple Viterbi attempts, turbo re-estimation, header repair) runs synchronously at
// the end of the burst and can take tens of milliseconds - and clusters of bursts
// compound it - which at accelerated file replay (10x and beyond) would overflow the
// 0.64 s standard FIFO. But capped in samples, since the FIFO is allocated in full: at
// 16x an 8 MS/s Iridium channel took 655 MB for its FIFO alone, and several channels on
// a wideband device took gigabytes. The cap is 8M samples (64 MB with 24 bit samples), still over a
// second at 8 MS/s.
static unsigned int fifoSize(unsigned int sampleRate)
{
const unsigned int standard = SampleSinkFifo::getSizePolicy(sampleRate);
const unsigned int maxSamples = 8 * 1024 * 1024;
return std::max(standard, std::min(standard * 16, maxSamples));
}
AcarsDemodBaseband::AcarsDemodBaseband(AcarsDemod *packetDemod) :
m_sink(packetDemod),
m_running(false)
{
qDebug("AcarsDemodBaseband::AcarsDemodBaseband");
m_sink.setScopeSink(&m_scopeSink);
m_sampleFifo.setSize(fifoSize(48000));
m_channelizer = new DownChannelizer(&m_sink);
}
AcarsDemodBaseband::~AcarsDemodBaseband()
{
m_inputMessageQueue.clear();
delete m_channelizer;
}
void AcarsDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset();
}
void AcarsDemodBaseband::startWork()
{
QMutexLocker mutexLocker(&m_mutex);
QObject::connect(
&m_sampleFifo,
&SampleSinkFifo::dataReady,
this,
&AcarsDemodBaseband::handleData,
Qt::QueuedConnection
);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_running = true;
}
void AcarsDemodBaseband::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
QObject::disconnect(
&m_sampleFifo,
&SampleSinkFifo::dataReady,
this,
&AcarsDemodBaseband::handleData
);
m_running = false;
}
void AcarsDemodBaseband::setChannel(ChannelAPI *channel)
{
m_sink.setChannel(channel);
}
void AcarsDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
{
m_sampleFifo.write(begin, end);
}
void AcarsDemodBaseband::handleData()
{
QMutexLocker mutexLocker(&m_mutex);
while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0))
{
SampleVector::iterator part1begin;
SampleVector::iterator part1end;
SampleVector::iterator part2begin;
SampleVector::iterator part2end;
std::size_t count = m_sampleFifo.readBegin(m_sampleFifo.fill(), &part1begin, &part1end, &part2begin, &part2end);
// first part of FIFO data
if (part1begin != part1end) {
m_channelizer->feed(part1begin, part1end);
}
// second part of FIFO data (used when block wraps around)
if(part2begin != part2end) {
m_channelizer->feed(part2begin, part2end);
}
m_sampleFifo.readCommit((unsigned int) count);
}
}
void AcarsDemodBaseband::handleInputMessages()
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != nullptr)
{
if (handleMessage(*message)) {
delete message;
}
}
}
bool AcarsDemodBaseband::handleMessage(const Message& cmd)
{
if (MsgConfigureAcarsDemodBaseband::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
MsgConfigureAcarsDemodBaseband& cfg = (MsgConfigureAcarsDemodBaseband&) cmd;
qDebug() << "AcarsDemodBaseband::handleMessage: MsgConfigureAcarsDemodBaseband";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPSignalNotification::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
qDebug() << "AcarsDemodBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate();
setBasebandSampleRate(notif.getSampleRate());
m_sampleFifo.setSize(fifoSize(notif.getSampleRate()));
return true;
}
else
{
return false;
}
}
void AcarsDemodBaseband::applySettings(const AcarsDemodSettings& settings, bool force)
{
bool modeChanged = AcarsDemodSettings::rateChanged(settings, m_settings);
// The sink has to know the mode before the channelization moves, as the mode sets
// the rate it resamples the channelizer output to
m_sink.applySettings(settings, force);
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || modeChanged || force)
{
m_channelizer->setChannelization(AcarsDemodSink::channelSampleRate(settings), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset(), modeChanged || force);
}
m_settings = settings;
}
void AcarsDemodBaseband::setBasebandSampleRate(int sampleRate)
{
m_channelizer->setBasebandSampleRate(sampleRate);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}

104
plugins/channelrx/demodacars/acarsdemodbaseband.h

@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODBASEBAND_H
#define INCLUDE_ACARSDEMODBASEBAND_H
#include <QObject>
#include <QMutex>
#include "dsp/samplesinkfifo.h"
#include "dsp/scopevis.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "acarsdemodsink.h"
class DownChannelizer;
class ChannelAPI;
class AcarsDemod;
class AcarsDemodBaseband : public QObject
{
Q_OBJECT
public:
class MsgConfigureAcarsDemodBaseband : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsDemodSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureAcarsDemodBaseband* create(const AcarsDemodSettings& settings, bool force)
{
return new MsgConfigureAcarsDemodBaseband(settings, force);
}
private:
AcarsDemodSettings m_settings;
bool m_force;
MsgConfigureAcarsDemodBaseband(const AcarsDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
AcarsDemodBaseband(AcarsDemod *packetDemod);
~AcarsDemodBaseband();
void reset();
void startWork();
void stopWork();
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
void getAeroQuality(double& evm, double& suRate) const {
m_sink.getAeroQuality(evm, suRate);
}
void getMagSqLevels(double& avg, double& peak, int& nbSamples) {
m_sink.getMagSqLevels(avg, peak, nbSamples);
}
void setMessageQueueToChannel(MessageQueue *messageQueue) { m_sink.setMessageQueueToChannel(messageQueue); }
void setBasebandSampleRate(int sampleRate);
ScopeVis *getScopeSink() { return &m_scopeSink; }
void setChannel(ChannelAPI *channel);
double getMagSq() const { return m_sink.getMagSq(); }
bool isRunning() const { return m_running; }
void setFifoLabel(const QString& label) { m_sampleFifo.setLabel(label); }
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
AcarsDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
AcarsDemodSettings m_settings;
ScopeVis m_scopeSink;
bool m_running;
QMutex m_mutex;
bool handleMessage(const Message& cmd);
void calculateOffset(AcarsDemodSink *sink);
void applySettings(const AcarsDemodSettings& settings, bool force = false);
private slots:
void handleInputMessages();
void handleData(); //!< Handle data when samples have to be processed
};
#endif // INCLUDE_ACARSDEMODBASEBAND_H

6
plugins/channelrx/demodacars/acarsdemoddata.qrc

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/">
<file>vdl2gs.txt</file>
</qresource>
</RCC>

2105
plugins/channelrx/demodacars/acarsdemodgui.cpp

File diff suppressed because it is too large Load Diff

244
plugins/channelrx/demodacars/acarsdemodgui.h

@ -0,0 +1,244 @@ @@ -0,0 +1,244 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODGUI_H
#define INCLUDE_ACARSDEMODGUI_H
#include <QIcon>
#include <QTableWidgetItem>
#include <QPushButton>
#include <QToolButton>
#include <QHBoxLayout>
#include <QMenu>
#include <QProgressDialog>
#include <QGeoCoordinate>
#include <QtCharts>
#include <QDialog>
#include <QTableWidget>
#include "channel/channelgui.h"
#include "dsp/channelmarker.h"
#include "util/messagequeue.h"
#include "util/planespotters.h"
#include "settings/rollupstate.h"
#include "util/acarsmessage.h"
#include "gui/acarsmessageview.h"
#include "acarsdemodsettings.h"
#include "acarsdemodworker.h"
#include "acarsmessagemodel.h"
#include "acarsvdl2.h"
#include "acarshfdl.h"
#include "util/osndb.h"
#include "util/ourairportsdb.h"
#include "util/aircraftreport.h"
class PluginAPI;
class DeviceUISet;
class BasebandSampleSink;
class AcarsDemod;
class AcarsDemodGUI;
class ScopeVis;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
using namespace QtCharts; // Qt6 moved the chart classes out of this namespace
#endif
namespace Ui {
class AcarsDemodGUI;
}
class AcarsDemodGUI;
class AcarsDemodGUI : public ChannelGUI {
Q_OBJECT
public:
static AcarsDemodGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel);
virtual void destroy();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setWorkspaceIndex(int index) { m_settings.m_workspaceIndex = index; };
virtual int getWorkspaceIndex() const { return m_settings.m_workspaceIndex; };
virtual void setGeometryBytes(const QByteArray& blob) { m_settings.m_geometryBytes = blob; };
virtual QByteArray getGeometryBytes() const { return m_settings.m_geometryBytes; };
virtual QString getTitle() const { return m_settings.m_title; };
virtual QColor getTitleColor() const { return m_settings.m_rgbColor; };
virtual void zetHidden(bool hidden) { m_settings.m_hidden = hidden; }
virtual bool getHidden() const { return m_settings.m_hidden; }
virtual ChannelMarker& getChannelMarker() { return m_channelMarker; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual void setStreamIndex(int streamIndex) { m_settings.m_streamIndex = streamIndex; }
public slots:
void channelMarkerChangedByCursor();
void channelMarkerHighlightedByCursor();
private:
Ui::AcarsDemodGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
ChannelMarker m_channelMarker;
RollupState m_rollupState;
AcarsDemodSettings m_settings;
bool m_doApplySettings;
ScopeVis* m_scopeVis;
AcarsDemod* m_acarsDemod;
qint64 m_deviceCenterFrequency;
int m_basebandSampleRate;
uint32_t m_tickCount;
MessageQueue m_inputMessageQueue;
PlaneSpotters m_planeSpotters;
QString m_photoLink;
QSharedPointer<const QHash<QString, AircraftInformation *>> m_aircraftInfo;
OsnDB m_osnDB;
QProgressDialog *m_progressDialog;
QMenu *menu; // Column select context menu
AcarsMessageModel *m_messageModel;
AcarsMessageFilter *m_messageFilter;
// Scrolling to the newest message is coalesced on to this timer rather than done per
// message: measured at 41 messages a second it was 393 us each, because
// scrollToBottom forces a synchronous relayout, and one relayout serves every
// message that arrived in the tick
QTimer *m_tableTimer;
bool m_scrollPending;
// Maps a row of the table as displayed to the model row behind it
int sourceRow(int viewRow) const;
QString udpToolTip() const;
// Multipart assembly states from the worker, for the decode view
QHash<quint64, AcarsAssemblyEvent> m_assemblies;
// Frames received per second chart
QChart *m_chart;
// One series per row type, indexed by AcarsRowEvent::m_frameType, so a protocol
// cannot be added without a series appearing for it. There used to be two series -
// "ACARS" and "VDL-2 link" - with everything that was not an ACARS message counted
// into the second one, so in HFDL or Aero mode the legend named the wrong protocol.
static const int CHART_FRAME_SERIES = 4;
static const char *m_frameSeriesNames[CHART_FRAME_SERIES];
QLineSeries *m_frameRateSeries[CHART_FRAME_SERIES];
QLineSeries *m_aircraftSeries;
bool anyFrameSeriesVisible() const;
QDateTimeAxis *m_xAxis;
QValueAxis *m_fpsYAxis;
QValueAxis *m_aircraftYAxis;
int m_frameRateCount[CHART_FRAME_SERIES];
QDateTime m_frameRateTime;
QHash<QString, qint64> m_aircraftLastSeen; // For the aircraft-seen series: epoch ms
QDateTime m_averageTime; // Up to when old chart data has been averaged
QPoint m_chartPanPos;
bool m_chartPanning;
// HFDL ground stations and the frequencies they announced in squitters
struct GsHeard
{
QSet<int> m_frequencies; // kHz
QDateTime m_lastHeard;
};
QHash<int, GsHeard> m_gsHeard;
QDialog *m_gsDialog = nullptr;
QTableWidget *m_gsTableWidget = nullptr;
explicit AcarsDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent = 0);
virtual ~AcarsDemodGUI();
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
void updateModeDependentWidgets();
void applyModeBandwidth();
void updateChannelMarker();
void updateGsTable();
void sendGroundStationToMap(const QString& name, float latitude, float longitude, const QString& text, QDateTime dateTime);
bool handleMessage(const Message& message);
void plotChart();
void resetChartAxes();
static void averageSeries(QLineSeries *series, const QDateTime& startTime, const QDateTime& endTime);
void makeUIConnections();
void updateAbsoluteCenterFrequency();
void updatePhotoText(const QString& registration);
void hideAircraftDetails();
void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);
virtual bool eventFilter(QObject *obj, QEvent *event) override;
void resizeTable();
QAction *createCheckableItem(QString& text, int idx, bool checked);
private slots:
void on_deltaFrequency_changed(qint64 value);
void on_mode_currentIndexChanged(int value);
void on_aeroChannel_currentIndexChanged(int value);
void on_iridiumBandwidth_currentIndexChanged(int value);
void on_gsTable_clicked();
void gsTableContextMenu(QPoint pos);
void on_rfBW_valueChanged(int index);
void on_threshold_valueChanged(int value);
void on_filter_currentIndexChanged(int index);
void on_filterPattern_editingFinished();
void on_clearTable_clicked();
void on_udpEnabled_clicked(bool checked);
void udpSettings(const QPoint& p);
void on_getOSNDB_clicked();
void applyFilter();
void restoreSplitter();
void on_logEnable_clicked(bool checked=false);
void on_logFilename_clicked();
void on_logOpen_clicked();
void on_displayChart_clicked(bool checked);
void on_noInfo_clicked(bool checked);
void updateMessagesTable();
void setShowDate(bool showDate);
void clearChart(const QPoint& p);
void legendMarkerClicked();
void on_channel1_currentIndexChanged(int index);
void on_channel2_currentIndexChanged(int index);
void messages_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
void messages_sectionResized(int logicalIndex, int oldSize, int newSize);
void messagesSelectionChanged();
void customContextMenuRequested(QPoint point);
void columnSelectMenu(QPoint pos);
void columnSelectMenuChecked(bool checked = false);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void handleInputMessages();
void tick();
void downloadingURL(const QString& url);
void downloadError(const QString& error);
void downloadProgress(qint64 bytesRead, qint64 totalBytes);
void downloadAircraftInformationFinished();
void aircraftPhoto(const PlaneSpottersPhoto *photo);
void photoClicked();
// Display events from the channel's worker, which does all the decode
void rowReady(const AcarsRowEvent& event);
void assemblyUpdated(const AcarsAssemblyEvent& event);
};
#endif // INCLUDE_ACARSDEMODGUI_H

1149
plugins/channelrx/demodacars/acarsdemodgui.ui

File diff suppressed because it is too large Load Diff

8
plugins/channelrx/demodacars/acarsdemodicons.qrc

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/">
<file>icons/aircraft.png</file>
<file>icons/chart.png</file>
<file>icons/gs.png</file>
<file>icons/forward.png</file>
</qresource>
</RCC>

92
plugins/channelrx/demodacars/acarsdemodplugin.cpp

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include "plugin/pluginapi.h"
#ifndef SERVER_MODE
#include "acarsdemodgui.h"
#endif
#include "acarsdemod.h"
#include "acarsdemodwebapiadapter.h"
#include "acarsdemodplugin.h"
const PluginDescriptor AcarsDemodPlugin::m_pluginDescriptor = {
AcarsDemod::m_channelId,
QStringLiteral("ACARS Demodulator"),
QStringLiteral("8.1.0"),
QStringLiteral("(c) Jon Beniston, M7RCE"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,
QStringLiteral("https://github.com/f4exb/sdrangel")
};
AcarsDemodPlugin::AcarsDemodPlugin(QObject* parent) :
QObject(parent),
m_pluginAPI(0)
{
}
const PluginDescriptor& AcarsDemodPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void AcarsDemodPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
m_pluginAPI->registerRxChannel(AcarsDemod::m_channelIdURI, AcarsDemod::m_channelId, this);
}
void AcarsDemodPlugin::createRxChannel(DeviceAPI *deviceAPI, BasebandSampleSink **bs, ChannelAPI **cs) const
{
if (bs || cs)
{
AcarsDemod *instance = new AcarsDemod(deviceAPI);
if (bs) {
*bs = instance;
}
if (cs) {
*cs = instance;
}
}
}
#ifdef SERVER_MODE
ChannelGUI* AcarsDemodPlugin::createRxChannelGUI(
DeviceUISet *deviceUISet,
BasebandSampleSink *rxChannel) const
{
(void) deviceUISet;
(void) rxChannel;
return 0;
}
#else
ChannelGUI* AcarsDemodPlugin::createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) const
{
return AcarsDemodGUI::create(m_pluginAPI, deviceUISet, rxChannel);
}
#endif
ChannelWebAPIAdapter* AcarsDemodPlugin::createChannelWebAPIAdapter() const
{
return new AcarsDemodWebAPIAdapter();
}

49
plugins/channelrx/demodacars/acarsdemodplugin.h

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODPLUGIN_H
#define INCLUDE_ACARSDEMODPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class DeviceUISet;
class BasebandSampleSink;
class AcarsDemodPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channel.acarsdemod")
public:
explicit AcarsDemodPlugin(QObject* parent = NULL);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual void createRxChannel(DeviceAPI *deviceAPI, BasebandSampleSink **bs, ChannelAPI **cs) const;
virtual ChannelGUI* createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) const;
virtual ChannelWebAPIAdapter* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
};
#endif // INCLUDE_ACARSDEMODPLUGIN_H

279
plugins/channelrx/demodacars/acarsdemodsettings.cpp

@ -0,0 +1,279 @@ @@ -0,0 +1,279 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB. //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "acarsdemodsettings.h"
#include "acarsaero.h"
AcarsDemodSettings::AcarsDemodSettings() :
m_channelMarker(nullptr),
m_scopeGUI(nullptr),
m_rollupState(nullptr)
{
resetToDefaults();
}
void AcarsDemodSettings::resetToDefaults()
{
m_inputFrequencyOffset = 0;
m_mode = ACARS;
m_aeroChannel = AcarsAeroReceiver::Submode600P;
m_iridiumBandwidth = AcarsDemodSettings::IridiumScanWidths - 1;
m_rfBandwidth = 12500.0f;
// Pre-key detection threshold, as a fraction of the AM modulation index seen at 2400 Hz.
// A real pre-key reads about 0.85 (ARINC 618 section 4.4.3 asks for at least 85 percent
// modulation); noise reads near zero. Being a ratio it does not move with signal level,
// so this is a false alarm setting rather than something to tune per station.
m_correlationThreshold = 0.25f;
m_filter = "";
m_filterColumn = 0;
m_udpEnabled = false;
m_udpAddress = "127.0.0.1";
m_udpPort = 9999;
m_scopeCh1 = 3; // Envelope
m_scopeCh2 = 4; // Pre-key detector statistic
m_displayPhotos = true;
m_hideNoInfo = true;
m_showDate = true;
m_splitterState = QByteArray();
m_displayChart = false;
m_logFilename = "acars_log.csv";
m_logEnabled = false;
// The airframes.io ACARS (acarsdec) station type ingests UDP on 5550; only some
// other station types (e.g. VDL2/vdlm2dec on 5555) are TCP
m_rgbColor = QColor(25, 205, 2).rgb();
m_title = "ACARS Demodulator";
m_streamIndex = 0;
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0;
m_reverseAPIChannelIndex = 0;
m_workspaceIndex = 0;
m_hidden = false;
for (int i = 0; i < ACARSDEMOD_COLUMNS; i++)
{
m_columnIndexes[i] = i;
m_columnSizes[i] = -1; // Autosize
}
}
QByteArray AcarsDemodSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeS32(2, m_streamIndex);
s.writeString(3, m_filter);
s.writeS32(52, m_filterColumn);
if (m_channelMarker) {
s.writeBlob(6, m_channelMarker->serialize());
}
s.writeU32(7, m_rgbColor);
s.writeString(9, m_title);
s.writeBool(14, m_useReverseAPI);
s.writeString(15, m_reverseAPIAddress);
s.writeU32(16, m_reverseAPIPort);
s.writeU32(17, m_reverseAPIDeviceIndex);
s.writeU32(18, m_reverseAPIChannelIndex);
s.writeFloat(20, m_rfBandwidth);
s.writeBool(22, m_udpEnabled);
s.writeString(23, m_udpAddress);
s.writeU32(24, m_udpPort);
s.writeS32(25, m_scopeCh1);
s.writeS32(26, m_scopeCh2);
s.writeFloat(27, m_correlationThreshold);
if (m_scopeGUI) {
s.writeBlob(28, m_scopeGUI->serialize());
}
if (m_rollupState) {
s.writeBlob(31, m_rollupState->serialize());
}
s.writeS32(33, m_workspaceIndex);
s.writeBlob(34, m_geometryBytes);
s.writeBool(35, m_hidden);
s.writeBool(36, m_displayPhotos);
s.writeString(37, m_logFilename);
s.writeBool(38, m_logEnabled);
s.writeS32(39, m_mode);
s.writeS32(53, m_aeroChannel);
s.writeS32(56, m_iridiumBandwidth);
// Key 40 stored the opposite question, "show these frames", so it is written
// inverted rather than moved to a new key - that way an existing preset keeps
// behaving exactly as it did, whichever way it was set
s.writeBool(40, !m_hideNoInfo);
s.writeBool(54, m_showDate);
s.writeBlob(55, m_splitterState);
s.writeBool(41, m_displayChart);
for (int i = 0; i < ACARSDEMOD_COLUMNS; i++)
s.writeS32(100 + i, m_columnIndexes[i]);
for (int i = 0; i < ACARSDEMOD_COLUMNS; i++)
s.writeS32(200 + i, m_columnSizes[i]);
return s.final();
}
bool AcarsDemodSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
uint32_t utmp;
QString strtmp;
d.readS32(1, &m_inputFrequencyOffset, 0);
d.readS32(2, &m_streamIndex, 0);
// Key 3 was previously the address filter, which migrates as the pattern with
// the default Registration column; key 4 (the flight filter) is retired
d.readString(3, &m_filter, "");
d.readS32(52, &m_filterColumn, 0);
if ((m_filterColumn < 0) || (m_filterColumn > 3)) {
m_filterColumn = 0;
}
d.readBlob(6, &bytetmp);
if (m_channelMarker) {
m_channelMarker->deserialize(bytetmp);
}
d.readU32(7, &m_rgbColor, QColor(25, 205, 2).rgb());
d.readString(9, &m_title, "ACARS Demodulator");
d.readBool(14, &m_useReverseAPI, false);
d.readString(15, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(16, &utmp, 0);
if ((utmp > 1023) && (utmp < 65535)) {
m_reverseAPIPort = utmp;
} else {
m_reverseAPIPort = 8888;
}
d.readU32(17, &utmp, 0);
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
d.readU32(18, &utmp, 0);
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
d.readFloat(20, &m_rfBandwidth, 12500.0f);
// The sink turns this straight into an interpolator cutoff (bandwidth / 2.2), so
// a corrupt or hand-edited preset carrying zero or a negative would build a
// degenerate filter. The GUI's slider covers 1 to 40 kHz; nothing else clamped it.
if ((m_rfBandwidth < 1000.0f) || (m_rfBandwidth > 40000.0f)) {
m_rfBandwidth = 12500.0f;
}
d.readBool(22, &m_udpEnabled);
d.readString(23, &m_udpAddress);
d.readU32(24, &utmp);
if ((utmp > 1023) && (utmp < 65535)) {
m_udpPort = utmp;
} else {
m_udpPort = 9999;
}
d.readS32(25, &m_scopeCh1, 0);
d.readS32(26, &m_scopeCh2, 0);
d.readFloat(27, &m_correlationThreshold, 0.25f);
// The threshold changed meaning when the demodulator became coherent: it used to be
// a raw correlation value in the tens to hundreds, now it is a ratio in 0 to 1. Any
// setting saved by an older version would disable detection entirely.
if (m_correlationThreshold > 1.0f) {
m_correlationThreshold = 0.25f;
}
if (m_scopeGUI)
{
d.readBlob(28, &bytetmp);
m_scopeGUI->deserialize(bytetmp);
}
if (m_rollupState)
{
d.readBlob(31, &bytetmp);
m_rollupState->deserialize(bytetmp);
}
d.readS32(33, &m_workspaceIndex, 0);
d.readBlob(34, &m_geometryBytes);
d.readBool(35, &m_hidden, false);
d.readBool(36, &m_displayPhotos, true);
d.readString(37, &m_logFilename, "acars_log.csv");
d.readBool(38, &m_logEnabled, false);
d.readS32(39, &m_mode, (int)ACARS);
if ((m_mode < 0) || (m_mode >= (int)ModeCount)) {
m_mode = (int)ACARS;
}
d.readS32(53, &m_aeroChannel, AcarsAeroReceiver::Submode600P);
if ((m_aeroChannel < 0) || (m_aeroChannel >= AcarsAeroReceiver::SubmodeCount)) {
m_aeroChannel = AcarsAeroReceiver::Submode600P;
}
d.readS32(56, &m_iridiumBandwidth, AcarsDemodSettings::IridiumScanWidths - 1);
if ((m_iridiumBandwidth < 0) || (m_iridiumBandwidth >= AcarsDemodSettings::IridiumScanWidths)) {
m_iridiumBandwidth = AcarsDemodSettings::IridiumScanWidths - 1;
}
bool displayNoInfo = false;
d.readBool(40, &displayNoInfo, false);
m_hideNoInfo = !displayNoInfo;
d.readBool(54, &m_showDate, true);
d.readBlob(55, &m_splitterState);
d.readBool(41, &m_displayChart, false);
// Both of these are fed to the table header - moveSection() and setColumnWidth() -
// so a preset from a build with a different column count, or a corrupt one, would
// otherwise reorder to an index that does not exist. A visual index must be a
// column; a size of 0 means hidden and -1 means "leave it to the header", so only
// negatives below -1 and absurd widths are rejected.
for (int i = 0; i < ACARSDEMOD_COLUMNS; i++)
{
d.readS32(100 + i, &m_columnIndexes[i], i);
if ((m_columnIndexes[i] < 0) || (m_columnIndexes[i] >= ACARSDEMOD_COLUMNS)) {
m_columnIndexes[i] = i;
}
}
for (int i = 0; i < ACARSDEMOD_COLUMNS; i++)
{
d.readS32(200 + i, &m_columnSizes[i], -1);
if ((m_columnSizes[i] < -1) || (m_columnSizes[i] > 8192)) {
m_columnSizes[i] = -1;
}
}
return true;
}
else
{
resetToDefaults();
return false;
}
}

150
plugins/channelrx/demodacars/acarsdemodsettings.h

@ -0,0 +1,150 @@ @@ -0,0 +1,150 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODSETTINGS_H
#define INCLUDE_ACARSDEMODSETTINGS_H
#include <QByteArray>
#include <QHash>
#include "dsp/dsptypes.h"
#include "util/aircraftreport.h"
class Serializable;
// Number of columns in the table.
#define ACARSDEMOD_COLUMNS 23
struct AcarsDemodSettings
{
enum Mode {
ACARS = 0, //!< Plain old ACARS: 2400 baud MSK on AM
VDL2 = 1, //!< VDL Mode 2: 10500 baud D8PSK, ACARS over AVLC
HFDL = 2, //!< HFDL: 1800 baud M-PSK on a 1440 Hz subcarrier, ACARS over MPDU/LPDU
Aero = 3, //!< Inmarsat Classic Aero: L band satellite, ACARS over signal units
Iridium = 4, //!< Iridium: L band satellite, burst DQPSK from low earth orbit.
ModeCount
};
// The protocol tag an AircraftReport gets for a given mode.
static AircraftReport::Protocol protocolForMode(int mode)
{
switch (mode)
{
case VDL2: return AircraftReport::VDL2;
case HFDL: return AircraftReport::HFDL;
case Aero: return AircraftReport::AERO;
case Iridium: return AircraftReport::IRIDIUM;
default: return AircraftReport::ACARS;
}
}
//! Whether a change moves the channel sample rate, and so needs the channelizer
//! retuned, the resampler rebuilt and the receivers restarted.
static bool rateChanged(const AcarsDemodSettings& a, const AcarsDemodSettings& b)
{
if (a.m_mode != b.m_mode) {
return true;
}
switch (a.m_mode)
{
case Aero: return a.m_aeroChannel != b.m_aeroChannel;
case Iridium: return a.m_iridiumBandwidth != b.m_iridiumBandwidth;
default: return false;
}
}
//! How many channelizer outputs each Iridium scan width uses. They have to be powers
//! of two, and the sample rate the channel needs is this times the 31.25 kHz channel
//! spacing - so 256 channels is 8 MS/s and covers 8 MHz, the whole Iridium band.
static int iridiumScanChannels(int bandwidth)
{
static const int channels[] = { 32, 64, 128, 256 };
const int count = (int) (sizeof(channels) / sizeof(channels[0]));
return channels[((bandwidth < 0) || (bandwidth >= count)) ? (count - 1) : bandwidth];
}
static const int IridiumScanWidths = 4;
qint32 m_inputFrequencyOffset;
int m_mode; //!< One of enum Mode
//!< Which Aero rate and channel is tuned, an AcarsAeroReceiver::Submode. Unlike
//!< HFDL, where the M1 sequence identifies the rate, these are properties of the
//!< frequency tuned, so they are a setting rather than something detected.
int m_aeroChannel;
//!< How much of the band the Iridium scanner covers. Iridium assigns a duplex channel
//!< when a call is set up, out of about 240 across 7 MHz, so watching one channel sees
//!< a few percent of the traffic - the scanner splits the whole width with a polyphase
//!< channelizer instead and runs a receiver on every output. An index into the table
//!< in iridiumScanChannels() below
int m_iridiumBandwidth;
Real m_rfBandwidth;
Real m_correlationThreshold; //!< Pre-key detection threshold, 0 to 1
QString m_filter; // Regular expression the filtered column must match
int m_filterColumn; // Which column to filter: 0 Registration, 1 Flight, 2 Label, 3 Message
bool m_udpEnabled;
QString m_udpAddress;
uint16_t m_udpPort;
int m_scopeCh1;
int m_scopeCh2;
bool m_displayPhotos;
//!< Hide frames carrying no usable information from the table - VDL-2
//!< supervisory/ack frames (RR etc) and Aero satellite housekeeping. They are
//!< still received and still held in the table, only not shown
bool m_hideNoInfo;
//!< Show the date as well as the time in the Date/Time column. The date is only
//!< worth the width once a session has run past midnight
bool m_showDate;
//!< How the table and the decode view divide the space, from QSplitter::saveState
QByteArray m_splitterState;
bool m_displayChart; //!< Show the frames-per-second chart
QString m_logFilename;
bool m_logEnabled;
quint32 m_rgbColor;
QString m_title;
Serializable *m_channelMarker;
QString m_audioDeviceName;
int m_streamIndex; //!< MIMO channel. Not relevant when connected to SI (single Rx).
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIDeviceIndex;
uint16_t m_reverseAPIChannelIndex;
Serializable *m_scopeGUI;
Serializable *m_rollupState;
int m_workspaceIndex;
QByteArray m_geometryBytes;
bool m_hidden;
int m_columnIndexes[ACARSDEMOD_COLUMNS];//!< How the columns are ordered in the table
int m_columnSizes[ACARSDEMOD_COLUMNS]; //!< Size of the columns in the table
AcarsDemodSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
void setScopeGUI(Serializable *scopeGUI) { m_scopeGUI = scopeGUI; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
#endif /* INCLUDE_ACARSDEMODSETTINGS_H */

523
plugins/channelrx/demodacars/acarsdemodsink.cpp

@ -0,0 +1,523 @@ @@ -0,0 +1,523 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2021-2026 Jon Beniston, M7RCE //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <algorithm>
#include "dsp/dspengine.h"
#include "dsp/datafifo.h"
#include "dsp/scopevis.h"
#include "util/db.h"
#include "maincore.h"
#include "acarsdemod.h"
#include "acarsdemodsink.h"
AcarsDemodSink::AcarsDemodSink(AcarsDemod *acarsDemod) :
m_scopeSink(nullptr),
m_acarsDemod(acarsDemod),
m_channel(nullptr),
m_channelSampleRate(ACARSDEMOD_CHANNEL_SAMPLE_RATE),
m_channelFrequencyOffset(0),
m_interpolatorDistance(1.0f),
m_interpolatorDistanceRemain(0.0f),
m_magsq(0.0),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
m_magsqCount(0),
m_messageQueueToChannel(nullptr),
m_iridiumChannels(0), // Configured on the first Iridium sample
m_iridiumLogCount(0),
m_iridiumCarrierCount(0),
m_demodPipesPresent(false),
m_demodPipeCheck(1),
m_scopeBufferIndex(0),
m_demodBufferFill(0)
{
m_demodBuffer.resize(1<<12);
m_scopeBuffer.resize(m_scopeBufferSize);
m_scopeBegin.resize(1);
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
AcarsDemodSink::~AcarsDemodSink()
{
}
void AcarsDemodSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
{
Complex ci;
if ((m_settings.m_mode == AcarsDemodSettings::Iridium)
&& (std::fabs(m_interpolatorDistance - 1.0f) < 1e-6f))
{
for (SampleVector::const_iterator it = begin; it != end; ++it)
{
Complex c(it->real(), it->imag());
c *= m_nco.nextIQ();
processOneSample(c);
}
return;
}
for (SampleVector::const_iterator it = begin; it != end; ++it)
{
Complex c(it->real(), it->imag());
c *= m_nco.nextIQ();
if (m_interpolatorDistance < 1.0f)
{
while (!m_interpolator.interpolate(&m_interpolatorDistanceRemain, c, &ci))
{
processOneSample(ci);
m_interpolatorDistanceRemain += m_interpolatorDistance;
}
}
else
{
if (m_interpolator.decimate(&m_interpolatorDistanceRemain, c, &ci))
{
processOneSample(ci);
m_interpolatorDistanceRemain += m_interpolatorDistance;
}
}
}
}
void AcarsDemodSink::sampleToScope(Real ch1, Real ch2)
{
m_scopeBuffer[m_scopeBufferIndex++] = Sample(ch1 * SDR_RX_SCALEF, ch2 * SDR_RX_SCALEF);
if (m_scopeBufferIndex == m_scopeBufferSize)
{
m_scopeBegin[0] = m_scopeBuffer.begin();
m_scopeSink->feed(m_scopeBegin, m_scopeBufferSize);
m_scopeBufferIndex = 0;
}
}
Real AcarsDemodSink::scopeChannel(int selection, const Complex& ci, Real magsq) const
{
bool vdl2 = m_settings.m_mode == AcarsDemodSettings::VDL2;
bool hfdl = m_settings.m_mode == AcarsDemodSettings::HFDL;
bool aero = m_settings.m_mode == AcarsDemodSettings::Aero;
switch (selection)
{
case 0: return ci.real() / SDR_RX_SCALEF;
case 1: return ci.imag() / SDR_RX_SCALEF;
case 2: return magsq;
case 3: return sqrt(magsq);
case 4: return vdl2 ? (Real) std::min(m_vdl2Receiver.syncStatistic(), 10.0)
: hfdl ? (Real) m_hfdlReceiver.lastSyncError()
: aero ? (Real) m_aeroReceiver.lastSyncError()
: (Real) m_receiver.detectStatistic();
case 5: return vdl2 ? (m_vdl2Receiver.synced() ? 1.0f : 0.0f)
: hfdl ? (m_hfdlReceiver.synced() ? 1.0f : 0.0f)
: aero ? (m_aeroReceiver.synced() ? 1.0f : 0.0f)
: (m_receiver.detected() ? 1.0f : 0.0f);
default: return 0.0f;
}
}
void AcarsDemodSink::processOneSample(Complex &ci)
{
Real re = ci.real() / SDR_RX_SCALEF;
Real im = ci.imag() / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
m_movingAverage(magsq);
m_magsq = m_movingAverage.asDouble();
m_magsqSum += magsq;
if (magsq > m_magsqPeak) {
m_magsqPeak = magsq;
}
m_magsqCount++;
if (m_settings.m_mode == AcarsDemodSettings::VDL2)
{
if (m_vdl2Receiver.processSample(std::complex<double>(re, im)))
{
while (m_vdl2Receiver.hasFrame())
{
AcarsVdl2Receiver::Frame frame = m_vdl2Receiver.popFrame();
if (!getMessageQueueToChannel()) {
continue;
}
if (frame.m_isAcars)
{
// ACARS over AVLC carries the message from the mode character to the
// DEL, so prepending an SOH gives the exact VHF ACARS byte layout and
// the whole existing message path (GUI, UDP, log) works unchanged
QByteArray rxPacket;
rxPacket.append((char) 0x01);
rxPacket.append((const char *) frame.m_bytes.data() + frame.m_infoOffset + 3, frame.m_infoLength - 3);
// The AVLC header names the airframe by its ICAO address, where the
// block inside names it by registration. Both are worth having: the
// address collates this aircraft with its ADS-B, and the pair is the
// only evidence we ever receive that the two belong together
uint32_t acAddress = frame.m_fromAircraft ? frame.m_srcAddress : frame.m_dstAddress;
int acType = frame.m_fromAircraft ? frame.m_srcType : frame.m_dstType;
getMessageQueueToChannel()->push(AcarsDemod::MsgAcarsPacket::create(
m_acarsDemod, rxPacket, (acType == 1) ? acAddress : 0));
}
else
{
getMessageQueueToChannel()->push(AcarsDemod::MsgVdl2Frame::create(frame));
}
}
}
}
else if (m_settings.m_mode == AcarsDemodSettings::HFDL)
{
if (m_hfdlReceiver.processSample(std::complex<double>(re, im)))
{
while (m_hfdlReceiver.hasFrame())
{
AcarsHfdlReceiver::Frame frame = m_hfdlReceiver.popFrame();
if (!getMessageQueueToChannel()) {
continue;
}
if (frame.m_isAcars)
{
// The LPDU carries the ACARS message from its SOH onwards, so the
// bytes from the mode character with an SOH prepended give the
// exact VHF ACARS layout and the existing message path works
QByteArray rxPacket;
rxPacket.append((char) 0x01);
rxPacket.append((const char *) frame.m_bytes.data() + frame.m_acarsOffset,
(int) (frame.m_bytes.size() - frame.m_acarsOffset));
getMessageQueueToChannel()->push(MainCore::MsgPacket::create(m_acarsDemod, rxPacket));
}
else
{
getMessageQueueToChannel()->push(AcarsDemod::MsgHfdlFrame::create(frame));
}
}
}
}
else if (m_settings.m_mode == AcarsDemodSettings::Aero)
{
if (m_aeroReceiver.processSample(std::complex<double>(re, im)))
{
while (m_aeroReceiver.hasFrame())
{
AcarsAeroReceiver::Frame frame = m_aeroReceiver.popFrame();
if (!getMessageQueueToChannel()) {
continue;
}
if (frame.m_isAcars)
{
// Unlike VDL-2 and HFDL, an Aero signal unit chain reassembles to a
// COMPLETE ARINC 618 block starting at its own SOH, so there is no
// SOH to prepend here. Parity is left on, as on the other protocols.
// Verified against AcarsMessage::decode on a real recording.
QByteArray rxPacket((const char *) frame.m_bytes.data(), (int) frame.m_bytes.size());
getMessageQueueToChannel()->push(MainCore::MsgPacket::create(m_acarsDemod, rxPacket));
}
else
{
getMessageQueueToChannel()->push(AcarsDemod::MsgAeroFrame::create(frame));
}
}
}
}
// Tested explicitly rather than left as a bare else: an unrecognised mode used to
// fall through to the VHF MSK demodulator, so a mode added without touching this
// line failed by quietly running the wrong receiver
else if (m_settings.m_mode == AcarsDemodSettings::Iridium)
{
// Unlike the other modes this one scans: the channelizer in the scanner splits
// the whole tuned width into Iridium channels and runs a receiver on each, so the
// samples arriving here are the band rather than a channel
const int channels = AcarsDemodSettings::iridiumScanChannels(m_settings.m_iridiumBandwidth);
if (channels != m_iridiumChannels)
{
m_iridiumScanner.setTransform(&m_iridiumTransform);
m_iridiumScanner.configure(channels);
m_iridiumChannels = channels;
m_iridiumCarrierCount = 0;
m_iridiumLogCount = 0;
m_iridiumLog = IridiumLog();
}
m_iridiumScanner.processSample(std::complex<double>(re, im));
if (++m_iridiumLogCount >= (qint64) (m_iridiumLogSeconds * m_iridiumScanner.inputRate()))
{
m_iridiumLogCount = 0;
logIridiumSummary();
}
while (m_iridiumScanner.hasDetection())
{
AcarsIridiumScanner::Detection detection = m_iridiumScanner.popDetection();
if (!detection.m_message.isEmpty())
{
QByteArray payload;
if (AcarsIridiumReassembler::sbdPayload(detection.m_message,
detection.m_frame.m_uplink, payload))
{
m_iridiumCarrierCount++;
if (detection.m_acars.isEmpty())
{
// Both type bytes, because the first on its own does not say
// whether a message could carry ACARS: 0x7608 does and 0x7605
// does not, and they look the same from the leading byte
const quint8 type0 = (quint8) detection.m_message[0];
const quint8 type1 = (detection.m_message.size() > 1)
? (quint8) detection.m_message[1] : 0;
qInfo() << "Iridium short burst data message," << detection.m_message.size()
<< "bytes, type" << QString("0x%1%2").arg(type0, 2, 16, QChar('0'))
.arg(type1, 2, 16, QChar('0'))
<< ":" << detection.m_message.toHex('.')
<< "(payload is not ACARS)";
}
}
}
if (detection.m_acars.isEmpty()) {
continue;
}
if (getMessageQueueToChannel())
{
MainCore::MsgPacket *msg = MainCore::MsgPacket::create(m_acarsDemod, detection.m_acars);
getMessageQueueToChannel()->push(msg);
}
}
}
else if (m_settings.m_mode == AcarsDemodSettings::ACARS)
{
if (m_receiver.processSample(std::complex<double>(re, im)))
{
QByteArray rxPacket((const char *) m_receiver.message(), m_receiver.messageLength());
if (getMessageQueueToChannel())
{
MainCore::MsgPacket *msg = MainCore::MsgPacket::create(m_acarsDemod, rxPacket);
getMessageQueueToChannel()->push(msg);
}
}
}
if (m_scopeSink)
{
sampleToScope(scopeChannel(m_settings.m_scopeCh1, ci, magsq),
scopeChannel(m_settings.m_scopeCh2, ci, magsq));
}
// Demod Analyzer feature.
//
// Whether anything is listening is rechecked periodically rather than assumed, so
// that the square root below is not paid for when nothing is. That mattered little
// while every mode ran at 105 kS/s or less, but Iridium scans the band at up to
// 8 MS/s, where this was eight million square roots a second and a pipe lookup two
// thousand times a second for a feature that is usually not attached
if (--m_demodPipeCheck <= 0)
{
QList<ObjectPipe*> dataPipes;
MainCore::instance()->getDataPipes().getDataPipes(m_channel, "demod", dataPipes);
m_demodPipesPresent = !dataPipes.isEmpty();
m_demodPipeCheck = m_demodPipeCheckInterval;
}
if (!m_demodPipesPresent)
{
m_demodBufferFill = 0;
return;
}
m_demodBuffer[m_demodBufferFill++] = (qint16)(sqrt(magsq) * std::numeric_limits<int16_t>::max());
if (m_demodBufferFill >= m_demodBuffer.size())
{
QList<ObjectPipe*> dataPipes;
MainCore::instance()->getDataPipes().getDataPipes(m_channel, "demod", dataPipes);
for (const auto& pipe : dataPipes)
{
DataFifo *fifo = qobject_cast<DataFifo*>(pipe->m_element);
if (fifo) {
fifo->write((quint8*) &m_demodBuffer[0], m_demodBuffer.size() * sizeof(qint16), DataFifo::DataTypeI16);
}
}
m_demodBufferFill = 0;
}
}
//! Taps per phase for the input resampler. The sharp filter the other modes need is to
//! keep the root raised cosine skirt intact right up to the channel edge. Iridium does not
//! want a channel filter at all - it passes the whole scanned width and lets its own
//! channelizer do the filtering - so the cheap setting is enough, and at several MS/s the
//! difference between 4.5 and 18 taps per phase is a large part of the whole cost
static Real inputFilterTaps(const AcarsDemodSettings& settings)
{
return ((settings.m_mode == AcarsDemodSettings::ACARS)
|| (settings.m_mode == AcarsDemodSettings::Iridium)) ? 4.5 : 18.0;
}
static Real effectiveRfBandwidth(const AcarsDemodSettings& settings)
{
if (settings.m_mode == AcarsDemodSettings::Iridium) {
return (Real) AcarsDemodSink::channelSampleRate(settings);
}
return settings.m_rfBandwidth;
}
void AcarsDemodSink::logIridiumSummary()
{
const int bursts = m_iridiumScanner.burstCount();
if (bursts == m_iridiumLog.m_bursts) {
return;
}
qInfo() << "Iridium:" << (bursts - m_iridiumLog.m_bursts) << "bursts in the last"
<< m_iridiumLogSeconds << "s on" << m_iridiumChannels << "channels,"
<< (m_iridiumScanner.duplicateCount() - m_iridiumLog.m_duplicates) << "duplicated,"
<< (m_iridiumScanner.frameCount() - m_iridiumLog.m_frames) << "frames decoded of which"
<< (m_iridiumScanner.idaCount() - m_iridiumLog.m_ida) << "short burst data,"
<< (m_iridiumScanner.messageCount() - m_iridiumLog.m_messages) << "messages reassembled of which"
<< (m_iridiumCarrierCount - m_iridiumLog.m_carriers) << "carry a payload,"
<< (m_iridiumScanner.acarsCount() - m_iridiumLog.m_acars) << "ACARS";
m_iridiumLog.m_bursts = bursts;
m_iridiumLog.m_duplicates = m_iridiumScanner.duplicateCount();
m_iridiumLog.m_frames = m_iridiumScanner.frameCount();
m_iridiumLog.m_ida = m_iridiumScanner.idaCount();
m_iridiumLog.m_messages = m_iridiumScanner.messageCount();
m_iridiumLog.m_carriers = m_iridiumCarrierCount;
m_iridiumLog.m_acars = m_iridiumScanner.acarsCount();
}
void AcarsDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force)
{
qDebug() << "AcarsDemodSink::applyChannelSettings:"
<< " channelSampleRate: " << channelSampleRate
<< " channelFrequencyOffset: " << channelFrequencyOffset;
if ((m_channelFrequencyOffset != channelFrequencyOffset) ||
(m_channelSampleRate != channelSampleRate) || force)
{
// The published HFDL channel frequency is the (suppressed) SSB carrier; the PSK
// subcarrier sits 1440 Hz above it, so tuning to the published frequency needs
// an extra shift down onto the subcarrier
int subcarrier = m_settings.m_mode == AcarsDemodSettings::HFDL ? ACARSHFDL_SUBCARRIER_HZ : 0;
m_nco.setFreq(-(channelFrequencyOffset + subcarrier), channelSampleRate);
// Retuning moves the signal, so everything a receiver has worked out about where
// it is - the carrier it is tracking, the symbol clock phase it has locked, the
// instant it expects the next frame at - describes the old position and not the
// new one. Only a mode or rate change used to reset them, which is why changing
// one was the way to get a demodulator going again after nudging the offset.
//
// Not on a sample rate change alone: that path already rebuilds the interpolator
// below and the receivers cope with it, and a reset there would throw away a
// transmission in progress for nothing.
if (m_channelFrequencyOffset != channelFrequencyOffset)
{
m_vdl2Receiver.reset();
m_hfdlReceiver.reset();
m_aeroReceiver.reset();
}
}
if ((m_channelSampleRate != channelSampleRate) || force)
{
// VDL-2, HFDL and Aero need a sharper filter: the root raised cosine skirt sits
// close to the channel edge and the default 4.5 taps per phase dents it enough
// to cause symbol errors
m_interpolator.create(16, channelSampleRate, effectiveRfBandwidth(m_settings) / 2.2f,
inputFilterTaps(m_settings));
m_interpolatorDistance = (Real) channelSampleRate / (Real) AcarsDemodSink::channelSampleRate(m_settings);
m_interpolatorDistanceRemain = m_interpolatorDistance;
}
m_channelSampleRate = channelSampleRate;
m_channelFrequencyOffset = channelFrequencyOffset;
}
void AcarsDemodSink::applySettings(const AcarsDemodSettings& settings, bool force)
{
qDebug() << "AcarsDemodSink::applySettings: force: " << force;
// An Aero submode or an Iridium scan width moves the rate just as a mode change does
bool modeChanged = AcarsDemodSettings::rateChanged(settings, m_settings);
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || modeChanged || force)
{
m_interpolator.create(16, m_channelSampleRate, effectiveRfBandwidth(settings) / 2.2f,
inputFilterTaps(settings));
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) AcarsDemodSink::channelSampleRate(settings);
m_interpolatorDistanceRemain = m_interpolatorDistance;
int subcarrier = settings.m_mode == AcarsDemodSettings::HFDL ? ACARSHFDL_SUBCARRIER_HZ : 0;
m_nco.setFreq(-(m_channelFrequencyOffset + subcarrier), m_channelSampleRate);
}
// Reconfiguring reallocates and resets the receiver, which throws away a transmission in
// progress, so only do it when something it cares about has actually moved
if ((settings.m_correlationThreshold != m_settings.m_correlationThreshold) || force)
{
AcarsOqpskReceiver::Config config = m_receiver.config();
config.m_detectThreshold = settings.m_correlationThreshold;
m_receiver.configure(config);
}
if (modeChanged || force)
{
// Stamp the protocol into the SAME queue the packets go to, so the worker applies
// it in stream order with them rather than from its own separately delivered
// settings - see AcarsDemod::MsgProtocolChange
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(AcarsDemod::MsgProtocolChange::create(settings.m_mode));
}
m_vdl2Receiver.reset();
m_hfdlReceiver.reset();
// setMode reconfigures the matched filter and buffers for the new rate, and
// resets, so it has to be called rather than reset() alone
m_aeroReceiver.setMode(AcarsAeroReceiver::submodeRate(settings.m_aeroChannel),
AcarsAeroReceiver::submodeChannel(settings.m_aeroChannel));
}
m_settings = settings;
}

193
plugins/channelrx/demodacars/acarsdemodsink.h

@ -0,0 +1,193 @@ @@ -0,0 +1,193 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2021-2026 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODSINK_H
#define INCLUDE_ACARSDEMODSINK_H
#include <QVector>
#include <vector>
#include "dsp/channelsamplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/movingaverage.h"
#include "util/messagequeue.h"
#include "acarsdemodsettings.h"
#include "acarsoqpsk.h"
#include "acarsvdl2.h"
#include "acarshfdl.h"
#include "acarsaero.h"
#include "acarsiridium.h"
#include "acarsiridiumscanner.h"
#include "acarsiridiumfftengine.h"
#define ACARSDEMOD_CHANNEL_SAMPLE_RATE ACARSOQPSK_CHANNEL_SAMPLE_RATE
class ChannelAPI;
class AcarsDemod;
class ScopeVis;
class AcarsDemodSink : public ChannelSampleSink {
public:
AcarsDemodSink(AcarsDemod *acarsDemod);
~AcarsDemodSink();
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
void setScopeSink(ScopeVis* scopeSink) { m_scopeSink = scopeSink; }
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
void applySettings(const AcarsDemodSettings& settings, bool force = false);
void setMessageQueueToChannel(MessageQueue *messageQueue) { m_messageQueueToChannel = messageQueue; }
void setChannel(ChannelAPI *channel) { m_channel = channel; }
// The fixed rate the demodulator for the given settings runs at. Aero needs the
// whole settings object rather than just the mode, because its rate depends on the
// submode as well - the MSK rates and the OQPSK rate run at different sample rates.
static int channelSampleRate(const AcarsDemodSettings& settings)
{
switch (settings.m_mode)
{
case AcarsDemodSettings::VDL2: return ACARSVDL2_CHANNEL_SAMPLE_RATE;
case AcarsDemodSettings::HFDL: return ACARSHFDL_CHANNEL_SAMPLE_RATE;
case AcarsDemodSettings::Aero:
return AcarsAeroReceiver::channelSampleRate(
AcarsAeroReceiver::submodeRate(settings.m_aeroChannel));
// Iridium scans rather than tuning one channel, so the rate is the width of band
// it covers, not the rate one receiver runs at
case AcarsDemodSettings::Iridium:
return AcarsDemodSettings::iridiumScanChannels(settings.m_iridiumBandwidth)
* ACARSIRIDIUM_SCAN_SPACING;
default: return ACARSDEMOD_CHANNEL_SAMPLE_RATE;
}
}
double getMagSq() const { return m_magsq; }
//! Aero link quality: EVM as a fraction and the recent signal unit CRC pass rate,
//! both negative until the receiver has something to report
void getAeroQuality(double& evm, double& suRate) const
{
evm = m_aeroReceiver.evm();
suRate = m_aeroReceiver.suRate();
}
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
if (m_magsqCount > 0)
{
m_magsq = m_magsqSum / m_magsqCount;
m_magSqLevelStore.m_magsq = m_magsq;
m_magSqLevelStore.m_magsqPeak = m_magsqPeak;
}
avg = m_magSqLevelStore.m_magsq;
peak = m_magSqLevelStore.m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;
}
private:
struct MagSqLevelsStore
{
MagSqLevelsStore() :
m_magsq(1e-12),
m_magsqPeak(1e-12)
{}
double m_magsq;
double m_magsqPeak;
};
ScopeVis* m_scopeSink;
AcarsDemod *m_acarsDemod;
AcarsDemodSettings m_settings;
ChannelAPI *m_channel;
int m_channelSampleRate;
int m_channelFrequencyOffset;
NCO m_nco;
Interpolator m_interpolator;
Real m_interpolatorDistance;
Real m_interpolatorDistanceRemain;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
MagSqLevelsStore m_magSqLevelStore;
MessageQueue *m_messageQueueToChannel;
MovingAverageUtil<Real, double, 16> m_movingAverage;
AcarsOqpskReceiver m_receiver;
AcarsVdl2Receiver m_vdl2Receiver;
AcarsHfdlReceiver m_hfdlReceiver;
AcarsAeroReceiver m_aeroReceiver;
AcarsIridiumScanner m_iridiumScanner;
//!< SDRangel's FFT behind the channelizer, which is much faster than the one the
//!< scanner carries for the sake of the offline harnesses
AcarsIridiumFftEngine m_iridiumTransform;
int m_iridiumChannels; //!< What the scanner is currently configured for
//!< Scanning the whole band decodes a dozen frames a second, so none of them are
//!< logged individually - what the band is doing is summarised this often instead,
//!< as the change in the scanner's counters since the last one
static constexpr double m_iridiumLogSeconds = 60.0;
qint64 m_iridiumLogCount; //!< Input samples since the last summary
int m_iridiumCarrierCount; //!< Reassembled messages whose type carries a payload
struct IridiumLog
{
int m_bursts = 0;
int m_duplicates = 0;
int m_frames = 0;
int m_ida = 0;
int m_messages = 0;
int m_carriers = 0;
int m_acars = 0;
};
IridiumLog m_iridiumLog; //!< The counters as of the last summary
//!< Whether a Demod Analyzer is attached, rechecked every so many samples rather
//!< than per sample. A tenth of a second at the fastest rate the plugin runs at
bool m_demodPipesPresent;
int m_demodPipeCheck;
static const int m_demodPipeCheckInterval = 100000;
static const int m_scopeBufferSize = 512;
SampleVector m_scopeBuffer;
std::vector<SampleVector::const_iterator> m_scopeBegin;
int m_scopeBufferIndex;
QVector<qint16> m_demodBuffer;
int m_demodBufferFill;
void processOneSample(Complex &ci);
void logIridiumSummary();
void sampleToScope(Real ch1, Real ch2);
Real scopeChannel(int selection, const Complex& ci, Real magsq) const;
MessageQueue *getMessageQueueToChannel() { return m_messageQueueToChannel; }
};
#endif // INCLUDE_ACARSDEMODSINK_H

52
plugins/channelrx/demodacars/acarsdemodwebapiadapter.cpp

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "SWGChannelSettings.h"
#include "acarsdemod.h"
#include "acarsdemodwebapiadapter.h"
AcarsDemodWebAPIAdapter::AcarsDemodWebAPIAdapter()
{}
AcarsDemodWebAPIAdapter::~AcarsDemodWebAPIAdapter()
{}
int AcarsDemodWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAcarsDemodSettings(new SWGSDRangel::SWGACARSDemodSettings());
response.getAcarsDemodSettings()->init();
AcarsDemod::webapiFormatChannelSettings(response, m_settings);
return 200;
}
int AcarsDemodWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) force;
(void) errorMessage;
AcarsDemod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
return 200;
}

50
plugins/channelrx/demodacars/acarsdemodwebapiadapter.h

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// Copyright (C) 2020 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMOD_WEBAPIADAPTER_H
#define INCLUDE_ACARSDEMOD_WEBAPIADAPTER_H
#include "channel/channelwebapiadapter.h"
#include "acarsdemodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class AcarsDemodWebAPIAdapter : public ChannelWebAPIAdapter {
public:
AcarsDemodWebAPIAdapter();
virtual ~AcarsDemodWebAPIAdapter();
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
AcarsDemodSettings m_settings;
};
#endif // INCLUDE_ACARSDEMOD_WEBAPIADAPTER_H

2586
plugins/channelrx/demodacars/acarsdemodworker.cpp

File diff suppressed because it is too large Load Diff

276
plugins/channelrx/demodacars/acarsdemodworker.h

@ -0,0 +1,276 @@ @@ -0,0 +1,276 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSDEMODWORKER_H
#define INCLUDE_ACARSDEMODWORKER_H
#include <QObject>
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <QUdpSocket>
#include <QTcpSocket>
#include <QHostAddress>
#include <QGeoCoordinate>
#include <QMetaType>
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/aircraftreport.h"
#include "util/osndb.h"
// For m_airportInfo, which names the airports a message mentions
#include "util/ourairportsdb.h"
#include <libacars/reassembly.h>
#include "acarsdemodsettings.h"
#include "util/acarsmessage.h"
#include "util/acarsmultipartassembler.h"
#include "acarsvdl2.h"
#include "acarshfdl.h"
#include "acarsaero.h"
#include "vdl2atn.h"
class AcarsDemod;
// One decoded frame, ready for display: the worker computes every table column
// and the decode view content, so the GUI only builds rows from strings
struct AcarsRowEvent {
int m_frameType = 0; // 0 = ACARS message, 1 = VDL-2 link frame, 2 = HFDL frame, 3 = Aero signal unit
// Frames carrying no usable information - VDL-2 supervisory and link management
// responses, Aero satellite housekeeping - which the GUI hides by default
bool m_noInfo = false;
QDateTime m_received;
bool m_uplink = false;
// Which link the frame arrived on, and how fast it was going. Both kept out of
// Label Decode, which is for what the Label means and nothing else.
QString m_protocol;
int m_bitRate = 0; // bits per second, 0 when not known
// Table column texts. The mode is the raw character - the GUI derives the
// country-specific decode so it can relabel when the country changes.
// The ground station the frame went to or came from, and its name. On plain ACARS
// the mode is the ARINC 618 Mode character and the decode is derived from it in the
// model; every other protocol names its ground station here, where the tables are.
QString m_mode;
QString m_modeDecode;
// Where that ground station is, for the Find on map action on the GS columns. Only
// the protocols whose stations are at known places have one - HFDL from its system
// table, VDL-2 from the community list - so ACARS and Aero leave this unset.
bool m_gsHasPosition = false;
float m_gsLatitude = 0.0f;
float m_gsLongitude = 0.0f;
QString m_address;
QString m_ack;
QString m_label;
QString m_labelDecode;
QString m_blockId;
QString m_originator;
QString m_originatorDecode;
QString m_messageNumber;
QString m_blockSequence;
QString m_flight;
QString m_text;
QString m_textDecode; // Flattened single-line decode for the column
QString m_atc;
QString m_hex;
bool m_hasPosition = false;
bool m_hasAltitude = false;
double m_latitude = 0.0;
double m_longitude = 0.0;
double m_altitudeFt = 0.0;
// Decode view / Map checkbox payloads
QString m_fullDecode; // Multi-line plain decode (the VDL2_DECODE_ROLE content)
bool m_useLibacars = false;
QString m_viewDecodeHtml; // Precomputed decode-view HTML for non-multipart rows
// Multipart: rows of one assembly share an id; the assembly's evolving
// state arrives via AcarsAssemblyEvent
quint64 m_assemblyId = 0;
int m_partNumber = 0;
// For the GUI's aircraft-count chart
QString m_chartAircraftId;
// For the GUI's HFDL ground-stations-heard table: a squitter announces the
// frequency sets of up to three stations
QList<int> m_gsHeardIds;
QList<QList<int>> m_gsHeardFreqs; // kHz, parallel to m_gsHeardIds
};
// The state of a multipart assembly, for the decode view of its rows
struct AcarsAssemblyEvent {
quint64 m_assemblyId = 0;
bool m_isMultipart = false;
bool m_uplink = false;
QString m_statusText;
int m_uniquePartCount = 0;
int m_duplicateCount = 0;
QStringList m_missingSequences;
QString m_combinedHtmlBody; // The "Combined message" section, ready for the view
};
Q_DECLARE_METATYPE(AcarsRowEvent)
Q_DECLARE_METATYPE(AcarsAssemblyEvent)
// Processes demodulated frames off the GUI thread: receives ACARS/VDL-2/HFDL
// frames directly from the sink and performs the higher layer decode (libacars,
// multipart assembly, ATN), the channel outputs ("packets" pipes, raw UDP, CSV
// log, aggregator feeds), aircraft reports and Map items. Runs on its own
// thread inside the channel, in both GUI and server builds; the GUI, when there
// is one, builds its table from this class's row events.
class AcarsDemodWorker : public QObject
{
Q_OBJECT
public:
class MsgConfigureWorker : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AcarsDemodSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureWorker* create(const AcarsDemodSettings& settings, bool force) {
return new MsgConfigureWorker(settings, force);
}
private:
AcarsDemodSettings m_settings;
bool m_force;
MsgConfigureWorker(const AcarsDemodSettings& settings, bool force) :
Message(), m_settings(settings), m_force(force)
{}
};
// The aircraft database has been downloaded again: pick up the new one
class MsgReloadAircraftDatabase : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgReloadAircraftDatabase* create() {
return new MsgReloadAircraftDatabase();
}
private:
MsgReloadAircraftDatabase() :
Message()
{}
};
// An ACARS block read back from a .csv log. Decoded and shown like a received one,
// but kept off the outputs - UDP, the "packets" pipes, the log and the aggregator
// feed - which would otherwise send old traffic out again as if it were new, and
// append to the very log being read.
class MsgReplayPacket : public Message {
MESSAGE_CLASS_DECLARATION
public:
const QByteArray& getPacket() const { return m_packet; }
QDateTime getDateTime() const { return m_dateTime; }
static MsgReplayPacket* create(const QByteArray& packet, const QDateTime& dateTime) {
return new MsgReplayPacket(packet, dateTime);
}
private:
QByteArray m_packet;
QDateTime m_dateTime;
MsgReplayPacket(const QByteArray& packet, const QDateTime& dateTime) :
Message(), m_packet(packet), m_dateTime(dateTime)
{}
};
explicit AcarsDemodWorker(AcarsDemod *acarsDemod);
~AcarsDemodWorker();
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
public slots:
void startWork();
signals:
void rowReady(const AcarsRowEvent& event);
void assemblyUpdated(const AcarsAssemblyEvent& event);
private:
AcarsDemod *m_acarsDemod;
AcarsDemodSettings m_settings;
MessageQueue m_inputMessageQueue;
qint64 m_centerFrequency = 0;
// Channel outputs
QUdpSocket *m_udpSocket = nullptr; // Created on the worker thread
QFile m_logFile;
QTextStream m_logStream;
// ACARS decode state
la_reasm_ctx *m_reasmCtx = nullptr;
AcarsMultipartAssembler m_multipartAssembler;
// Identity handed to the multipart assembler for each decoded message. A counter,
// not a pointer, so decoded messages no longer have to be kept alive to keep their
// addresses unique - see processAcarsMessage()
quint64 m_nextSourceId = 0;
// VDL-2 decode state
Vdl2AtnDecoder m_atnDecoder; // X.25/CLNP/COTP/ATN decode of VDL-2 I frames
struct Vdl2GsInfo
{
QString m_name;
QString m_city;
bool m_hasPosition = false;
float m_latitude = 0.0f;
float m_longitude = 0.0f;
};
QHash<quint32, Vdl2GsInfo> m_vdl2Gs; // The community ground station list
// HFDL decode state
int m_hfdlNewestReportSecs = -1; // Newest HFNPDU report time seen, for replay-aware freshness
// Aggregator feeds (sockets created on the worker thread)
// Databases for message decode and flight paths
QSharedPointer<const QHash<QString, AircraftInformation *>> m_aircraftInfo;
QSharedPointer<const QHash<int, AircraftInformation *>> m_aircraftInfoByIcao;
// Label decode tables (moved from the GUI so the decode works headless)
static QHash<QString, QString> m_labels;
static QHash<QString, QString> m_subLabels;
static QHash<QString, QString> m_originators;
bool handleMessage(const Message& message);
void applySettings(const AcarsDemodSettings& settings, bool force);
void forwardToGui(Message *message);
//!< icao is the address the bearer knew, or 0 - see AcarsDemod::MsgAcarsPacket
//!< replay is true for a block read back from a .csv log - see MsgReplayPacket
void processPacket(const QByteArray& packet, QDateTime dateTime, quint32 icao = 0, bool replay = false);
void processAcarsMessage(QByteArray messageBytes, QDateTime received, quint32 icao = 0, bool replay = false);
void processVdl2Frame(const AcarsVdl2Receiver::Frame& frame, QDateTime received);
void processHfdlFrame(const AcarsHfdlReceiver::Frame& frame, QDateTime received);
void processAeroFrame(const AcarsAeroReceiver::Frame& frame, QDateTime received);
void loadVdl2Gs();
void resetReassembly();
bool hasGui() const;
// The protocol the packets currently in flight came off, stamped by the sink rather
// than read from m_settings - see AcarsDemod::MsgProtocolChange
int m_protocolMode = 0; // AcarsDemodSettings::ACARS
void feedMessage(const QByteArray& block, const QDateTime& received);
void sendAircraftReport(AircraftReport& report);
void emitAssemblyState(const QSharedPointer<AcarsMultipartAssembler::Assembly>& assembly);
private slots:
void handleInputMessages();
};
#endif // INCLUDE_ACARSDEMODWORKER_H

3114
plugins/channelrx/demodacars/acarshfdl.h

File diff suppressed because it is too large Load Diff

894
plugins/channelrx/demodacars/acarsiridium.h

@ -0,0 +1,894 @@ @@ -0,0 +1,894 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUM_H
#define INCLUDE_ACARSIRIDIUM_H
#include <QDebug>
#include <complex>
#include <cmath>
#include <cstdint>
#include <deque>
#include <algorithm>
#include <vector>
#include "acarsiridiumfft.h"
#include "acarsiridiumdetector.h"
// Iridium L band burst receiver, physical layer.
//
// Iridium is unlike the other protocols this plugin decodes. ACARS, VDL-2 and HFDL are
// continuous narrowband channels, and Inmarsat Aero is a geostationary satellite whose
// Doppler barely moves. Iridium is burst TDMA from satellites in low earth orbit:
//
// - bursts of about 8.3 ms in a 90 ms frame, so the receiver sees silence most of the
// time and has nothing to hold a lock on between them
// - DQPSK at 25 kbaud, an order of magnitude faster than the Aero MSK rates
// - low earth orbit gives roughly 37 kHz of Doppler either way, and it moves while the
// burst is being received, so every burst needs its own frequency estimate
//
// This stage finds bursts, demodulates them to symbols, and hands the bit stream from the
// unique word onwards to AcarsIridiumFrameDecoder in acarsiridiumframe.h, which does
// frame classification, BCH and the field decoding.
//
// The constants and the processing order follow gr-iridium, which is the reference this
// was checked against: coarse frequency from the preamble, fine frequency from the whole
// burst, root raised cosine matched filter, symbol timing, then differential demodulation.
// Five samples per symbol at 25 kbaud. One Iridium channel is 41.67 kHz wide, so 125 kHz
// leaves room either side for a burst that Doppler has pushed off its nominal frequency.
//
// The rate is what it is because of the channelizer in acarsiridiumchannelizer.h, which
// scans the whole band: its output rate is four times its channel spacing, and 31.25 kHz
// spacing - close enough to the 41.67 kHz Iridium grid that every channel is covered -
// gives 125 kHz out. That it also divides the symbol rate exactly is what makes 31.25 kHz
// the spacing to pick
#define ACARSIRIDIUM_CHANNEL_SAMPLE_RATE 125000
#define ACARSIRIDIUM_SYMBOL_RATE 25000
#define ACARSIRIDIUM_SAMPLES_PER_SYMBOL (ACARSIRIDIUM_CHANNEL_SAMPLE_RATE / ACARSIRIDIUM_SYMBOL_RATE)
// A burst is nominally 8.28 ms, which is about 207 symbols, and a simplex burst about
// 20.6 ms. Accept a generous range either side: anything far outside it is interference
#define ACARSIRIDIUM_MIN_BURST_SYMBOLS 40
#define ACARSIRIDIUM_MAX_BURST_SYMBOLS 640
// From gr-iridium lib/iridium.h, which is the reference these were checked against.
// The unique word was then found at zero symbol error in 11 of 18 bursts of a recording
// of the ring alert channel, at symbol 66 every time - the 64 symbol preamble plus the
// two samples the burst detector picks up ahead of it
#define ACARSIRIDIUM_UW_LENGTH 12
#define ACARSIRIDIUM_PREAMBLE_SHORT 16 // Duplex
#define ACARSIRIDIUM_PREAMBLE_LONG 64 // Simplex, above 1626 MHz
// How far either side of the expected position the unique word is looked for, and how
// many of its symbols may be wrong before the burst is treated as having no sync.
//
// The window has to be tight, because the search is over two preamble lengths, two
// directions and four rotations, which is a lot of chances to match by luck: allowing two
// errors over a 24 symbol window gives roughly a one in ten chance of a false match on
// any burst, measured on a traffic channel recording where it produced 18 spurious syncs
// at scattered positions against 12 real ones. Over 8 symbols it is below one in a
// hundred, and a false sync is then thrown out by the BCH check in the frame layer, which
// is a far stronger test than the unique word - which is why two errors are allowed here.
// On a ring alert recording the bursts that need the second error are the ones at 10 to
// 18 dB; the strong ones match with no errors at all
#define ACARSIRIDIUM_UW_SEARCH 8
#define ACARSIRIDIUM_UW_MAX_ERRORS 2
// Root raised cosine matched filter, as gr-iridium designs it in burst_downmix_impl.cc:
//
// root_raised_cosine(1.0, d_output_sample_rate, SYMBOLS_PER_SECOND, .4, 51)
//
// Without it the preamble still demodulates perfectly, because it is one symbol repeated
// and so has no transitions to smear, but the data symbols that follow are corrupted by
// intersymbol interference. That showed up as bursts whose preamble was a clean run of
// zero differential symbols and whose unique word then failed to match
#define ACARSIRIDIUM_RRC_ALPHA 0.4
#define ACARSIRIDIUM_RRC_TAPS 51
// How much of the burst the coarse frequency estimate uses, in symbols. gr-iridium sizes
// its estimation FFT as PREAMBLE_LENGTH_SHORT + 10, which covers the whole short preamble
// plus the first symbols of the unique word, and for a long preamble is all preamble. The
// unique word is only symbols 0 and 2, so squaring the signal removes it as well as the
// preamble, leaving a single tone at twice the frequency offset
#define ACARSIRIDIUM_CFO_SYMBOLS (ACARSIRIDIUM_PREAMBLE_SHORT + 10)
class AcarsIridiumReceiver
{
public:
typedef std::complex<double> Cd;
enum Direction
{
DirectionUnknown = 0,
DirectionDownlink, //!< Satellite to ground, which is what is heard
DirectionUplink
};
struct Burst
{
qint64 m_sampleIndex = 0; //!< Where the burst started, in channel samples
double m_frequencyOffset = 0.0; //!< Hz from the centre of the channel, mostly Doppler
double m_coarseOffset = 0.0; //!< The preamble only estimate, before refinement
double m_snrDb = 0.0;
double m_powerDb = 0.0;
int m_symbolCount = 0;
std::vector<uint8_t> m_symbols; //!< Differential symbol, 0 to 3, rotation not removed
// Filled in when the unique word is found
Direction m_direction = DirectionUnknown;
int m_uwPosition = -1; //!< Index in m_symbols where the unique word starts
int m_uwErrors = 0;
int m_rotation = 0; //!< Quarter turns of residual frequency error removed
//!< The frame, as the bits the frame layer works on: two per differential symbol,
//!< Gray coded, starting with the 24 bit access code. Empty when there is no sync
std::vector<uint8_t> m_frameBits;
};
// Detection thresholds, as ratios against the noise floor. The end one is lower than
// the start one so a fade within a burst does not chop it in two. Public because
// AcarsIridiumDetectorBank applies the same test across a bank of channels and has
// to be given the same numbers
static constexpr double StartThreshold = 8.0;
static constexpr double EndThreshold = 3.0;
static const int StartSamples = 8;
static const int EndSamples = 16;
static const int PreTriggerLength = 16;
AcarsIridiumReceiver()
{
designRrc();
reset();
}
void reset()
{
m_sampleIndex = 0;
m_burstStart = 0;
m_noiseFloor = 0.0;
m_noiseValid = false;
m_inBurst = false;
m_belowCount = 0;
m_aboveCount = 0;
m_smoothedPower = 0.0;
m_preTrigger.assign(PreTriggerLength, Cd(0.0, 0.0));
m_preTriggerWrite = 0;
m_preTriggerCount = 0;
m_burstSamples.clear();
// Reserved once rather than grown: the band scanner runs one of these per channel,
// so a reallocation here is a reallocation a couple of hundred times over
m_burstSamples.reserve(ACARSIRIDIUM_MAX_BURST_SYMBOLS * ACARSIRIDIUM_SAMPLES_PER_SYMBOL);
m_bursts.clear();
m_burstCount = 0;
m_rejectedCount = 0;
}
//! Two bits per differential symbol, Gray coded. The de_dqpsk() function in
//! iridium-toolkit reads the bit pair as a number and maps it through
//! imap[] = { 0, 1, 3, 2 } to recover the symbol, and that map is its own inverse, so
//! the same table encodes. It is what makes the differential form of the downlink
//! unique word come out as the access code "001100000011000011110011"
static uint8_t grayMap(uint8_t symbol)
{
static const uint8_t imap[4] = { 0, 1, 3, 2 };
return imap[symbol & 3];
}
//! Feeds one channel sample. Returns true when a burst has been completed and is
//! waiting to be popped
bool processSample(const Cd& sample)
{
const double power = std::norm(sample);
// Short smoothing, so one noisy sample neither starts nor ends a burst
m_smoothedPower += (power - m_smoothedPower) * 0.25;
if (!m_inBurst)
{
// The noise floor only tracks while nothing is being received: a long burst
// would otherwise drag it up and the burst would end early
if (!m_noiseValid)
{
m_noiseFloor = m_smoothedPower;
m_noiseValid = true;
}
else
{
m_noiseFloor += (m_smoothedPower - m_noiseFloor) * 0.0001;
}
if (m_smoothedPower > (m_noiseFloor * StartThreshold))
{
m_aboveCount++;
if (m_aboveCount >= StartSamples)
{
m_inBurst = true;
m_belowCount = 0;
m_burstStart = m_sampleIndex - (qint64) m_preTriggerCount;
m_burstSamples.clear();
// The samples from before the detector fired are part of the burst,
// and the preamble they hold is what the frequency estimate needs.
// Oldest first, which with a ring is wherever the next write would go
for (int i = 0; i < m_preTriggerCount; i++)
{
const int index = (m_preTriggerWrite + PreTriggerLength - m_preTriggerCount + i)
% PreTriggerLength;
m_burstSamples.push_back(m_preTrigger[index]);
}
}
}
else
{
m_aboveCount = 0;
}
}
else
{
m_burstSamples.push_back(sample);
if (m_smoothedPower < (m_noiseFloor * EndThreshold))
{
m_belowCount++;
if (m_belowCount >= EndSamples)
{
endBurst();
m_inBurst = false;
m_aboveCount = 0;
}
}
else
{
m_belowCount = 0;
}
if ((int) m_burstSamples.size() > (ACARSIRIDIUM_MAX_BURST_SYMBOLS * ACARSIRIDIUM_SAMPLES_PER_SYMBOL))
{
// Not a burst: something is transmitting continuously, so drop it and
// let the noise floor re-converge rather than growing the buffer for ever
m_burstSamples.clear();
m_inBurst = false;
m_aboveCount = 0;
m_noiseValid = false;
m_rejectedCount++;
}
}
m_preTrigger[m_preTriggerWrite] = sample;
m_preTriggerWrite = (m_preTriggerWrite + 1) % PreTriggerLength;
if (m_preTriggerCount < PreTriggerLength) {
m_preTriggerCount++;
}
m_sampleIndex++;
return !m_bursts.empty();
}
// Burst handling driven by AcarsIridiumDetectorBank, which holds the detection
// state for a whole bank of channels instead of one receiver at a time. These do the
// same things, in the same order, as the branches of processSample() above - that
// path stays for a receiver watching a single channel, and for the tests
//! Begins a burst. The caller then seeds burstSamples() with the pre-trigger history
void beginBurst(qint64 burstStart)
{
m_burstStart = burstStart;
m_burstSamples.clear();
}
//! The samples this burst is made of, so the bank can seed it with the history it
//! holds rather than this keeping a ring of its own
std::vector<Cd>& burstSamples() { return m_burstSamples; }
//! Takes one more sample. Returns true when the burst has outgrown anything a burst
//! can be, which means something is transmitting continuously rather than in bursts
bool appendBurst(const Cd& sample)
{
m_burstSamples.push_back(sample);
if ((int) m_burstSamples.size() > (ACARSIRIDIUM_MAX_BURST_SYMBOLS * ACARSIRIDIUM_SAMPLES_PER_SYMBOL))
{
m_burstSamples.clear();
m_rejectedCount++;
return true;
}
return false;
}
//! Decodes what has been collected. The noise floor comes from the bank, because
//! that is what tracked it, and the burst's signal to noise is measured against it
void finishBurst(double noiseFloor)
{
m_noiseFloor = noiseFloor;
endBurst();
}
bool hasBurst() const { return !m_bursts.empty(); }
Burst popBurst()
{
Burst burst = m_bursts.front();
m_bursts.pop_front();
return burst;
}
int burstCount() const { return m_burstCount; }
int rejectedCount() const { return m_rejectedCount; }
double noiseFloor() const { return m_noiseFloor; }
private:
//! Root raised cosine taps, by the root_raised_cosine function in GNU Radio firdes,
//! so the matched filter is the same one gr-iridium uses
void designRrc()
{
const int ntaps = ACARSIRIDIUM_RRC_TAPS | 1;
const double alpha = ACARSIRIDIUM_RRC_ALPHA;
const double spb = (double) ACARSIRIDIUM_SAMPLES_PER_SYMBOL;
m_rrc.resize(ntaps);
double scale = 0.0;
for (int i = 0; i < ntaps; i++)
{
const double index = (double) (i - (ntaps / 2));
const double x1 = M_PI * index / spb;
double x2 = 4.0 * alpha * index / spb;
double x3 = (x2 * x2) - 1.0;
double num;
double den;
if (std::fabs(x3) >= 0.000001)
{
if (i != (ntaps / 2)) {
num = std::cos((1.0 + alpha) * x1) + (std::sin((1.0 - alpha) * x1) / (4.0 * alpha * index / spb));
} else {
num = std::cos((1.0 + alpha) * x1) + ((1.0 - alpha) * M_PI / (4.0 * alpha));
}
den = x3 * M_PI;
}
else
{
// The removable singularity, where index is plus or minus spb / (4 alpha)
x3 = (1.0 - alpha) * x1;
x2 = (1.0 + alpha) * x1;
num = (std::sin(x2) * (1.0 + alpha) * M_PI)
- (std::cos(x3) * ((1.0 - alpha) * M_PI * spb) / (4.0 * alpha * index))
+ (std::sin(x3) * spb * spb / (4.0 * alpha * index * index));
den = -32.0 * M_PI * alpha * alpha * index / spb;
}
m_rrc[i] = 4.0 * alpha * num / den;
scale += m_rrc[i];
}
for (int i = 0; i < ntaps; i++) {
m_rrc[i] /= scale;
}
}
//! Matched filter, with the group delay taken out so an output sample lines up with
//! the input sample of the same index and the unique word stays where it was found
std::vector<Cd> matchedFilter(const std::vector<Cd>& samples) const
{
const int ntaps = (int) m_rrc.size();
const int centre = ntaps / 2;
const int length = (int) samples.size();
std::vector<Cd> out(length);
for (int i = 0; i < length; i++)
{
Cd sum(0.0, 0.0);
for (int k = 0; k < ntaps; k++)
{
const int index = i + k - centre;
if ((index >= 0) && (index < length)) {
sum += samples[index] * m_rrc[k];
}
}
out[i] = sum;
}
return out;
}
//! Magnitude of the tone at power times offset, which is how the fine frequency
//! estimate below scores a candidate. The phasor is stepped rather than recomputed,
//! because this is searched over hundreds of candidates for every burst
double toneMagnitude(const std::vector<Cd>& raised, int power, double offset, int length) const
{
const double w = -2.0 * M_PI * ((double) power * offset) / ACARSIRIDIUM_CHANNEL_SAMPLE_RATE;
const Cd step = std::exp(Cd(0.0, w));
Cd phasor(1.0, 0.0);
Cd sum(0.0, 0.0);
for (int i = 0; i < length; i++)
{
sum += raised[i] * phasor;
phasor *= step;
}
return std::abs(sum);
}
//! Where the burst actually sits in the channel, from its power spectrum.
//!
//! This exists only to settle which alias the estimates below have landed on, and is
//! the one step in the chain that cannot be ambiguous. Raising the signal to a power
//! to strip the modulation also folds the frequency axis: squaring leaves the offset
//! known only modulo half the sample rate, and the fourth power modulo a quarter of
//! it. Neither fold matters to differential demodulation, because an offset that is a
//! whole number of symbol rates advances the phase by a whole turn per symbol, which
//! is why this went unnoticed until the matched filter was added. It matters a great
//! deal to the matched filter, which would otherwise be centred up to 50 kHz away
//! from the signal - at this sample rate, on the far side of Nyquist.
//!
//! The score is the power a matched filter centred on the candidate would pass, so
//! the whole occupied bandwidth votes rather than any single bin
double estimateFrequencyCentre(const std::vector<Cd>& samples)
{
const int length = (int) samples.size();
const double rate = ACARSIRIDIUM_CHANNEL_SAMPLE_RATE;
// The spectrum from a transform rather than a bin at a time. Scoring each
// candidate separately meant a pass over the whole burst per candidate, which for
// a few hundred candidates is most of the cost of handling a burst - and with the
// whole band being scanned there are a great many bursts
const int size = AcarsIridiumFft::nextPowerOfTwo(std::max(length, 1024));
m_fft.configure(size);
std::vector<Cd> spectrum(size, Cd(0.0, 0.0));
for (int i = 0; i < length; i++) {
spectrum[i] = samples[i];
}
m_fft.transform(spectrum);
// A 25 kbaud signal shaped at alpha 0.4 occupies about 35 kHz, so a filter centred
// on the signal passes roughly 17.5 kHz either side. The score for a candidate is
// how much power such a filter would pass, so the whole occupied bandwidth votes
const double binHz = rate / (double) size;
const int half = (int) std::lround(17500.0 / binHz);
// Running totals, so each candidate costs a subtraction rather than a sweep over
// its whole bandwidth
std::vector<double> prefix(size + 1, 0.0);
for (int k = 0; k < size; k++) {
prefix[k + 1] = prefix[k] + std::norm(spectrum[k]);
}
const double total = prefix[size];
int bestBin = 0;
double bestPower = -1.0;
for (int c = 0; c < size; c++)
{
const int from = c - half;
const int to = c + half + 1;
double sum;
if ((from >= 0) && (to <= size))
{
sum = prefix[to] - prefix[from];
}
else
{
// The spectrum is periodic at the sample rate, so a candidate near the
// edge takes the rest of its bandwidth from the other end
const int lo = ((from % size) + size) % size;
const int hi = ((to % size) + size) % size;
sum = (total - prefix[lo]) + prefix[hi];
}
if (sum > bestPower)
{
bestPower = sum;
bestBin = c;
}
}
return ((bestBin < (size / 2)) ? (double) bestBin : (double) (bestBin - size)) * binHz;
}
//! Fine frequency from the whole burst, raised to the fourth power so the QPSK data
//! cancels as well as the preamble, and read off a transform of the result.
//!
//! The fourth power puts a tone at four times the frequency offset, and its peak is
//! only about 1/T wide - some tens of Hz for a burst this long. Searching for it by
//! scoring candidate offsets one at a time therefore needs a step of a few Hz over
//! the whole range, which is thousands of passes over the burst: with a few hundred
//! channels being scanned at once that was most of the time the scanner spent, and
//! coarsening the step simply steps over the peak and misses it. A transform gives
//! every candidate at once instead.
//!
//! The result is still ambiguous - a tone at four times the offset repeats every
//! quarter of the sample rate - so the answer taken is the one nearest the coarse
//! estimate, which is what that estimate is for
double estimateFrequencyFine(const std::vector<Cd>& samples, double coarse)
{
const int length = (int) samples.size();
const double rate = ACARSIRIDIUM_CHANNEL_SAMPLE_RATE;
// Sized to the burst rather than fixed. A burst defines its own frequency only to
// about 1 / (4T), which is 30 Hz for a short duplex burst, and the bin spacing
// here is rate / (4 * size) - so a transform the length of the burst already
// resolves it as finely as it can be resolved, and the interpolation below picks
// up the rest. Padding every burst out to a fixed large size was eight times the
// work for the short ones, which are most of them
const int size = AcarsIridiumFft::nextPowerOfTwo(std::max(length, 1024));
m_fft.configure(size);
std::vector<Cd> fourth(size, Cd(0.0, 0.0));
for (int i = 0; i < length; i++)
{
const Cd s2 = samples[i] * samples[i];
fourth[i] = s2 * s2;
}
m_fft.transform(fourth);
// One alias of the fourth power tone every quarter of the sample rate
const double aliasHz = rate / 4.0;
const double searchHz = aliasHz / 2.0;
int bestBin = -1;
double bestMagnitude = -1.0;
double best = coarse;
for (int k = 0; k < size; k++)
{
// Bin to the frequency of the tone, then to the offset that produced it
const double tone = ((k < (size / 2)) ? (double) k : (double) (k - size)) * rate / (double) size;
double offset = tone / 4.0;
// Slide to whichever alias sits nearest the coarse estimate
offset += std::round((coarse - offset) / aliasHz) * aliasHz;
if (std::fabs(offset - coarse) > searchHz) {
continue;
}
const double magnitude = std::norm(fourth[k]);
if (magnitude > bestMagnitude)
{
bestMagnitude = magnitude;
bestBin = k;
best = offset;
}
}
if (bestBin < 0) {
return coarse;
}
// Parabolic interpolation between the neighbouring bins, so the answer is not
// limited to the bin spacing
const double left = std::abs(fourth[(bestBin - 1 + size) % size]);
const double centre = std::abs(fourth[bestBin]);
const double right = std::abs(fourth[(bestBin + 1) % size]);
const double denominator = left - (2.0 * centre) + right;
if (std::fabs(denominator) > 1e-20)
{
const double shift = 0.5 * (left - right) / denominator;
if (std::fabs(shift) <= 1.0) {
best += shift * rate / (4.0 * (double) size);
}
}
return best;
}
//! Symbol timing by Oerder and Meyr: the squared magnitude carries a line at the
//! symbol rate, and its phase is the timing offset within a symbol.
//!
//! Mind the sign. If the squared magnitude peaks a fraction tau of the way into each
//! symbol, the sum below comes out proportional to e^(-j 2 pi tau / sps), so the
//! offset is MINUS its phase. Taking the phase as it stands gives -tau mod sps, which
//! is only right when tau happens to be zero or half a symbol - anywhere else it
//! samples as far the wrong side of the peak as the peak is from the symbol start
double estimateTiming(const std::vector<Cd>& samples) const
{
const int sps = ACARSIRIDIUM_SAMPLES_PER_SYMBOL;
Cd sum(0.0, 0.0);
// The phase only takes as many values as there are samples in a symbol, so a
// small table replaces a transcendental per sample
Cd rotations[ACARSIRIDIUM_SAMPLES_PER_SYMBOL];
for (int i = 0; i < sps; i++)
{
const double w = -2.0 * M_PI * (double) i / (double) sps;
rotations[i] = Cd(std::cos(w), std::sin(w));
}
int slot = 0;
for (size_t i = 0; i < samples.size(); i++)
{
sum += std::norm(samples[i]) * rotations[slot];
if (++slot == sps) {
slot = 0;
}
}
// Negated, as above, then wrapped into [0, 2 pi) so the offset is in [0, sps)
double phase = -std::arg(sum);
if (phase < 0.0) {
phase += 2.0 * M_PI;
}
return (phase / (2.0 * M_PI)) * (double) sps;
}
//! The unique words, as gr-iridium gives them: absolute symbols, only 0 and 2, so
//! the sync is effectively BPSK within the QPSK constellation
static const uint8_t *uniqueWord(Direction direction)
{
static const uint8_t downlink[ACARSIRIDIUM_UW_LENGTH] = { 0, 2, 2, 2, 2, 0, 0, 0, 2, 0, 0, 2 };
static const uint8_t uplink[ACARSIRIDIUM_UW_LENGTH] = { 2, 2, 0, 0, 0, 2, 0, 0, 2, 0, 2, 2 };
return (direction == DirectionUplink) ? uplink : downlink;
}
//! Looks for a unique word in the differential symbols and, when one is found, emits
//! the frame bit stream from it onwards.
//!
//! The search allows for a residual frequency error of a multiple of a quarter of the
//! symbol rate, which leaves a fixed quarter turn on every symbol and so adds a
//! constant to every differential symbol. Trying all four rotations resolves it
void findUniqueWord(Burst& burst) const
{
if (burst.m_symbolCount < (ACARSIRIDIUM_PREAMBLE_SHORT + ACARSIRIDIUM_UW_LENGTH)) {
return;
}
// A simplex burst carries the long preamble, a duplex burst the short one. Which
// this is depends on the frequency, which the receiver does not know, so both
// are looked for
const int expected[2] = { ACARSIRIDIUM_PREAMBLE_LONG, ACARSIRIDIUM_PREAMBLE_SHORT };
int bestErrors = ACARSIRIDIUM_UW_MAX_ERRORS + 1;
int bestPosition = -1;
int bestRotation = 0;
Direction bestDirection = DirectionUnknown;
for (int d = 0; d < 2; d++)
{
const Direction direction = (d == 0) ? DirectionDownlink : DirectionUplink;
const uint8_t *uw = uniqueWord(direction);
// The differential form of the unique word, which is what the symbols are
uint8_t wanted[ACARSIRIDIUM_UW_LENGTH - 1];
for (int i = 1; i < ACARSIRIDIUM_UW_LENGTH; i++) {
wanted[i-1] = (uint8_t) ((4 + uw[i] - uw[i-1]) % 4);
}
for (int p = 0; p < 2; p++)
{
for (int offset = -ACARSIRIDIUM_UW_SEARCH; offset <= ACARSIRIDIUM_UW_SEARCH; offset++)
{
// One differential symbol before the unique word is part of the access
// code, so the frame cannot start at symbol zero
const int start = expected[p] + offset;
if ((start < 1) || ((start + ACARSIRIDIUM_UW_LENGTH - 1) > burst.m_symbolCount)) {
continue;
}
for (int rotation = 0; rotation < 4; rotation++)
{
int errors = 0;
for (int i = 0; i < (ACARSIRIDIUM_UW_LENGTH - 1); i++)
{
if (burst.m_symbols[start + i] != ((wanted[i] + rotation) % 4))
{
errors++;
if (errors >= bestErrors) {
break;
}
}
}
if (errors < bestErrors)
{
bestErrors = errors;
bestPosition = start;
bestRotation = rotation;
bestDirection = direction;
}
}
}
}
}
if (bestPosition < 0) {
return;
}
burst.m_direction = bestDirection;
burst.m_uwPosition = bestPosition;
burst.m_uwErrors = bestErrors;
burst.m_rotation = bestRotation;
// The access code is the twelve differential symbols ending with the eleven of
// the unique word. The one before them is the step from the last preamble symbol
// into the unique word, and because the preamble is symbol 0 repeated and the
// downlink unique word also starts at symbol 0 it is a step of nothing - which is
// why the access code begins with two zero bits
for (int i = bestPosition - 1; i < burst.m_symbolCount; i++)
{
const uint8_t symbol = (uint8_t) ((4 + burst.m_symbols[i] - bestRotation) % 4);
const uint8_t mapped = grayMap(symbol);
burst.m_frameBits.push_back((uint8_t) ((mapped >> 1) & 1));
burst.m_frameBits.push_back((uint8_t) (mapped & 1));
}
}
void endBurst()
{
const int sps = ACARSIRIDIUM_SAMPLES_PER_SYMBOL;
const int symbols = (int) m_burstSamples.size() / sps;
if ((symbols < ACARSIRIDIUM_MIN_BURST_SYMBOLS) || (symbols > ACARSIRIDIUM_MAX_BURST_SYMBOLS))
{
m_rejectedCount++;
m_burstSamples.clear();
return;
}
Burst burst;
burst.m_sampleIndex = m_burstStart;
burst.m_coarseOffset = estimateFrequencyCentre(m_burstSamples);
burst.m_frequencyOffset = estimateFrequencyFine(m_burstSamples, burst.m_coarseOffset);
// De-rotate by the estimated offset, so what is left is the modulation
std::vector<Cd> corrected(m_burstSamples.size());
const double w = -2.0 * M_PI * burst.m_frequencyOffset / ACARSIRIDIUM_CHANNEL_SAMPLE_RATE;
double power = 0.0;
// Stepped rather than computed per sample: this used to be a transcendental for
// every sample of every burst, and when the whole band is scanned there are a
// great many bursts. The phasor is renormalised every so often, because repeated
// multiplication lets its magnitude drift
const Cd step(std::cos(w), std::sin(w));
Cd phasor(1.0, 0.0);
for (size_t i = 0; i < m_burstSamples.size(); i++)
{
corrected[i] = m_burstSamples[i] * phasor;
power += std::norm(m_burstSamples[i]);
phasor *= step;
if ((i & 0xff) == 0xff) {
phasor /= std::abs(phasor);
}
}
power /= (double) m_burstSamples.size();
burst.m_powerDb = 10.0 * std::log10(power + 1e-20);
burst.m_snrDb = 10.0 * std::log10((power / (m_noiseFloor + 1e-20)) + 1e-20);
// Matched filter, now the burst is centred. Doing it after the de-rotation rather
// than before is what lets the filter be centred on the signal
const std::vector<Cd> filtered = matchedFilter(corrected);
const double timing = estimateTiming(filtered);
// Differential demodulation: each symbol is the phase STEP from the one before,
// which is what lets a burst be read without ever knowing absolute phase, and is
// why the frequency estimate above only has to be good enough to stop the phase
// walking within a single symbol
Cd previous(0.0, 0.0);
bool havePrevious = false;
for (int s = 0; s < symbols; s++)
{
const int index = (int) std::lround((double) (s * sps) + timing);
if ((index < 0) || (index >= (int) filtered.size())) {
continue;
}
const Cd sample = filtered[index];
if (havePrevious)
{
const Cd difference = sample * std::conj(previous);
double angle = std::arg(difference);
if (angle < 0.0) {
angle += 2.0 * M_PI;
}
const int quadrant = ((int) std::floor((angle + (M_PI / 4.0)) / (M_PI / 2.0))) & 3;
burst.m_symbols.push_back((uint8_t) quadrant);
}
previous = sample;
havePrevious = true;
}
burst.m_symbolCount = (int) burst.m_symbols.size();
findUniqueWord(burst);
if (burst.m_symbolCount >= ACARSIRIDIUM_MIN_BURST_SYMBOLS)
{
m_bursts.push_back(burst);
m_burstCount++;
}
else
{
m_rejectedCount++;
}
m_burstSamples.clear();
}
std::vector<double> m_rrc;
AcarsIridiumFft m_fft;
qint64 m_sampleIndex;
qint64 m_burstStart;
double m_noiseFloor;
bool m_noiseValid;
double m_smoothedPower;
bool m_inBurst;
int m_aboveCount;
int m_belowCount;
std::vector<Cd> m_preTrigger;
int m_preTriggerWrite;
int m_preTriggerCount;
std::vector<Cd> m_burstSamples;
std::deque<Burst> m_bursts;
int m_burstCount;
int m_rejectedCount;
};
#endif // INCLUDE_ACARSIRIDIUM_H

443
plugins/channelrx/demodacars/acarsiridiumchannelizer.h

@ -0,0 +1,443 @@ @@ -0,0 +1,443 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUMCHANNELIZER_H
#define INCLUDE_ACARSIRIDIUMCHANNELIZER_H
#include <complex>
#include <cmath>
#include <cstdint>
#include <algorithm>
#include <vector>
#if defined(USE_SSE4_1)
#include <smmintrin.h>
#endif
#include "acarsiridiumfft.h"
// Oversampled polyphase channelizer, so one Iridium receiver can watch the whole band.
//
// Iridium hops: a duplex channel is assigned when a call is set up, and over 240 channels
// spaced 41.67 kHz across roughly 1619 to 1626 MHz. Watching one 125 kHz channel sees
// only a few percent of the traffic - measured on a four minute recording, the busiest
// single channel carried 4% of the short burst data frames in the band. Covering it all
// with one demodulator per channel would mean dozens of them, so the band is split here
// instead, in one pass, and a receiver run on every output.
//
// A plain filter bank decimates by the number of channels, which puts the output rate
// equal to the channel spacing and leaves no room for a signal that does not sit exactly
// in the middle of its channel. This one decimates by a quarter of that, so each output
// runs at four times the channel spacing:
//
// channels M, decimate by D = M / 4, so the output rate is 4 * inputRate / M
//
// The channel spacing is then inputRate / M and the output rate four times it. At
// 31.25 kHz spacing and 125 kHz out, an Iridium burst - about 35 kHz wide, and up to
// 37 kHz off its nominal frequency once Doppler has had its way - is always wholly
// inside at least one output. It is often inside two, so the scanner above this has to
// throw the duplicates away.
//
// Oversampling by a whole number of channels is what keeps this simple: decimating by
// M / 4 rather than M leaves a phase step between output blocks of a quarter turn per
// channel per block, which is a power of -j and so costs nothing to apply.
//! The transform the bank runs on each block, so that a faster one can be put behind it.
//!
//! The built-in radix 2 is what keeps the channelizer self contained, which is what lets
//! the offline harnesses in test/ build against Qt alone. It is also the single largest
//! thing the bank spends its time on - measured against FFTW on the same 256 point
//! transform it is over five times slower - so the plugin, which has sdrbase, installs
//! SDRangel's FFT engine instead
class AcarsIridiumTransform
{
public:
virtual ~AcarsIridiumTransform() {}
//! Always the inverse transform, unscaled, which is what the bank wants
virtual void configure(int size) = 0;
virtual void transform(std::vector<std::complex<double>>& data) = 0;
};
class AcarsIridiumChannelizer
{
public:
typedef std::complex<double> Cd;
//! How much each channel is oversampled: the output rate is this many times the
//! channel spacing. Four leaves room for a burst anywhere in its channel
static const int Oversample = 4;
AcarsIridiumChannelizer() :
m_channels(0),
m_decimation(0),
m_tapsPerBranch(0),
m_length(0),
m_write(0),
m_count(0),
m_block(0)
{
}
//! Puts a different transform behind the bank. Must be called before configure, and
//! the caller keeps ownership. Passing nullptr goes back to the built-in one
void setTransform(AcarsIridiumTransform *transform)
{
m_transform = transform ? transform : &m_builtIn;
}
//! channels must be a power of two and a multiple of Oversample. The input rate has
//! to be channels * spacing, and for Iridium the spacing wanted is 31.25 kHz, so
//! 8 MS/s gives 256 channels, 4 MS/s gives 128, and so on.
//!
//! The taps per branch set what the filtering costs: the work is the input rate times
//! the oversampling times this, and nothing else - the channel count cancels out. It
//! was twelve, which left the prototype far better than it needs to be. At eight it
//! still has 70 dB beyond the output Nyquist, which is what folds back, and reaches
//! 60 dB by 1.28 channel spacings against the two that are available. The cost of
//! going lower is not aliasing but a softer channel edge, which lets more of a burst
//! into its neighbours: measured on two recordings, eight finds slightly more bursts
//! than twelve and rather more of them are duplicates of each other
void configure(int channels, int tapsPerBranch = 8)
{
m_channels = channels;
m_decimation = channels / Oversample;
m_tapsPerBranch = tapsPerBranch;
m_length = channels * tapsPerBranch;
designPrototype();
m_delay.assign(m_length, Cd(0.0, 0.0));
m_out.assign(m_channels, Cd(0.0, 0.0));
m_write = 0;
m_count = 0;
m_block = 0;
m_transform->configure(channels);
buildRotations();
}
int channels() const { return m_channels; }
int decimation() const { return m_decimation; }
//! Channel spacing, which is also how far apart the channel centres below are
double spacing(double inputRate) const { return inputRate / (double) m_channels; }
//! Output sample rate of every channel
double channelRate(double inputRate) const { return inputRate / (double) m_decimation; }
//! Where channel c sits relative to the centre of the band, in Hz. The upper half of
//! the channels are the negative frequencies, as they are in any transform
double channelOffset(int c, double inputRate) const
{
const double step = spacing(inputRate);
return (c < (m_channels / 2)) ? (c * step) : ((c - m_channels) * step);
}
//! Feeds one input sample. Returns true when a block of channel samples is ready,
//! one per channel, in channelSamples()
bool processSample(const Cd& sample)
{
m_delay[m_write] = sample;
// A conditional wrap, not a modulo: m_length is a member, so the compiler cannot
// turn the division into a multiply, and this runs once per input sample - eight
// million times a second at the widest setting
if (++m_write == m_length) {
m_write = 0;
}
m_count++;
if (m_count < m_decimation) {
return false;
}
m_count = 0;
computeBlock();
return true;
}
const std::vector<Cd>& channelSamples() const { return m_out; }
//! The prototype lowpass the bank is built from. Exposed so a test can filter a
//! channel directly with the same taps and check the bank against it
const std::vector<double>& prototype() const { return m_proto; }
private:
//! Prototype lowpass, Kaiser windowed sinc.
//!
//! The cutoff is a little wider than the channel spacing, so that a burst sitting
//! between two channel centres is still passed whole by one of them. That makes
//! neighbouring channels overlap, which is why the same burst can be found twice.
//! The stopband has to be inside the output Nyquist - two channel spacings away with
//! this much oversampling - or what is rejected would fold back in
void designPrototype()
{
const int taps = m_length;
const double cutoff = 1.05 / (double) m_channels; // Cycles per input sample
const double beta = 0.1102 * (60.0 - 8.7); // Kaiser, for 60 dB stopband
m_proto.assign(taps, 0.0);
double sum = 0.0;
for (int n = 0; n < taps; n++)
{
const double x = (double) n - ((double) (taps - 1) / 2.0);
const double sinc = (std::fabs(x) < 1e-12)
? (2.0 * cutoff)
: (std::sin(2.0 * M_PI * cutoff * x) / (M_PI * x));
const double t = ((2.0 * (double) n) / (double) (taps - 1)) - 1.0;
const double window = besselI0(beta * std::sqrt(std::max(0.0, 1.0 - (t * t)))) / besselI0(beta);
m_proto[n] = sinc * window;
sum += m_proto[n];
}
// Unit gain at DC, so a channel output has the same amplitude as its input
for (int n = 0; n < taps; n++) {
m_proto[n] *= (double) m_channels / sum;
}
}
static double besselI0(double x)
{
double sum = 1.0;
double term = 1.0;
for (int k = 1; k < 40; k++)
{
term *= (x * x) / (4.0 * (double) k * (double) k);
sum += term;
if (term < (1e-16 * sum)) {
break;
}
}
return sum;
}
void buildRotations()
{
// The phase each channel output carries, as a table indexed by the block counter
// and the channel.
//
// Decimating by M / Oversample rather than by M leaves a step of
// exp(-j2.pi.c.r / Oversample) on channel c at block r, which repeats every
// Oversample blocks. On top of that the first block is emitted once D samples
// have arrived, so it corresponds to input sample D - 1 rather than 0, and that
// offset puts a further constant exp(-j2.pi.c.(D - 1) / M) on each channel.
// Differential demodulation would not notice a constant phase, but folding it in
// costs nothing and makes a channel output exactly what mixing that channel down
// and filtering it would have given - which is what the test checks against
m_rotation.assign(Oversample * m_channels, Cd(0.0, 0.0));
for (int r = 0; r < Oversample; r++)
{
for (int c = 0; c < m_channels; c++)
{
const double angle = -2.0 * M_PI * (double) c
* (((double) (r * m_decimation)) + (double) (m_decimation - 1))
/ (double) m_channels;
m_rotation[(r * m_channels) + c] = Cd(std::cos(angle), std::sin(angle));
}
}
}
//! out[i] += in[-i] * h[i], for a run of i. The input walks backwards, because branch
//! p of the bank takes the sample p further back down the delay line, and the run has
//! already been cut so that neither side crosses the end of the buffer.
//!
//! A complex double is exactly one 128 bit register, so a vector unit does the
//! multiply and the add on the real and imaginary parts together rather than one
//! after the other. Two runs are kept going at once because each is a chain of
//! dependent adds, and one chain on its own leaves the pipeline waiting on itself
//! One chunk of channels, all taps, with the sums held in registers.
//!
//! The other way round - one tap across every channel, which is what this did - has
//! to read and write the output array once per tap, so a complex multiply and add
//! costs three loads and a store. Holding a chunk's sums across all the taps leaves
//! two loads and nothing else, and the output is written once.
//!
//! Every bound here is the constant, never a variable count, so that the loops unroll
//! and the accumulators become registers. Written with a runtime chunk length instead
//! this was 30% SLOWER than the version it replaced, because the array of sums went
//! on the stack and the loads and stores came straight back
void accumulateChunk(int p, int newest)
{
#if defined(USE_SSE4_1)
__m128d acc[ChunkChannels];
for (int i = 0; i < ChunkChannels; i++) {
acc[i] = _mm_setzero_pd();
}
for (int q = 0; q < m_tapsPerBranch; q++)
{
// Branch p reads the sample this far back, and within the chunk the index
// walks backwards one per channel
int index = newest - (q * m_channels) - p;
while (index < 0) {
index += m_length;
}
const double *tap = &m_proto[(q * m_channels) + p];
if (index >= (ChunkChannels - 1))
{
// The whole chunk is there without the delay line wrapping round
const Cd *in = &m_delay[index];
for (int i = 0; i < ChunkChannels; i++)
{
const __m128d a = _mm_loadu_pd((const double *) (in - i));
acc[i] = _mm_add_pd(acc[i], _mm_mul_pd(a, _mm_set1_pd(tap[i])));
}
}
else
{
// At most one chunk per tap straddles the end of the delay line
for (int i = 0; i < ChunkChannels; i++)
{
int j = index - i;
if (j < 0) {
j += m_length;
}
const __m128d a = _mm_loadu_pd((const double *) &m_delay[j]);
acc[i] = _mm_add_pd(acc[i], _mm_mul_pd(a, _mm_set1_pd(tap[i])));
}
}
}
for (int i = 0; i < ChunkChannels; i++) {
_mm_storeu_pd((double *) &m_out[p + i], acc[i]);
}
#else
Cd acc[ChunkChannels];
for (int i = 0; i < ChunkChannels; i++) {
acc[i] = Cd(0.0, 0.0);
}
for (int q = 0; q < m_tapsPerBranch; q++)
{
int index = newest - (q * m_channels) - p;
while (index < 0) {
index += m_length;
}
const double *tap = &m_proto[(q * m_channels) + p];
for (int i = 0; i < ChunkChannels; i++)
{
int j = index - i;
if (j < 0) {
j += m_length;
}
const Cd& sample = m_delay[j];
acc[i] += Cd(sample.real() * tap[i], sample.imag() * tap[i]);
}
}
for (int i = 0; i < ChunkChannels; i++) {
m_out[p + i] = acc[i];
}
#endif
}
void computeBlock()
{
const int newest = (m_write - 1 + m_length) % m_length;
// Each branch filters every Mth sample of the delay line, which is what makes one
// prototype filter serve as the whole bank. Written straight into the output,
// because the transform below is in place and a copy of the whole bank every
// block is megabytes a second for nothing.
//
// A chunk of channels at a time, with every tap applied before moving on. Taking
// one tap across all the channels instead walks all three arrays one element at
// a time, which looks better and was what this did, but it has to read and write
// the output once per tap. Doing it this way the chunk's sums never leave the
// registers and the output is written once, which is also why nothing needs
// zeroing first. What must not be done is a whole branch at a time, which walks
// the delay line and the prototype in strides of a whole channel count - at 256
// channels a 4 kB step per access, which no prefetcher will follow
// The channel count is a power of two and never below the chunk, so every chunk
// is full - which is what lets the loops inside run to a constant bound
for (int p = 0; p < m_channels; p += ChunkChannels)
{
accumulateChunk(p, newest);
}
m_transform->transform(m_out);
// The phase for this block, which is where the oversampling is paid for
const int base = m_block * m_channels;
for (int c = 0; c < m_channels; c++) {
m_out[c] *= m_rotation[base + c];
}
m_block = (m_block + 1) % Oversample;
}
//! Channels whose sums are carried in registers together. Eight complex doubles is
//! eight of the sixteen vector registers, leaving room for the loads and the taps
static const int ChunkChannels = 8;
int m_channels;
int m_decimation;
int m_tapsPerBranch;
int m_length;
int m_write;
int m_count;
int m_block;
std::vector<double> m_proto;
std::vector<Cd> m_delay;
std::vector<Cd> m_out;
std::vector<Cd> m_rotation;
//! The transform the bank actually runs, and the one it falls back on
class BuiltInTransform : public AcarsIridiumTransform
{
public:
void configure(int size) override { m_fft.configure(size); }
void transform(std::vector<Cd>& data) override { m_fft.transform(data, true); }
private:
AcarsIridiumFft m_fft;
};
BuiltInTransform m_builtIn;
AcarsIridiumTransform *m_transform = &m_builtIn;
};
#endif // INCLUDE_ACARSIRIDIUMCHANNELIZER_H

373
plugins/channelrx/demodacars/acarsiridiumdetector.h

@ -0,0 +1,373 @@ @@ -0,0 +1,373 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUMDETECTOR_H
#define INCLUDE_ACARSIRIDIUMDETECTOR_H
#include <QtGlobal>
#include <cmath>
#include <complex>
#include <vector>
#if defined(USE_SSE4_1)
#include <smmintrin.h>
#endif
// Burst detection for a whole bank of channels at once.
//
// Every channel runs the same half dozen arithmetic operations on each of its samples -
// power, a smoothing step, a noise floor step and two comparisons - and at the widest
// setting that is thirty two million of them a second, because the channelizer produces
// four samples per channel for every input sample and there are two hundred and fifty six
// channels. Held one receiver object at a time, that work is slow for a reason that is
// not arithmetic: each block touches a couple of cache lines in each of 256 objects that
// are tens of kilobytes apart, so the whole thing runs at the speed of the cache rather
// than of the adds.
//
// Holding the state as one array per quantity instead puts a block's worth of each in a
// handful of cache lines, and makes the arithmetic something a vector unit can do two
// channels at a time. The samples a burst is made of are not here - those stay with the
// receiver, which is what knows how to demodulate them.
//
// The order of operations within a channel is exactly the order the single channel path
// used, because the two have to agree: the scanner's output is checked against recordings
// frame for frame, and a different rounding order would be a different set of frames.
class AcarsIridiumDetectorBank
{
public:
typedef std::complex<double> Cd;
enum Event
{
Started, //!< A burst began on this channel in this block
Ended //!< It ended, and the receiver should decode what it has
};
struct Change
{
int m_channel;
Event m_event;
};
AcarsIridiumDetectorBank() :
m_channels(0),
m_startThreshold(8.0),
m_endThreshold(3.0),
m_startSamples(8),
m_endSamples(16),
m_preTriggerLength(16),
m_preTriggerWrite(0),
m_preTriggerCount(0),
m_sampleIndex(0)
{
}
//! The thresholds are ratios against the tracked noise floor, and the counts are how
//! many samples either side of one is needed before a burst starts or ends
void configure(int channels, double startThreshold, double endThreshold,
int startSamples, int endSamples, int preTriggerLength)
{
m_channels = channels;
m_startThreshold = startThreshold;
m_endThreshold = endThreshold;
m_startSamples = startSamples;
m_endSamples = endSamples;
m_preTriggerLength = preTriggerLength;
reset();
}
void reset()
{
m_smoothed.assign(m_channels, 0.0);
m_noiseFloor.assign(m_channels, 0.0);
m_noiseValid.assign(m_channels, 0);
m_inBurst.assign(m_channels, 0);
m_aboveCount.assign(m_channels, 0);
m_belowCount.assign(m_channels, 0);
// One ring for the whole bank, holding whole blocks rather than a ring per
// channel, and laid out block first so that a block is written as one run.
//
// The other way round - all of a channel's history together - is the obvious
// layout and is much worse: a block then writes one sample into each channel's
// own stretch, a cache line apart, so at 256 channels it touches 256 lines over
// 64 kB and falls out of L1. That showed up as the detector costing 80% more per
// sample at 256 channels than at 128, while every other stage stayed flat.
// Reading one channel's history is strided instead, but that only happens when a
// burst starts, which is thousands of blocks apart
m_preTrigger.assign((size_t) m_channels * m_preTriggerLength, Cd(0.0, 0.0));
m_preTriggerWrite = 0;
m_preTriggerCount = 0;
m_sampleIndex = 0;
m_burstChannels.clear();
}
//! The index the next block will have, which is what a burst start is measured from
qint64 sampleIndex() const { return m_sampleIndex; }
int preTriggerCount() const { return m_preTriggerCount; }
//! The channels currently receiving a burst, so the caller does not have to look
const std::vector<int>& burstChannels() const { return m_burstChannels; }
bool inBurst(int channel) const { return m_inBurst[channel] != 0; }
//! The tracked noise floor for a channel, which is what a burst's signal to noise is
//! measured against
double noiseFloor(int channel) const { return m_noiseFloor[channel]; }
//! Ends a burst the caller has given up on, without decoding it - a channel that has
//! been transmitting continuously for longer than any burst can be. The noise floor
//! is invalidated so it re-converges rather than staying at whatever it was
void abandonBurst(int channel)
{
m_inBurst[channel] = 0;
m_aboveCount[channel] = 0;
m_noiseValid[channel] = 0;
removeBurstChannel(channel);
}
//! Feeds one sample per channel.
//!
//! append(channel, sample) is called for every channel that was already receiving
//! when the block arrived, and returns true if that channel has now taken more
//! samples than any burst can be - it is given the sample before the end test, which
//! is the order the single channel path used, so the sample a burst ends on is part
//! of it. A channel that starts in this block is not appended to: its samples so far
//! are the pre-trigger history.
//!
//! begin(channel, burstStart) is called when a burst starts and returns the buffer to
//! put that history in, which is filled here rather than afterwards: this block's
//! sample goes into the ring at the end, over the oldest one, so by the time the
//! caller had a chance to read it the window would be short of where it started
template <typename Append, typename Begin>
void processBlock(const Cd *samples, std::vector<Change>& changes, Append append, Begin begin)
{
power(samples);
continueBursts(samples, changes, append);
idleAndHistory(samples, changes, begin);
m_sampleIndex++;
}
private:
//! Power and the smoothing step, for every channel. Nothing here depends on whether a
//! channel is in a burst, so it is one straight run over two arrays
void power(const Cd *samples)
{
const double *in = (const double *) samples;
double *smoothed = m_smoothed.data();
int c = 0;
#if defined(USE_SSE4_1)
const __m128d alpha = _mm_set1_pd(0.25);
for (; c + 2 <= m_channels; c += 2)
{
// Two complex samples are four doubles: multiply by themselves and add the
// halves across to get the two norms
const __m128d a = _mm_loadu_pd(in + (2 * c));
const __m128d b = _mm_loadu_pd(in + (2 * c) + 2);
const __m128d aa = _mm_mul_pd(a, a);
const __m128d bb = _mm_mul_pd(b, b);
const __m128d p = _mm_hadd_pd(aa, bb);
const __m128d s = _mm_loadu_pd(smoothed + c);
_mm_storeu_pd(smoothed + c,
_mm_add_pd(s, _mm_mul_pd(_mm_sub_pd(p, s), alpha)));
}
#endif
for (; c < m_channels; c++)
{
const double p = std::norm(samples[c]);
smoothed[c] += (p - smoothed[c]) * 0.25;
}
}
//! The noise floor, the start test and the history ring, in one pass.
//!
//! One pass rather than three: the arithmetic here is only a handful of operations
//! per channel, so walking the arrays is most of what it costs, and splitting it up
//! was measurably worse than the single fused loop it replaced. Within a channel the
//! order is the one the single channel path used - the idle test, then the start,
//! then the ring write, so that a burst's history is taken before this block's
//! sample lands on the oldest slot
template <typename Begin>
void idleAndHistory(const Cd *samples, std::vector<Change>& changes, Begin begin)
{
const double *smoothed = m_smoothed.data();
double *noise = m_noiseFloor.data();
quint8 *valid = m_noiseValid.data();
const quint8 *inBurst = m_inBurst.data();
qint32 *above = m_aboveCount.data();
Cd *ring = m_preTrigger.data();
const int length = m_preTriggerLength;
const size_t write = (size_t) m_preTriggerWrite;
for (int c = 0; c < m_channels; c++)
{
if (!inBurst[c])
{
if (!valid[c])
{
noise[c] = smoothed[c];
valid[c] = 1;
}
else
{
noise[c] += (smoothed[c] - noise[c]) * 0.0001;
}
if (smoothed[c] > (noise[c] * m_startThreshold))
{
above[c]++;
if (above[c] >= m_startSamples) {
startBurst(c, changes, begin);
}
}
else
{
above[c] = 0;
}
}
ring[((size_t) write * m_channels) + c] = samples[c];
}
m_preTriggerWrite++;
if (m_preTriggerWrite == length) {
m_preTriggerWrite = 0;
}
if (m_preTriggerCount < length) {
m_preTriggerCount++;
}
}
//! The channels that were already receiving: take this block's sample, then test
//! whether the burst has ended. Walked backwards so that removing one does not
//! disturb the ones still to be looked at, and only over the channels that were
//! receiving before this block - on a real band a handful out of hundreds
template <typename Append>
void continueBursts(const Cd *samples, std::vector<Change>& changes, Append append)
{
const double *smoothed = m_smoothed.data();
const double *noise = m_noiseFloor.data();
for (int i = (int) m_burstChannels.size() - 1; i >= 0; i--)
{
const int c = m_burstChannels[i];
if (append(c, samples[c]))
{
// Longer than any burst can be, so something is transmitting continuously
m_inBurst[c] = 0;
m_aboveCount[c] = 0;
m_noiseValid[c] = 0;
m_burstChannels.erase(m_burstChannels.begin() + i);
continue;
}
if (smoothed[c] < (noise[c] * m_endThreshold))
{
m_belowCount[c]++;
if (m_belowCount[c] >= m_endSamples)
{
m_inBurst[c] = 0;
m_aboveCount[c] = 0;
m_burstChannels.erase(m_burstChannels.begin() + i);
changes.push_back({ c, Ended });
}
}
else
{
m_belowCount[c] = 0;
}
}
}
//! Channels whose start counter has reached the threshold. The counter only advances
//! for an idle channel, so one that reaches it here cannot already be receiving, and
//! the end test above has already run without it
template <typename Begin>
void startBurst(int c, std::vector<Change>& changes, Begin begin)
{
m_inBurst[c] = 1;
m_belowCount[c] = 0;
m_burstChannels.push_back(c);
changes.push_back({ c, Started });
// The samples from before the detector fired are part of the burst, and the
// preamble they hold is what the frequency estimate needs. Oldest first, which
// with a ring is wherever the next write would go
std::vector<Cd>& out = begin(c, m_sampleIndex - (qint64) m_preTriggerCount);
for (int i = 0; i < m_preTriggerCount; i++)
{
const int slot = (m_preTriggerWrite + m_preTriggerLength - m_preTriggerCount + i)
% m_preTriggerLength;
out.push_back(m_preTrigger[((size_t) slot * m_channels) + c]);
}
}
void removeBurstChannel(int channel)
{
for (size_t i = 0; i < m_burstChannels.size(); i++)
{
if (m_burstChannels[i] == channel)
{
m_burstChannels.erase(m_burstChannels.begin() + i);
return;
}
}
}
int m_channels;
double m_startThreshold;
double m_endThreshold;
int m_startSamples;
int m_endSamples;
int m_preTriggerLength;
std::vector<double> m_smoothed;
std::vector<double> m_noiseFloor;
std::vector<quint8> m_noiseValid;
std::vector<quint8> m_inBurst;
std::vector<qint32> m_aboveCount;
std::vector<qint32> m_belowCount;
std::vector<int> m_burstChannels;
std::vector<Cd> m_preTrigger;
int m_preTriggerWrite;
int m_preTriggerCount;
qint64 m_sampleIndex;
};
#endif // INCLUDE_ACARSIRIDIUMDETECTOR_H

147
plugins/channelrx/demodacars/acarsiridiumfft.h

@ -0,0 +1,147 @@ @@ -0,0 +1,147 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUMFFT_H
#define INCLUDE_ACARSIRIDIUMFFT_H
#include <complex>
#include <cmath>
#include <vector>
#if defined(USE_SSE4_1)
#include <smmintrin.h>
#endif
// A small radix 2 transform, shared by the Iridium channelizer and the burst receiver.
//
// Both only ever need power of two sizes, and both are in a plugin that should not drag
// a transform library in behind it, so this is deliberately plain. It is not fast by the
// standards of a real FFT library; it is fast enough, and the sizes are small.
class AcarsIridiumFft
{
public:
typedef std::complex<double> Cd;
//! Prepares for transforms of the given size, which must be a power of two
void configure(int size)
{
if (m_size == size) {
return;
}
m_size = size;
m_twiddle.resize(size / 2);
m_twiddleInverse.resize(size / 2);
for (int k = 0; k < (size / 2); k++)
{
const double angle = -2.0 * M_PI * (double) k / (double) size;
m_twiddle[k] = Cd(std::cos(angle), std::sin(angle));
m_twiddleInverse[k] = std::conj(m_twiddle[k]);
}
}
int size() const { return m_size; }
//! In place transform. inverse runs the same butterflies with the conjugate twiddles
//! and no scaling, which is what a filter bank wants
void transform(std::vector<Cd>& data, bool inverse = false) const
{
const int n = m_size;
for (int i = 1, j = 0; i < n; i++)
{
int bit = n >> 1;
for (; j & bit; bit >>= 1) {
j ^= bit;
}
j ^= bit;
if (i < j) {
std::swap(data[i], data[j]);
}
}
// Both tables are precomputed: conjugating inside the butterfly meant doing it
// once per butterfly, which for a bank running tens of thousands of transforms a
// second is a great deal of work to repeat for a table that never changes
const Cd *twiddle = inverse ? m_twiddleInverse.data() : m_twiddle.data();
for (int len = 2; len <= n; len <<= 1)
{
const int step = n / len;
const int half = len / 2;
for (int i = 0; i < n; i += len)
{
Cd *lower = &data[i];
Cd *upper = &data[i + half];
for (int k = 0; k < half; k++)
{
#if defined(USE_SSE4_1)
// A complex double fills one 128 bit register. The product of two of
// them is the classic shuffle and alternating add: ac - bd in the
// real half and bc + ad in the imaginary half, which addsub does in
// one instruction instead of the sign juggling it would otherwise take
const __m128d x = _mm_loadu_pd((const double *) &upper[k]);
const __m128d y = _mm_loadu_pd((const double *) &twiddle[k * step]);
const __m128d t1 = _mm_mul_pd(x, _mm_unpacklo_pd(y, y));
const __m128d t2 = _mm_mul_pd(_mm_shuffle_pd(x, x, 1), _mm_unpackhi_pd(y, y));
const __m128d v = _mm_addsub_pd(t1, t2);
const __m128d u = _mm_loadu_pd((const double *) &lower[k]);
_mm_storeu_pd((double *) &lower[k], _mm_add_pd(u, v));
_mm_storeu_pd((double *) &upper[k], _mm_sub_pd(u, v));
#else
const Cd w = twiddle[k * step];
const Cd u = lower[k];
const Cd v = upper[k] * w;
lower[k] = u + v;
upper[k] = u - v;
#endif
}
}
}
}
//! The smallest power of two at least as large as n
static int nextPowerOfTwo(int n)
{
int size = 1;
while (size < n) {
size <<= 1;
}
return size;
}
private:
int m_size = 0;
std::vector<Cd> m_twiddle;
std::vector<Cd> m_twiddleInverse;
};
#endif // INCLUDE_ACARSIRIDIUMFFT_H

173
plugins/channelrx/demodacars/acarsiridiumfftengine.h

@ -0,0 +1,173 @@ @@ -0,0 +1,173 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUMFFTENGINE_H
#define INCLUDE_ACARSIRIDIUMFFTENGINE_H
#include <cmath>
#include <complex>
#include <vector>
#include <QDebug>
#include "dsp/dspengine.h"
#include "dsp/fftengine.h"
#include "dsp/fftfactory.h"
#include "acarsiridiumchannelizer.h"
#include "acarsiridiumfft.h"
// Puts SDRangel's FFT engine behind the Iridium channelizer.
//
// The bank runs one transform per output block, which at the widest setting is a hundred
// and twenty five thousand 256 point transforms a second, and that was over a third of
// everything the scanner cost. The radix 2 in acarsiridiumfft.h is deliberately plain so
// that the offline harnesses in test/ can build against Qt alone; here, where sdrbase is
// available, FFTW does the same transform several times faster.
//
// Single precision, because that is what SDRangel's engines work in. The polyphase
// filtering either side of it stays double, and a 256 point transform in float carries
// far more precision than a burst detector and a DQPSK slicer can use.
class AcarsIridiumFftEngine : public AcarsIridiumTransform
{
public:
AcarsIridiumFftEngine() :
m_engine(nullptr),
m_sequence(0),
m_size(0)
{
}
~AcarsIridiumFftEngine()
{
release();
}
void configure(int size) override
{
release();
FFTFactory *factory = DSPEngine::instance()->getFFTFactory();
// Inverse, which the factory configures the engine for. Both this and the radix 2
// leave it unscaled, which is what a filter bank wants
m_sequence = factory->getEngine(size, true, &m_engine);
m_size = size;
m_builtIn.configure(size);
if (!m_engine)
{
qWarning() << "AcarsIridiumFftEngine: no engine for size" << size
<< "- falling back to the built-in transform";
return;
}
qInfo() << "AcarsIridiumFftEngine: using" << m_engine->getName()
<< "for the" << size << "point channelizer transform";
checkAgainstBuiltIn(size);
}
void transform(std::vector<std::complex<double>>& data) override
{
if (!m_engine)
{
m_builtIn.transform(data, true);
return;
}
Complex *in = m_engine->in();
for (int i = 0; i < m_size; i++) {
in[i] = Complex((float) data[i].real(), (float) data[i].imag());
}
m_engine->transform();
const Complex *out = m_engine->out();
for (int i = 0; i < m_size; i++) {
data[i] = std::complex<double>(out[i].real(), out[i].imag());
}
}
private:
//! One transform of a known vector through both, compared, when the engine is taken.
//!
//! Worth the once-per-configure cost because the ways this can be wrong are not
//! subtle but are silent: a library that scales its inverse by 1/N, or orders its
//! output differently, would leave the bank producing plausible rubbish and the only
//! visible symptom would be that nothing ever decodes. The tests in test/ cannot
//! cover this path, because they build without sdrbase and so never see this engine
void checkAgainstBuiltIn(int size)
{
AcarsIridiumFft reference;
reference.configure(size);
std::vector<std::complex<double>> a(size);
for (int i = 0; i < size; i++)
{
const double phase = 0.7 * i;
a[i] = std::complex<double>(std::cos(phase) + (0.1 * i), std::sin(phase) - (0.05 * i));
}
std::vector<std::complex<double>> b = a;
reference.transform(a, true);
transform(b);
double worst = 0.0;
double scale = 1e-12;
for (int i = 0; i < size; i++)
{
worst = std::max(worst, std::abs(b[i] - a[i]));
scale = std::max(scale, std::abs(a[i]));
}
// Generous: single precision over a 256 point transform of values this large is
// good to about a part in a million, and anything structurally wrong is out by
// orders of magnitude rather than by rounding
if ((worst / scale) > 1e-4)
{
qWarning() << "AcarsIridiumFftEngine:" << m_engine->getName()
<< "disagrees with the built-in transform by" << (worst / scale)
<< "- falling back to the built-in one";
release();
}
}
void release()
{
if (m_engine)
{
DSPEngine::instance()->getFFTFactory()->releaseEngine(m_size, true, m_sequence);
m_engine = nullptr;
}
}
FFTEngine *m_engine;
unsigned int m_sequence;
int m_size;
AcarsIridiumFft m_builtIn;
};
#endif // INCLUDE_ACARSIRIDIUMFFTENGINE_H

1118
plugins/channelrx/demodacars/acarsiridiumframe.h

File diff suppressed because it is too large Load Diff

347
plugins/channelrx/demodacars/acarsiridiumscanner.h

@ -0,0 +1,347 @@ @@ -0,0 +1,347 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACARSIRIDIUMSCANNER_H
#define INCLUDE_ACARSIRIDIUMSCANNER_H
#include <QByteArray>
#include <QList>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <deque>
#include <vector>
#include "acarsiridium.h"
#include "acarsiridiumframe.h"
#include "acarsiridiumchannelizer.h"
#include "acarsiridiumdetector.h"
// Watches the whole Iridium band at once.
//
// Iridium assigns a duplex channel when a call is set up, out of about 240 spaced
// 41.67 kHz across roughly 1619 to 1626 MHz, so a receiver watching one channel sees a
// few percent of what is on the air - measured on a four minute recording of the whole
// band, the busiest single channel carried 4% of the short burst data frames in it. This
// splits the band with the polyphase channelizer and runs a burst receiver on every
// output, which is what makes scanning practical without the user adding a demodulator
// per channel.
//
// The channelizer spacing is 31.25 kHz rather than the 41.67 kHz of the Iridium grid.
// Lining the two up would need a channel count divisible by three, and a transform of
// that size is far more work than a power of two; nothing needs them aligned, because a
// burst is found by searching its channel rather than by being assumed to sit in the
// middle of one. The cost is that neighbouring channels overlap, so a burst is often
// found twice, and the duplicates have to go - a frame decoded twice would otherwise
// break the short burst data reassembly, whose fragments have to arrive in counter order.
//! The channelizer spacing, which with four times oversampling gives the 125 kHz the
//! receiver runs at. The input rate is this times the number of channels
#define ACARSIRIDIUM_SCAN_SPACING 31250
class AcarsIridiumScanner
{
public:
typedef std::complex<double> Cd;
struct Detection
{
AcarsIridiumFrame m_frame;
double m_frequency = 0.0; //!< Hz from the centre of the band
double m_snrDb = 0.0;
qint64 m_sampleIndex = 0; //!< Where the burst started, in input samples
int m_channel = 0;
//!< A short burst data message, once a run of frames has been put back together.
//!< Reported whether or not it turns out to hold ACARS, because the step that
//!< reads an ACARS block out of one is the only part of the chain never tested
//!< against real traffic - if it ever wrongly refuses a message, that has to be
//!< visible rather than silently dropped
QByteArray m_message;
QByteArray m_acars; //!< A complete ACARS block, when one came out
};
AcarsIridiumScanner() :
m_channels(0),
m_decimation(0),
m_inputRate(0.0),
m_holdSamples(0),
m_sameTimeSamples(0),
m_sampleIndex(0)
{
}
//! channels is the number of channelizer outputs, which fixes the input rate at
//! channels * ACARSIRIDIUM_SCAN_SPACING. It must be a power of two
void configure(int channels)
{
m_channels = channels;
m_inputRate = (double) channels * ACARSIRIDIUM_SCAN_SPACING;
m_holdSamples = (qint64) (HoldSeconds * m_inputRate);
m_sameTimeSamples = (qint64) (SameTimeSeconds * m_inputRate);
m_channelizer.configure(channels);
m_reassembler.setBandWidth(m_inputRate);
m_decimation = m_channelizer.decimation();
m_receivers.clear();
m_receivers.resize(channels);
m_detector.configure(channels,
AcarsIridiumReceiver::StartThreshold,
AcarsIridiumReceiver::EndThreshold,
AcarsIridiumReceiver::StartSamples,
AcarsIridiumReceiver::EndSamples,
AcarsIridiumReceiver::PreTriggerLength);
m_changes.clear();
m_pending.clear();
m_detections.clear();
m_sampleIndex = 0;
m_burstCount = 0;
m_duplicateCount = 0;
m_frameCount = 0;
m_idaCount = 0;
m_messageCount = 0;
m_acarsCount = 0;
}
//! Puts a different transform behind the channelizer. Must be called before
//! configure, and the caller keeps ownership
void setTransform(AcarsIridiumTransform *transform) { m_channelizer.setTransform(transform); }
int channels() const { return m_channels; }
double inputRate() const { return m_inputRate; }
//! Feeds one input sample at inputRate
void processSample(const Cd& sample)
{
m_sampleIndex++;
if (!m_channelizer.processSample(sample)) {
return;
}
const std::vector<Cd>& channelSamples = m_channelizer.channelSamples();
// Detection for every channel in one pass over arrays rather than a receiver at
// a time - see the note on AcarsIridiumDetectorBank
m_changes.clear();
m_detector.processBlock(channelSamples.data(), m_changes,
[this](int channel, const Cd& sample) {
return m_receivers[channel].appendBurst(sample);
},
[this](int channel, qint64 burstStart) -> std::vector<Cd>& {
m_receivers[channel].beginBurst(burstStart);
return m_receivers[channel].burstSamples();
});
for (size_t i = 0; i < m_changes.size(); i++)
{
const AcarsIridiumDetectorBank::Change& change = m_changes[i];
const int c = change.m_channel;
// A start has already been dealt with, inside the block
if (change.m_event == AcarsIridiumDetectorBank::Started) {
continue;
}
m_receivers[c].finishBurst(m_detector.noiseFloor(c));
while (m_receivers[c].hasBurst())
{
AcarsIridiumReceiver::Burst burst = m_receivers[c].popBurst();
if (burst.m_direction == AcarsIridiumReceiver::DirectionUnknown) {
continue;
}
Candidate candidate;
candidate.m_burst = burst;
candidate.m_channel = c;
candidate.m_frequency = m_channelizer.channelOffset(c, m_inputRate)
+ burst.m_frequencyOffset;
// The detector counts in channel samples
candidate.m_sampleIndex = burst.m_sampleIndex * m_decimation;
candidate.m_detectedAt = m_sampleIndex;
m_pending.push_back(candidate);
m_burstCount++;
}
}
flush(false);
}
//! Call when the input ends, so anything still held for duplicate checking is emitted
void finish()
{
flush(true);
}
bool hasDetection() const { return !m_detections.empty(); }
Detection popDetection()
{
Detection detection = m_detections.front();
m_detections.pop_front();
return detection;
}
int burstCount() const { return m_burstCount; }
int duplicateCount() const { return m_duplicateCount; }
int frameCount() const { return m_frameCount; }
int idaCount() const { return m_idaCount; }
int messageCount() const { return m_messageCount; }
int acarsCount() const { return m_acarsCount; }
private:
struct Candidate
{
AcarsIridiumReceiver::Burst m_burst;
int m_channel = 0;
double m_frequency = 0.0;
qint64 m_sampleIndex = 0; //!< Where the burst started
qint64 m_detectedAt = 0; //!< When it finished and was handed over
};
// How long a burst is held before being decoded, so that the same burst found in a
// neighbouring channel has arrived too and the better of the two can be taken.
// Measured from when the burst was handed over, not from when it started: a burst
// runs to 20 ms, so by the time it ends its start is long past and holding against
// that would expire immediately and let every duplicate through.
//
// A duration rather than a count of input samples, because the input rate spans eight
// to one across the bandwidth settings: as a fixed count this was 8 ms at 32 channels
// but 1 ms at 256, which is the wrong way round - the widest setting has the most
// overlapping neighbours and so needs the hold most
static constexpr double HoldSeconds = 0.008;
// Two detections are the same burst when they start at about the same time and are at
// about the same frequency. Bursts on one channel are a time slot apart, roughly
// 9 ms, so this cannot merge two genuine transmissions; the channel spacing is
// 31.25 kHz, so the frequency tolerance is well inside it
static constexpr double SameTimeSeconds = 0.004;
static constexpr double SameFrequencyHz = 12000.0;
void flush(bool all)
{
while (!m_pending.empty())
{
if (!all && ((m_sampleIndex - m_pending.front().m_detectedAt) < m_holdSamples)) {
break;
}
// Take the oldest, then find every other pending detection that is the same
// burst heard in an overlapping channel, and keep whichever has the best
// signal to noise - that is the one whose channel the burst sat nearest the
// middle of
Candidate best = m_pending.front();
m_pending.pop_front();
for (size_t i = 0; i < m_pending.size(); )
{
const Candidate& other = m_pending[i];
// The band is circular, so the channels either side of the fold at its
// edge are neighbours and a burst in both has to be recognised as one
if ((std::llabs(other.m_sampleIndex - best.m_sampleIndex) < m_sameTimeSamples)
&& (AcarsIridiumReassembler::separation(other.m_frequency, best.m_frequency, m_inputRate) < SameFrequencyHz))
{
if (other.m_burst.m_snrDb > best.m_burst.m_snrDb) {
best = other;
}
m_pending.erase(m_pending.begin() + i);
m_duplicateCount++;
}
else
{
i++;
}
}
decode(best);
}
}
void decode(const Candidate& candidate)
{
Detection detection;
if (!m_decoder.decode(candidate.m_burst.m_frameBits, detection.m_frame)) {
return;
}
detection.m_frequency = candidate.m_frequency;
detection.m_snrDb = candidate.m_burst.m_snrDb;
detection.m_sampleIndex = candidate.m_sampleIndex;
detection.m_channel = candidate.m_channel;
m_frameCount++;
if (detection.m_frame.m_type == AcarsIridiumFrame::TypeIDA)
{
m_idaCount++;
const qint64 timeMs = (qint64) ((1000.0 * (double) candidate.m_sampleIndex) / m_inputRate);
QByteArray message;
// Short burst data is reassembled per transmitter, and the reassembler tells
// them apart by frequency, so it is given the absolute frequency in the band
// rather than the offset within a channel
if (m_reassembler.addFrame(detection.m_frame, timeMs, candidate.m_frequency, message))
{
QByteArray block;
detection.m_message = message;
m_messageCount++;
if (AcarsIridiumReassembler::acarsBlock(message, detection.m_frame.m_uplink, block))
{
detection.m_acars = block;
m_acarsCount++;
}
}
}
m_detections.push_back(detection);
}
int m_channels;
int m_decimation;
double m_inputRate;
qint64 m_holdSamples;
qint64 m_sameTimeSamples;
qint64 m_sampleIndex;
AcarsIridiumChannelizer m_channelizer;
AcarsIridiumDetectorBank m_detector;
std::vector<AcarsIridiumDetectorBank::Change> m_changes;
std::vector<AcarsIridiumReceiver> m_receivers;
AcarsIridiumFrameDecoder m_decoder;
AcarsIridiumReassembler m_reassembler;
std::deque<Candidate> m_pending;
std::deque<Detection> m_detections;
int m_burstCount = 0;
int m_duplicateCount = 0;
int m_frameCount = 0;
int m_idaCount = 0;
int m_messageCount = 0;
int m_acarsCount = 0;
};
#endif // INCLUDE_ACARSIRIDIUMSCANNER_H

366
plugins/channelrx/demodacars/acarsmessagemodel.cpp

@ -0,0 +1,366 @@ @@ -0,0 +1,366 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "acarsmessagemodel.h"
AcarsMessageModel::AcarsMessageModel(QObject *parent) :
QAbstractTableModel(parent),
m_showDate(true)
{
}
int AcarsMessageModel::rowCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : m_rows.size();
}
int AcarsMessageModel::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : MESSAGE_COL_COUNT;
}
QString AcarsMessageModel::dateTimeText(const QDateTime& dateTime) const
{
if (m_showDate)
{
return QString("%1 %2").arg(m_locale.toString(dateTime.date(), QLocale::ShortFormat),
dateTime.time().toString());
}
return dateTime.time().toString();
}
// The Mode character, per ARINC 618-7 Attachment 6.
//
// Category A is the single character "2" - "transmitted bi-directional, no preferred
// air/ground data path selected", which ARINC 620 calls the broadcast mode.
//
// Category B identifies a path, and Attachment 6 pairs the two directions: an uplink
// character in ` (6/0) through } (7/13) and the downlink character the aircraft then
// answers on, @ (4/0) through ] (5/13), are the same access code. The two ranges are
// 0x20 apart - the case bit - so subtracting the base of whichever range the character
// is in gives the access code, 0 to 29, for either direction.
//
// Attachment 6 does NOT name the ground stations. Its column is headed "LOGICAL PATH
// (GROUND STATION)" and holds only #0 to #29, because section 2.3.2.2 leaves the
// assignment to the service provider: it is regional operational data, not a standard,
// and only thirty codes exist for the whole world. This used to be decoded against
// per-country tables of airport names taken from an enthusiast's handbook, which named
// stations the specification never does and which were as likely wrong as right - so
// the path number is reported and nothing is invented around it.
//
// The satellite column of Attachment 6 IS normative, but names only five of the thirty,
// and applies to Satcom alone.
QString AcarsMessageModel::modeDecode(const AcarsRowEvent& e)
{
// Every protocol but plain ACARS names its ground station in the worker, where the
// station tables are. Only an ACARS block carries an ARINC 618 Mode character.
if (!e.m_modeDecode.isEmpty()) {
return e.m_modeDecode;
}
if ((e.m_frameType != 0) || e.m_mode.isEmpty()) {
return QString();
}
// Not used on HF: 618 section 2.2.2.5 says to enter the default 2 and ignore it
if (e.m_protocol == "HFDL") {
return "";
}
if (e.m_mode == "2") {
return "All"; // Category A
}
const ushort c = e.m_mode.at(0).unicode();
int path = -1;
if ((c >= 0x40) && (c <= 0x5D)) {
path = c - 0x40; // Air to ground
} else if ((c >= 0x60) && (c <= 0x7D)) {
path = c - 0x60; // Ground to air
} else {
return "Invalid";
}
// Attachment 6's satellite service provider column. Sparse on purpose: the other
// twenty-five codes have no provider assigned.
if (e.m_protocol.startsWith("Aero"))
{
const char *provider = (path == 1) ? "ARINC"
: (path == 3) ? "Air Canada"
: (path == 10) ? "AVICOM"
: (path == 12) ? "AlliedSignal"
: (path == 19) ? "SITA" : nullptr;
if (provider) {
return QString("%1").arg(provider);
}
}
return QString("#%1").arg(path);
}
QVariant AcarsMessageModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || !isValidRow(index.row())) {
return QVariant();
}
const Row& r = m_rows.at(index.row());
const AcarsRowEvent& e = r.m_event;
const int col = index.column();
if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
{
switch (col)
{
case MESSAGE_COL_DATETIME: return dateTimeText(e.m_received);
case MESSAGE_COL_DIR: return QString(QChar(e.m_uplink ? 0x2191 : 0x2193));
case MESSAGE_COL_GS: return e.m_mode;
case MESSAGE_COL_GS_DECODE: return modeDecode(e);
case MESSAGE_COL_ADDRESS: return e.m_address;
case MESSAGE_COL_ACK: return e.m_ack;
case MESSAGE_COL_LABEL: return e.m_label;
case MESSAGE_COL_LABEL_DECODE: return e.m_labelDecode;
case MESSAGE_COL_ID: return e.m_blockId;
case MESSAGE_COL_ORIGIN: return e.m_originator;
case MESSAGE_COL_ORIGIN_DECODE: return e.m_originatorDecode;
case MESSAGE_COL_MSG_NUM: return e.m_messageNumber;
case MESSAGE_COL_BLOCK_SEQUENCE: return e.m_blockSequence;
case MESSAGE_COL_FLIGHT: return e.m_flight;
case MESSAGE_COL_TEXT: return e.m_text;
case MESSAGE_COL_TEXT_DECODE: return e.m_textDecode;
case MESSAGE_COL_ATC: return e.m_atc;
case MESSAGE_COL_HEX: return e.m_hex;
case MESSAGE_COL_PROTOCOL: return e.m_protocol;
// A number, so it sorts and aligns as one
case MESSAGE_COL_RATE: return e.m_bitRate ? QVariant(e.m_bitRate) : QVariant();
// Numbers rather than strings, so they sort and align as numbers. An empty
// QVariant leaves the cell blank where there is no position at all.
case MESSAGE_COL_LATITUDE: return e.m_hasPosition ? QVariant(e.m_latitude) : QVariant();
case MESSAGE_COL_LONGITUDE: return e.m_hasPosition ? QVariant(e.m_longitude) : QVariant();
case MESSAGE_COL_ALTITUDE:
return (e.m_hasPosition && e.m_hasAltitude) ? QVariant(e.m_altitudeFt) : QVariant();
default: return QVariant();
}
}
else if (role == Qt::ToolTipRole)
{
// The flattened decode is what fits in the cell; the full one is worth having on
// hover, and is often many lines
if ((col == MESSAGE_COL_TEXT_DECODE) && !e.m_fullDecode.isEmpty()) {
return e.m_fullDecode;
}
}
return QVariant();
}
QVariant AcarsMessageModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation != Qt::Horizontal) {
// The row numbers come from the proxy, which numbers what is on show rather
// than mapping back to a source row - see AcarsMessageFilter::headerData
return QVariant();
}
if ((section < 0) || (section >= MESSAGE_COL_COUNT)) {
return QVariant();
}
static const char *names[MESSAGE_COL_COUNT] = {
"Date/Time", "Dir", "GS", "GS Decode", "Registration", "Ack", "Label",
"Label Decode", "ID", "Origin", "Origin Decode", "Msg No.", "Block Seq.",
"Flight", "Message", "Message Decode", "ATC", "Lat (°)",
"Lon (°)", "Alt (ft)", "Hex", "Protocol", "Rate (bps)"
};
static const char *tips[MESSAGE_COL_COUNT] = {
"Date and time the message was received. Right click the table to show the time alone",
"Direction of the message relative to the aircraft. ↑ uplink, ground station to aircraft; ↓ downlink, aircraft to ground",
"Ground Station Id.\n\nACARS: Mode character.\nVDL-2: Ground Station (GS)\nHFDL: Ground Station (GS)\nAero: Ground Earth Station (GES)",
"Ground Station name",
"Address / Aircraft registration",
"Technical acknowledgement",
"Message type",
"Description of message type",
"",
"Origin of message",
"Description of origin of message",
"Message number",
"Block sequence",
"Flight number",
"Message text",
"Decoded message",
"Air Traffic Control Communications",
"Aircraft latitude in decimal degrees. North positive",
"Aircraft longitude in decimal degrees. East positive",
"Aircraft altitude in feet",
"",
"Which link the frame arrived on",
"Bit rate the frame was sent at, in bits per second"
};
if (role == Qt::DisplayRole) {
return QString(names[section]);
}
if (role == Qt::ToolTipRole)
{
const QString tip(tips[section]);
return tip.isEmpty() ? QVariant() : QVariant(tip);
}
return QVariant();
}
void AcarsMessageModel::addRow(const AcarsRowEvent& event)
{
beginInsertRows(QModelIndex(), m_rows.size(), m_rows.size());
Row r;
r.m_event = event;
m_rows.append(r);
endInsertRows();
}
void AcarsMessageModel::clear()
{
if (m_rows.isEmpty()) {
return;
}
beginResetModel();
m_rows.clear();
endResetModel();
}
// One column's worth of every row has changed, which is a single signal rather than a
// walk over the table writing new strings in
void AcarsMessageModel::columnChanged(int column)
{
if (m_rows.isEmpty()) {
return;
}
emit dataChanged(index(0, column), index(m_rows.size() - 1, column),
{ Qt::DisplayRole });
}
void AcarsMessageModel::setShowDate(bool showDate)
{
if (showDate == m_showDate) {
return;
}
m_showDate = showDate;
columnChanged(MESSAGE_COL_DATETIME);
}
// beginFilterChange() was added in Qt 6.9 and endFilterChange() in Qt 6.10, and
// invalidateFilter() is deprecated in favour of the pair. Bracketing the change is
// what newer Qt wants - beginFilterChange() before the filter state is touched - so
// the call sites are written that way and these stand in on older Qt, where a single
// invalidateFilter() after the change is the whole operation.
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0)
void AcarsMessageFilter::beginFilterChange()
{
}
void AcarsMessageFilter::endFilterChange()
{
invalidateFilter();
}
#endif
AcarsMessageFilter::AcarsMessageFilter(QObject *parent) :
QSortFilterProxyModel(parent),
m_hideNoInfo(true),
m_filterColumn(-1),
m_filterValid(false)
{
}
void AcarsMessageFilter::setHideNoInfo(bool hide)
{
if (hide == m_hideNoInfo) {
return;
}
beginFilterChange();
m_hideNoInfo = hide;
endFilterChange();
}
void AcarsMessageFilter::setFilter(int column, const QString& pattern)
{
beginFilterChange();
m_filterColumn = column;
// Anchored, as the table's filter has always been - the pattern has to match the
// whole cell rather than appear somewhere in it
m_filterRe = QRegularExpression(QRegularExpression::anchoredPattern(pattern));
m_filterValid = !pattern.isEmpty() && m_filterRe.isValid()
&& (column >= 0) && (column < MESSAGE_COL_COUNT);
endFilterChange();
}
// The base class would map a vertical section back to its source row, which with a
// filter applied gives a broken looking 2, 4, 6... Numbering the displayed position
// instead keeps them 1..N, and the last one is the number of messages shown.
QVariant AcarsMessageFilter::headerData(int section, Qt::Orientation orientation, int role) const
{
if ((orientation == Qt::Vertical) && (role == Qt::DisplayRole)) {
return section + 1;
}
return QSortFilterProxyModel::headerData(section, orientation, role);
}
bool AcarsMessageFilter::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
(void) sourceParent;
const AcarsMessageModel *model = qobject_cast<const AcarsMessageModel *>(sourceModel());
if (!model || !model->isValidRow(sourceRow)) {
return true;
}
if (m_hideNoInfo && model->event(sourceRow).m_noInfo) {
return false;
}
if (m_filterValid)
{
const QString text = model->data(model->index(sourceRow, m_filterColumn),
Qt::DisplayRole).toString();
if (!m_filterRe.match(text).hasMatch()) {
return false;
}
}
return true;
}
bool AcarsMessageFilter::lessThan(const QModelIndex& left, const QModelIndex& right) const
{
const AcarsMessageModel *model = qobject_cast<const AcarsMessageModel *>(sourceModel());
if (model && model->isValidRow(left.row()) && model->isValidRow(right.row())
&& (left.column() == MESSAGE_COL_DATETIME))
{
// Never on the displayed text: the date can be hidden, and the locale's date
// string does not sort chronologically even when it is not
return model->event(left.row()).m_received < model->event(right.row()).m_received;
}
const QVariant l = left.data(Qt::DisplayRole);
const QVariant r = right.data(Qt::DisplayRole);
switch (left.column())
{
case MESSAGE_COL_LATITUDE:
case MESSAGE_COL_LONGITUDE:
case MESSAGE_COL_ALTITUDE:
case MESSAGE_COL_RATE:
// Blank sorts before any value rather than comparing as the string ""
if (!l.isValid() || !r.isValid()) {
return !l.isValid() && r.isValid();
}
return l.toDouble() < r.toDouble();
default:
return QString::localeAwareCompare(l.toString(), r.toString()) < 0;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save