@ -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) |
||||
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 666 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 242 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 290 KiB |
|
After Width: | Height: | Size: 233 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 530 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 745 KiB After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 37 KiB |
@ -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() |
||||
@ -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(); |
||||
} |
||||
@ -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
|
||||
@ -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()); |
||||
} |
||||
@ -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
|
||||
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE RCC> |
||||
<RCC version="1.0"> |
||||
<qresource prefix="/"> |
||||
<file>vdl2gs.txt</file> |
||||
</qresource> |
||||
</RCC> |
||||
@ -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
|
||||
@ -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> |
||||
@ -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("7.28.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(); |
||||
} |
||||
@ -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
|
||||
@ -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; |
||||
} |
||||
} |
||||
@ -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 */ |
||||
@ -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; |
||||
} |
||||
@ -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
|
||||
@ -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; |
||||
} |
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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; |
||||
} |
||||
} |
||||
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// 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_ACARSMESSAGEMODEL_H |
||||
#define INCLUDE_ACARSMESSAGEMODEL_H |
||||
|
||||
#include <QAbstractTableModel> |
||||
#include <QSortFilterProxyModel> |
||||
#include <QRegularExpression> |
||||
#include <QList> |
||||
#include <QLocale> |
||||
|
||||
#include "acarsdemodworker.h" |
||||
|
||||
// Columns of the received messages table. At file scope rather than inside the model,
|
||||
// because the GUI refers to them constantly and qualifying every one would not make
|
||||
// any of it clearer.
|
||||
enum MessageCol { |
||||
MESSAGE_COL_DATETIME, |
||||
MESSAGE_COL_DIR, |
||||
MESSAGE_COL_GS, |
||||
MESSAGE_COL_GS_DECODE, |
||||
MESSAGE_COL_ADDRESS, |
||||
MESSAGE_COL_ACK, |
||||
MESSAGE_COL_LABEL, |
||||
MESSAGE_COL_LABEL_DECODE, |
||||
MESSAGE_COL_ID, |
||||
MESSAGE_COL_ORIGIN, |
||||
MESSAGE_COL_ORIGIN_DECODE, |
||||
MESSAGE_COL_MSG_NUM, |
||||
MESSAGE_COL_BLOCK_SEQUENCE, |
||||
MESSAGE_COL_FLIGHT, |
||||
MESSAGE_COL_TEXT, |
||||
MESSAGE_COL_TEXT_DECODE, |
||||
MESSAGE_COL_ATC, |
||||
MESSAGE_COL_LATITUDE, |
||||
MESSAGE_COL_LONGITUDE, |
||||
MESSAGE_COL_ALTITUDE, |
||||
MESSAGE_COL_HEX, |
||||
// Appended rather than placed next to Dir where it belongs, because the saved column
|
||||
// widths and order are stored by index - putting it in the middle would shift every
|
||||
// one of them. Drag it where you want it; the order is remembered.
|
||||
MESSAGE_COL_PROTOCOL, |
||||
MESSAGE_COL_RATE, |
||||
MESSAGE_COL_COUNT |
||||
}; |
||||
|
||||
// The received messages table.
|
||||
//
|
||||
// This was a QTableWidget until 2026-08-26, and the reason it is not any more is that
|
||||
// hiding a row there is O(rows already present): QTableView::setRowHidden goes to
|
||||
// QHeaderView::setSectionHidden, which invalidates the section start positions and then
|
||||
// walks every section. Measured over 22000 rows with alternate rows hidden - which is
|
||||
// what an Aero P channel produces, since its housekeeping alternates with real traffic -
|
||||
// the cost of adding a row rose from 19 us to 390 us and was still climbing. Batching
|
||||
// the hides and disabling updates around them changed nothing; the cost is inside
|
||||
// setSectionHidden itself.
|
||||
//
|
||||
// A filtered row simply does not exist in a proxy's mapping, so there is no section to
|
||||
// hide. The same measurement through QSortFilterProxyModel is FLAT at 2.8 us a row -
|
||||
// faster than the QTableWidget managed even with no hiding at all (8.7 us), because
|
||||
// nothing allocates 22 QTableWidgetItems per row any more.
|
||||
//
|
||||
// Values that depend on a setting rather than on the message - the date format, the
|
||||
// country-specific mode decode - are computed in data() rather than written into every
|
||||
// row, so changing the setting is one dataChanged rather than a walk over the table.
|
||||
class AcarsMessageModel : public QAbstractTableModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit AcarsMessageModel(QObject *parent = nullptr); |
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
||||
QVariant headerData(int section, Qt::Orientation orientation, |
||||
int role = Qt::DisplayRole) const override; |
||||
|
||||
void addRow(const AcarsRowEvent& event); |
||||
void clear(); |
||||
|
||||
bool isValidRow(int row) const { return (row >= 0) && (row < m_rows.size()); } |
||||
// The whole decoded frame, so a handler can read what it needs instead of scraping
|
||||
// it back out of the cell text
|
||||
const AcarsRowEvent& event(int row) const { return m_rows.at(row).m_event; } |
||||
|
||||
void setShowDate(bool showDate); |
||||
|
||||
private: |
||||
struct Row { |
||||
AcarsRowEvent m_event; |
||||
}; |
||||
|
||||
QList<Row> m_rows; |
||||
bool m_showDate; |
||||
QLocale m_locale; |
||||
|
||||
QString dateTimeText(const QDateTime& dateTime) const; |
||||
static QString modeDecode(const AcarsRowEvent& event); |
||||
void columnChanged(int column); |
||||
}; |
||||
|
||||
// Hides frames carrying no usable information, applies the filter pattern, and sorts by
|
||||
// the underlying value rather than by the displayed text - which matters most for the
|
||||
// date and time, where the locale's date string does not sort chronologically and the
|
||||
// date can be hidden altogether.
|
||||
class AcarsMessageFilter : public QSortFilterProxyModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit AcarsMessageFilter(QObject *parent = nullptr); |
||||
|
||||
void setHideNoInfo(bool hide); |
||||
void setFilter(int column, const QString& pattern); |
||||
|
||||
// Row numbers down the side. They count the rows on show rather than the rows
|
||||
// received, so the last one is how many messages are in the table.
|
||||
QVariant headerData(int section, Qt::Orientation orientation, |
||||
int role = Qt::DisplayRole) const override; |
||||
|
||||
protected: |
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override; |
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override; |
||||
|
||||
// Qt 6.10 brought these, deprecating invalidateFilter() in their favour. On
|
||||
// anything older they stand in for it - see acarsmessagemodel.cpp
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) |
||||
void beginFilterChange(); |
||||
void endFilterChange(); |
||||
#endif |
||||
|
||||
private: |
||||
bool m_hideNoInfo; |
||||
int m_filterColumn; |
||||
QRegularExpression m_filterRe; |
||||
bool m_filterValid; |
||||
}; |
||||
|
||||
#endif // INCLUDE_ACARSMESSAGEMODEL_H
|
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is a part of dumpvdl2 |
||||
* |
||||
* Copyright (c) 2017-2026 Tomasz Lemiech <szpajder@gmail.com> |
||||
* |
||||
* 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, either 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 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 _ASN1_FORMAT_ICAO_H |
||||
#define _ASN1_FORMAT_ICAO_H |
||||
|
||||
#include <libacars/asn1-util.h> // la_asn1_formatter_func |
||||
#include <libacars/dict.h> // la_dict |
||||
|
||||
// asn1-format-icao-text.c
|
||||
extern la_dict const Associate_result_labels[]; |
||||
extern la_dict const Release_request_reason_labels[]; |
||||
extern la_dict const Release_response_reason_labels[]; |
||||
extern la_dict const RevisionReason_labels[]; |
||||
extern la_dict const RunwayUse_labels[]; |
||||
extern la_dict const TransferConstraints_bit_labels[]; |
||||
extern la_dict const ABRT_source_labels[]; |
||||
extern la_dict const ATCUplinkMsgElementId_labels[]; |
||||
extern la_dict const VerticalType_bit_labels[]; |
||||
extern la_dict const ReportTypeNotSupported_bit_labels[]; |
||||
extern la_dict const EPPLimitations_bit_labels[]; |
||||
extern la_dict const EventTypeNotSupported_bit_labels[]; |
||||
extern la_dict const EmergencyUrgencyStatus_bit_labels[]; |
||||
extern la_dict const ATCDownlinkMsgElementId_labels[]; |
||||
extern la_asn1_formatter const asn1_icao_formatter_table_text[]; |
||||
extern size_t asn1_icao_formatter_table_text_len; |
||||
extern la_asn1_formatter const asn1_acse_formatter_table_text[]; |
||||
extern size_t asn1_acse_formatter_table_text_len; |
||||
|
||||
// asn1-format-icao-json.c
|
||||
extern la_asn1_formatter const asn1_icao_formatter_table_json[]; |
||||
extern size_t asn1_icao_formatter_table_json_len; |
||||
extern la_asn1_formatter const asn1_acse_formatter_table_json[]; |
||||
extern size_t asn1_acse_formatter_table_json_len; |
||||
|
||||
#endif // !_ASN1_FORMAT_ICAO_H
|
||||
@ -0,0 +1,110 @@
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is a part of dumpvdl2 |
||||
* |
||||
* Copyright (c) 2017-2026 Tomasz Lemiech <szpajder@gmail.com> |
||||
* |
||||
* 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, either 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 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 <stdint.h> |
||||
#include <search.h> // lfind() |
||||
#include <libacars/vstring.h> // la_vstring |
||||
#include <libacars/json.h> |
||||
#include <libacars/asn1-util.h> // la_asn1_formatter_params, la_asn1_output |
||||
#include "asn1/asn_application.h" // asn_TYPE_descriptor_t |
||||
#include "dumpvdl2.h" // debug_print |
||||
#include "asn1-util.h" // asn1_pdu_t |
||||
|
||||
int asn1_decode_as(asn_TYPE_descriptor_t *td, void **struct_ptr, uint8_t *buf, int size) { |
||||
asn_dec_rval_t rval; |
||||
rval = uper_decode_complete(0, td, struct_ptr, buf, size); |
||||
if(rval.code != RC_OK) { |
||||
debug_print(D_PROTO, "uper_decode_complete failed: %d\n", rval.code); |
||||
return -1; |
||||
} |
||||
if(rval.consumed < (size_t)size) { |
||||
debug_print(D_PROTO, "uper_decode_complete left %zd unparsed octets\n", |
||||
(size_t)size - rval.consumed); |
||||
return (int)((size_t)size - rval.consumed); |
||||
} |
||||
#ifdef DEBUG |
||||
if(Config.debug_filter & D_PROTO_DETAIL) { |
||||
asn_fprint(stderr, td, *struct_ptr, 1); |
||||
} |
||||
#endif |
||||
return 0; |
||||
} |
||||
|
||||
// text formatter for la_proto_nodes containing asn1_pdu_t data
|
||||
void asn1_pdu_format_text(la_vstring *vstr, void const *data, int indent) { |
||||
ASSERT(vstr != NULL); |
||||
ASSERT(data); |
||||
ASSERT(indent >= 0); |
||||
|
||||
asn1_pdu_t const *pdu = data; |
||||
if(pdu->type == NULL) { // No user data in APDU, so no decoding was attempted
|
||||
return; |
||||
} |
||||
if(pdu->data == NULL) { |
||||
LA_ISPRINTF(vstr, indent, "%s: <empty PDU>\n", pdu->type->name); |
||||
return; |
||||
} |
||||
if(Config.dump_asn1 == true) { |
||||
LA_ISPRINTF(vstr, indent, "ASN.1 dump:\n"); |
||||
// asn_fprint does not indent the first line
|
||||
LA_ISPRINTF(vstr, indent + 1, ""); |
||||
asn_sprintf(vstr, pdu->type, pdu->data, indent + 2); |
||||
EOL(vstr); |
||||
} |
||||
ASSERT(pdu->formatter_table_text != NULL); |
||||
la_asn1_output((la_asn1_formatter_params){ |
||||
.vstr = vstr, |
||||
.td = pdu->type, |
||||
.sptr = pdu->data, |
||||
.indent = indent |
||||
}, |
||||
pdu->formatter_table_text, pdu->formatter_table_text_len, true); |
||||
} |
||||
|
||||
void asn1_pdu_format_json(la_vstring *vstr, void const *data) { |
||||
ASSERT(vstr != NULL); |
||||
ASSERT(data); |
||||
|
||||
asn1_pdu_t const *pdu = data; |
||||
if(pdu->type == NULL) { // No user data in APDU - no decoding was attempted
|
||||
return; |
||||
} |
||||
if(pdu->data == NULL) { // Empty PDU
|
||||
return; |
||||
} |
||||
ASSERT(pdu->formatter_table_json != NULL); |
||||
la_asn1_output((la_asn1_formatter_params){ |
||||
.vstr = vstr, |
||||
.td = pdu->type, |
||||
.sptr = pdu->data, |
||||
}, |
||||
pdu->formatter_table_json, pdu->formatter_table_json_len, false); |
||||
} |
||||
|
||||
// a destructor for la_proto_nodes containing asn1_pdu_t data
|
||||
void asn1_pdu_destroy(void *data) { |
||||
if(data == NULL) { |
||||
return; |
||||
} |
||||
asn1_pdu_t *pdu = data; |
||||
if(pdu->type != NULL) { |
||||
pdu->type->free_struct(pdu->type, pdu->data, 0); |
||||
} |
||||
XFREE(data); |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is a part of dumpvdl2 |
||||
* |
||||
* Copyright (c) 2017-2026 Tomasz Lemiech <szpajder@gmail.com> |
||||
* |
||||
* 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, either 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 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 _ASN1_UTIL_H |
||||
#define _ASN1_UTIL_H |
||||
#include <stdint.h> // uint8_t |
||||
#include <libacars/libacars.h> // la_type_descriptor |
||||
#include <libacars/asn1-util.h> // la_asn1_formatter_params |
||||
#include "asn1/constr_TYPE.h" // asn_TYPE_descriptor_t |
||||
|
||||
// A structure for storing decoded ASN.1 payloads in a la_proto_node
|
||||
typedef struct { |
||||
asn_TYPE_descriptor_t *type; |
||||
void *data; |
||||
la_asn1_formatter const *formatter_table_text; |
||||
la_asn1_formatter const *formatter_table_json; |
||||
size_t formatter_table_text_len; |
||||
size_t formatter_table_json_len; |
||||
} asn1_pdu_t; |
||||
|
||||
// asn1-util.c
|
||||
int asn1_decode_as(asn_TYPE_descriptor_t *td, void **struct_ptr, uint8_t *buf, int size); |
||||
void asn1_pdu_format_text(la_vstring *vstr, void const *data, int indent); |
||||
void asn1_pdu_format_json(la_vstring *vstr, void const *data); |
||||
void asn1_pdu_destroy(void *data); |
||||
|
||||
#endif // _ASN1_UTIL_H
|
||||
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
Makefile.am.sample |
||||
converter-sample.c |
||||
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ADSMessageSetVersion2" |
||||
* found in "../../../dumpvdl2.asn1/atn-b2_adsc_v2.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "AAISAvailability.h" |
||||
|
||||
int |
||||
AAISAvailability_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
||||
/* Replace with underlying type checker */ |
||||
td->check_constraints = asn_DEF_BOOLEAN.check_constraints; |
||||
return td->check_constraints(td, sptr, ctfailcb, app_key); |
||||
} |
||||
|
||||
/*
|
||||
* This type is implemented using BOOLEAN, |
||||
* so here we adjust the DEF accordingly. |
||||
*/ |
||||
static void |
||||
AAISAvailability_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
||||
td->free_struct = asn_DEF_BOOLEAN.free_struct; |
||||
td->print_struct = asn_DEF_BOOLEAN.print_struct; |
||||
td->check_constraints = asn_DEF_BOOLEAN.check_constraints; |
||||
td->ber_decoder = asn_DEF_BOOLEAN.ber_decoder; |
||||
td->der_encoder = asn_DEF_BOOLEAN.der_encoder; |
||||
td->xer_decoder = asn_DEF_BOOLEAN.xer_decoder; |
||||
td->xer_encoder = asn_DEF_BOOLEAN.xer_encoder; |
||||
td->uper_decoder = asn_DEF_BOOLEAN.uper_decoder; |
||||
td->uper_encoder = asn_DEF_BOOLEAN.uper_encoder; |
||||
if(!td->per_constraints) |
||||
td->per_constraints = asn_DEF_BOOLEAN.per_constraints; |
||||
td->elements = asn_DEF_BOOLEAN.elements; |
||||
td->elements_count = asn_DEF_BOOLEAN.elements_count; |
||||
td->specifics = asn_DEF_BOOLEAN.specifics; |
||||
} |
||||
|
||||
void |
||||
AAISAvailability_free(asn_TYPE_descriptor_t *td, |
||||
void *struct_ptr, int contents_only) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
td->free_struct(td, struct_ptr, contents_only); |
||||
} |
||||
|
||||
int |
||||
AAISAvailability_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
AAISAvailability_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const void *bufptr, size_t size, int tag_mode) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
AAISAvailability_encode_der(asn_TYPE_descriptor_t *td, |
||||
void *structure, int tag_mode, ber_tlv_tag_t tag, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
AAISAvailability_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
AAISAvailability_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
||||
int ilevel, enum xer_encoder_flags_e flags, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
AAISAvailability_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
AAISAvailability_encode_uper(asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, |
||||
void *structure, asn_per_outp_t *per_out) { |
||||
AAISAvailability_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_encoder(td, constraints, structure, per_out); |
||||
} |
||||
|
||||
static const ber_tlv_tag_t asn_DEF_AAISAvailability_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (1 << 2)) |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_AAISAvailability = { |
||||
"AAISAvailability", |
||||
"AAISAvailability", |
||||
AAISAvailability_free, |
||||
AAISAvailability_print, |
||||
AAISAvailability_constraint, |
||||
AAISAvailability_decode_ber, |
||||
AAISAvailability_encode_der, |
||||
AAISAvailability_decode_xer, |
||||
AAISAvailability_encode_xer, |
||||
AAISAvailability_decode_uper, |
||||
AAISAvailability_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_AAISAvailability_tags_1, |
||||
sizeof(asn_DEF_AAISAvailability_tags_1) |
||||
/sizeof(asn_DEF_AAISAvailability_tags_1[0]), /* 1 */ |
||||
asn_DEF_AAISAvailability_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_AAISAvailability_tags_1) |
||||
/sizeof(asn_DEF_AAISAvailability_tags_1[0]), /* 1 */ |
||||
0, /* No PER visible constraints */ |
||||
0, 0, /* No members */ |
||||
0 /* No specifics */ |
||||
}; |
||||
|
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ADSMessageSetVersion2" |
||||
* found in "../../../dumpvdl2.asn1/atn-b2_adsc_v2.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _AAISAvailability_H_ |
||||
#define _AAISAvailability_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "BOOLEAN.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* AAISAvailability */ |
||||
typedef BOOLEAN_t AAISAvailability_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_AAISAvailability; |
||||
asn_struct_free_f AAISAvailability_free; |
||||
asn_struct_print_f AAISAvailability_print; |
||||
asn_constr_check_f AAISAvailability_constraint; |
||||
ber_type_decoder_f AAISAvailability_decode_ber; |
||||
der_type_encoder_f AAISAvailability_encode_der; |
||||
xer_type_decoder_f AAISAvailability_decode_xer; |
||||
xer_type_encoder_f AAISAvailability_encode_xer; |
||||
per_type_decoder_f AAISAvailability_decode_uper; |
||||
per_type_encoder_f AAISAvailability_encode_uper; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _AAISAvailability_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,193 @@
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "AARE-apdu.h" |
||||
|
||||
static asn_TYPE_member_t asn_MBR_AARE_apdu_1[] = { |
||||
{ ATF_POINTER, 1, offsetof(struct AARE_apdu, protocol_version), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_BIT_STRING, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"protocol-version" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct AARE_apdu, application_context_name), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Application_context_name, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"application-context-name" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct AARE_apdu, result), |
||||
(ASN_TAG_CLASS_CONTEXT | (2 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Associate_result, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"result" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct AARE_apdu, result_source_diagnostic), |
||||
(ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Associate_source_diagnostic, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"result-source-diagnostic" |
||||
}, |
||||
{ ATF_POINTER, 10, offsetof(struct AARE_apdu, responding_AP_title), |
||||
(ASN_TAG_CLASS_CONTEXT | (4 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_title, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responding-AP-title" |
||||
}, |
||||
{ ATF_POINTER, 9, offsetof(struct AARE_apdu, responding_AE_qualifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_qualifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responding-AE-qualifier" |
||||
}, |
||||
{ ATF_POINTER, 8, offsetof(struct AARE_apdu, responding_AP_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (6 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responding-AP-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 7, offsetof(struct AARE_apdu, responding_AE_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (7 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responding-AE-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 6, offsetof(struct AARE_apdu, responder_acse_requirements), |
||||
(ASN_TAG_CLASS_CONTEXT | (8 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_ACSE_requirements, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responder-acse-requirements" |
||||
}, |
||||
{ ATF_POINTER, 5, offsetof(struct AARE_apdu, mechanism_name), |
||||
(ASN_TAG_CLASS_CONTEXT | (9 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Mechanism_name, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"mechanism-name" |
||||
}, |
||||
{ ATF_POINTER, 4, offsetof(struct AARE_apdu, responding_authentication_value), |
||||
(ASN_TAG_CLASS_CONTEXT | (10 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Authentication_value, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"responding-authentication-value" |
||||
}, |
||||
{ ATF_POINTER, 3, offsetof(struct AARE_apdu, application_context_name_list), |
||||
(ASN_TAG_CLASS_CONTEXT | (11 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Application_context_name_list, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"application-context-name-list" |
||||
}, |
||||
{ ATF_POINTER, 2, offsetof(struct AARE_apdu, implementation_information), |
||||
(ASN_TAG_CLASS_CONTEXT | (29 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Implementation_data, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"implementation-information" |
||||
}, |
||||
{ ATF_POINTER, 1, offsetof(struct AARE_apdu, user_information), |
||||
(ASN_TAG_CLASS_CONTEXT | (30 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Association_information, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"user-information" |
||||
}, |
||||
}; |
||||
static const int asn_MAP_AARE_apdu_oms_1[] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; |
||||
static const ber_tlv_tag_t asn_DEF_AARE_apdu_tags_1[] = { |
||||
(ASN_TAG_CLASS_APPLICATION | (1 << 2)), |
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_AARE_apdu_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* protocol-version */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* application-context-name */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* result */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* result-source-diagnostic */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* responding-AP-title */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* responding-AE-qualifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* responding-AP-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* responding-AE-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 }, /* responder-acse-requirements */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 9, 0, 0 }, /* mechanism-name */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 10, 0, 0 }, /* responding-authentication-value */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 11, 0, 0 }, /* application-context-name-list */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (29 << 2)), 12, 0, 0 }, /* implementation-information */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (30 << 2)), 13, 0, 0 } /* user-information */ |
||||
}; |
||||
static asn_SEQUENCE_specifics_t asn_SPC_AARE_apdu_specs_1 = { |
||||
sizeof(struct AARE_apdu), |
||||
offsetof(struct AARE_apdu, _asn_ctx), |
||||
asn_MAP_AARE_apdu_tag2el_1, |
||||
14, /* Count of tags in the map */ |
||||
asn_MAP_AARE_apdu_oms_1, /* Optional members */ |
||||
11, 0, /* Root/Additions */ |
||||
13, /* Start extensions */ |
||||
15 /* Stop extensions */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_AARE_apdu = { |
||||
"AARE-apdu", |
||||
"AARE-apdu", |
||||
SEQUENCE_free, |
||||
SEQUENCE_print, |
||||
SEQUENCE_constraint, |
||||
SEQUENCE_decode_ber, |
||||
SEQUENCE_encode_der, |
||||
SEQUENCE_decode_xer, |
||||
SEQUENCE_encode_xer, |
||||
SEQUENCE_decode_uper, |
||||
SEQUENCE_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_AARE_apdu_tags_1, |
||||
sizeof(asn_DEF_AARE_apdu_tags_1) |
||||
/sizeof(asn_DEF_AARE_apdu_tags_1[0]) - 1, /* 1 */ |
||||
asn_DEF_AARE_apdu_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_AARE_apdu_tags_1) |
||||
/sizeof(asn_DEF_AARE_apdu_tags_1[0]), /* 2 */ |
||||
0, /* No PER visible constraints */ |
||||
asn_MBR_AARE_apdu_1, |
||||
14, /* Elements count */ |
||||
&asn_SPC_AARE_apdu_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _AARE_apdu_H_ |
||||
#define _AARE_apdu_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "BIT_STRING.h" |
||||
#include "Application-context-name.h" |
||||
#include "Associate-result.h" |
||||
#include "Associate-source-diagnostic.h" |
||||
#include "AP-invocation-identifier.h" |
||||
#include "AE-invocation-identifier.h" |
||||
#include "ACSE-requirements.h" |
||||
#include "Mechanism-name.h" |
||||
#include "Implementation-data.h" |
||||
#include "constr_SEQUENCE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum AARE_apdu__protocol_version { |
||||
AARE_apdu__protocol_version_version1 = 0 |
||||
} e_AARE_apdu__protocol_version; |
||||
|
||||
/* Forward declarations */ |
||||
struct AP_title; |
||||
struct AE_qualifier; |
||||
struct Authentication_value; |
||||
struct Application_context_name_list; |
||||
struct Association_information; |
||||
|
||||
/* AARE-apdu */ |
||||
typedef struct AARE_apdu { |
||||
BIT_STRING_t *protocol_version /* DEFAULT { version1 } */; |
||||
Application_context_name_t application_context_name; |
||||
Associate_result_t result; |
||||
Associate_source_diagnostic_t result_source_diagnostic; |
||||
struct AP_title *responding_AP_title /* OPTIONAL */; |
||||
struct AE_qualifier *responding_AE_qualifier /* OPTIONAL */; |
||||
AP_invocation_identifier_t *responding_AP_invocation_identifier /* OPTIONAL */; |
||||
AE_invocation_identifier_t *responding_AE_invocation_identifier /* OPTIONAL */; |
||||
ACSE_requirements_t *responder_acse_requirements /* OPTIONAL */; |
||||
Mechanism_name_t *mechanism_name /* OPTIONAL */; |
||||
struct Authentication_value *responding_authentication_value /* OPTIONAL */; |
||||
struct Application_context_name_list *application_context_name_list /* OPTIONAL */; |
||||
Implementation_data_t *implementation_information /* OPTIONAL */; |
||||
struct Association_information *user_information /* OPTIONAL */; |
||||
/*
|
||||
* This type is extensible, |
||||
* possible extensions are below. |
||||
*/ |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} AARE_apdu_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_AARE_apdu; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
/* Referred external types */ |
||||
#include "AP-title.h" |
||||
#include "AE-qualifier.h" |
||||
#include "Authentication-value.h" |
||||
#include "Application-context-name-list.h" |
||||
#include "Association-information.h" |
||||
|
||||
#endif /* _AARE_apdu_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,213 @@
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "AARQ-apdu.h" |
||||
|
||||
static asn_TYPE_member_t asn_MBR_AARQ_apdu_1[] = { |
||||
{ ATF_POINTER, 1, offsetof(struct AARQ_apdu, protocol_version), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_BIT_STRING, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"protocol-version" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct AARQ_apdu, application_context_name), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Application_context_name, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"application-context-name" |
||||
}, |
||||
{ ATF_POINTER, 14, offsetof(struct AARQ_apdu, called_AP_title), |
||||
(ASN_TAG_CLASS_CONTEXT | (2 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_title, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"called-AP-title" |
||||
}, |
||||
{ ATF_POINTER, 13, offsetof(struct AARQ_apdu, called_AE_qualifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_qualifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"called-AE-qualifier" |
||||
}, |
||||
{ ATF_POINTER, 12, offsetof(struct AARQ_apdu, called_AP_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (4 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"called-AP-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 11, offsetof(struct AARQ_apdu, called_AE_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"called-AE-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 10, offsetof(struct AARQ_apdu, calling_AP_title), |
||||
(ASN_TAG_CLASS_CONTEXT | (6 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_title, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"calling-AP-title" |
||||
}, |
||||
{ ATF_POINTER, 9, offsetof(struct AARQ_apdu, calling_AE_qualifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (7 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_qualifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"calling-AE-qualifier" |
||||
}, |
||||
{ ATF_POINTER, 8, offsetof(struct AARQ_apdu, calling_AP_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (8 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AP_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"calling-AP-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 7, offsetof(struct AARQ_apdu, calling_AE_invocation_identifier), |
||||
(ASN_TAG_CLASS_CONTEXT | (9 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AE_invocation_identifier, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"calling-AE-invocation-identifier" |
||||
}, |
||||
{ ATF_POINTER, 6, offsetof(struct AARQ_apdu, sender_acse_requirements), |
||||
(ASN_TAG_CLASS_CONTEXT | (10 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_ACSE_requirements, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"sender-acse-requirements" |
||||
}, |
||||
{ ATF_POINTER, 5, offsetof(struct AARQ_apdu, mechanism_name), |
||||
(ASN_TAG_CLASS_CONTEXT | (11 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Mechanism_name, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"mechanism-name" |
||||
}, |
||||
{ ATF_POINTER, 4, offsetof(struct AARQ_apdu, calling_authentication_value), |
||||
(ASN_TAG_CLASS_CONTEXT | (12 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Authentication_value, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"calling-authentication-value" |
||||
}, |
||||
{ ATF_POINTER, 3, offsetof(struct AARQ_apdu, application_context_name_list), |
||||
(ASN_TAG_CLASS_CONTEXT | (13 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Application_context_name_list, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"application-context-name-list" |
||||
}, |
||||
{ ATF_POINTER, 2, offsetof(struct AARQ_apdu, implementation_information), |
||||
(ASN_TAG_CLASS_CONTEXT | (29 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Implementation_data, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"implementation-information" |
||||
}, |
||||
{ ATF_POINTER, 1, offsetof(struct AARQ_apdu, user_information), |
||||
(ASN_TAG_CLASS_CONTEXT | (30 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Association_information, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"user-information" |
||||
}, |
||||
}; |
||||
static const int asn_MAP_AARQ_apdu_oms_1[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; |
||||
static const ber_tlv_tag_t asn_DEF_AARQ_apdu_tags_1[] = { |
||||
(ASN_TAG_CLASS_APPLICATION | (0 << 2)), |
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_AARQ_apdu_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* protocol-version */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* application-context-name */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* called-AP-title */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* called-AE-qualifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* called-AP-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* called-AE-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* calling-AP-title */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* calling-AE-qualifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 }, /* calling-AP-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 9, 0, 0 }, /* calling-AE-invocation-identifier */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 10, 0, 0 }, /* sender-acse-requirements */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 11, 0, 0 }, /* mechanism-name */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (12 << 2)), 12, 0, 0 }, /* calling-authentication-value */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (13 << 2)), 13, 0, 0 }, /* application-context-name-list */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (29 << 2)), 14, 0, 0 }, /* implementation-information */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (30 << 2)), 15, 0, 0 } /* user-information */ |
||||
}; |
||||
static asn_SEQUENCE_specifics_t asn_SPC_AARQ_apdu_specs_1 = { |
||||
sizeof(struct AARQ_apdu), |
||||
offsetof(struct AARQ_apdu, _asn_ctx), |
||||
asn_MAP_AARQ_apdu_tag2el_1, |
||||
16, /* Count of tags in the map */ |
||||
asn_MAP_AARQ_apdu_oms_1, /* Optional members */ |
||||
15, 0, /* Root/Additions */ |
||||
15, /* Start extensions */ |
||||
17 /* Stop extensions */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_AARQ_apdu = { |
||||
"AARQ-apdu", |
||||
"AARQ-apdu", |
||||
SEQUENCE_free, |
||||
SEQUENCE_print, |
||||
SEQUENCE_constraint, |
||||
SEQUENCE_decode_ber, |
||||
SEQUENCE_encode_der, |
||||
SEQUENCE_decode_xer, |
||||
SEQUENCE_encode_xer, |
||||
SEQUENCE_decode_uper, |
||||
SEQUENCE_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_AARQ_apdu_tags_1, |
||||
sizeof(asn_DEF_AARQ_apdu_tags_1) |
||||
/sizeof(asn_DEF_AARQ_apdu_tags_1[0]) - 1, /* 1 */ |
||||
asn_DEF_AARQ_apdu_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_AARQ_apdu_tags_1) |
||||
/sizeof(asn_DEF_AARQ_apdu_tags_1[0]), /* 2 */ |
||||
0, /* No PER visible constraints */ |
||||
asn_MBR_AARQ_apdu_1, |
||||
16, /* Elements count */ |
||||
&asn_SPC_AARQ_apdu_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _AARQ_apdu_H_ |
||||
#define _AARQ_apdu_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "BIT_STRING.h" |
||||
#include "Application-context-name.h" |
||||
#include "AP-invocation-identifier.h" |
||||
#include "AE-invocation-identifier.h" |
||||
#include "ACSE-requirements.h" |
||||
#include "Mechanism-name.h" |
||||
#include "Implementation-data.h" |
||||
#include "constr_SEQUENCE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum AARQ_apdu__protocol_version { |
||||
AARQ_apdu__protocol_version_version1 = 0 |
||||
} e_AARQ_apdu__protocol_version; |
||||
|
||||
/* Forward declarations */ |
||||
struct AP_title; |
||||
struct AE_qualifier; |
||||
struct Authentication_value; |
||||
struct Application_context_name_list; |
||||
struct Association_information; |
||||
|
||||
/* AARQ-apdu */ |
||||
typedef struct AARQ_apdu { |
||||
BIT_STRING_t *protocol_version /* DEFAULT { version1 } */; |
||||
Application_context_name_t application_context_name; |
||||
struct AP_title *called_AP_title /* OPTIONAL */; |
||||
struct AE_qualifier *called_AE_qualifier /* OPTIONAL */; |
||||
AP_invocation_identifier_t *called_AP_invocation_identifier /* OPTIONAL */; |
||||
AE_invocation_identifier_t *called_AE_invocation_identifier /* OPTIONAL */; |
||||
struct AP_title *calling_AP_title /* OPTIONAL */; |
||||
struct AE_qualifier *calling_AE_qualifier /* OPTIONAL */; |
||||
AP_invocation_identifier_t *calling_AP_invocation_identifier /* OPTIONAL */; |
||||
AE_invocation_identifier_t *calling_AE_invocation_identifier /* OPTIONAL */; |
||||
ACSE_requirements_t *sender_acse_requirements /* OPTIONAL */; |
||||
Mechanism_name_t *mechanism_name /* OPTIONAL */; |
||||
struct Authentication_value *calling_authentication_value /* OPTIONAL */; |
||||
struct Application_context_name_list *application_context_name_list /* OPTIONAL */; |
||||
Implementation_data_t *implementation_information /* OPTIONAL */; |
||||
struct Association_information *user_information /* OPTIONAL */; |
||||
/*
|
||||
* This type is extensible, |
||||
* possible extensions are below. |
||||
*/ |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} AARQ_apdu_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_AARQ_apdu; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
/* Referred external types */ |
||||
#include "AP-title.h" |
||||
#include "AE-qualifier.h" |
||||
#include "Authentication-value.h" |
||||
#include "Application-context-name-list.h" |
||||
#include "Association-information.h" |
||||
|
||||
#endif /* _AARQ_apdu_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ABRT-apdu.h" |
||||
|
||||
static asn_TYPE_member_t asn_MBR_ABRT_apdu_1[] = { |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ABRT_apdu, abort_source), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_ABRT_source, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"abort-source" |
||||
}, |
||||
{ ATF_POINTER, 2, offsetof(struct ABRT_apdu, abort_diagnostic), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_ABRT_diagnostic, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"abort-diagnostic" |
||||
}, |
||||
{ ATF_POINTER, 1, offsetof(struct ABRT_apdu, user_information), |
||||
(ASN_TAG_CLASS_CONTEXT | (30 << 2)), |
||||
-1, /* IMPLICIT tag at current level */ |
||||
&asn_DEF_Association_information, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"user-information" |
||||
}, |
||||
}; |
||||
static const int asn_MAP_ABRT_apdu_oms_1[] = { 1, 2 }; |
||||
static const ber_tlv_tag_t asn_DEF_ABRT_apdu_tags_1[] = { |
||||
(ASN_TAG_CLASS_APPLICATION | (4 << 2)), |
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_ABRT_apdu_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* abort-source */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* abort-diagnostic */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (30 << 2)), 2, 0, 0 } /* user-information */ |
||||
}; |
||||
static asn_SEQUENCE_specifics_t asn_SPC_ABRT_apdu_specs_1 = { |
||||
sizeof(struct ABRT_apdu), |
||||
offsetof(struct ABRT_apdu, _asn_ctx), |
||||
asn_MAP_ABRT_apdu_tag2el_1, |
||||
3, /* Count of tags in the map */ |
||||
asn_MAP_ABRT_apdu_oms_1, /* Optional members */ |
||||
2, 0, /* Root/Additions */ |
||||
2, /* Start extensions */ |
||||
4 /* Stop extensions */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ABRT_apdu = { |
||||
"ABRT-apdu", |
||||
"ABRT-apdu", |
||||
SEQUENCE_free, |
||||
SEQUENCE_print, |
||||
SEQUENCE_constraint, |
||||
SEQUENCE_decode_ber, |
||||
SEQUENCE_encode_der, |
||||
SEQUENCE_decode_xer, |
||||
SEQUENCE_encode_xer, |
||||
SEQUENCE_decode_uper, |
||||
SEQUENCE_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ABRT_apdu_tags_1, |
||||
sizeof(asn_DEF_ABRT_apdu_tags_1) |
||||
/sizeof(asn_DEF_ABRT_apdu_tags_1[0]) - 1, /* 1 */ |
||||
asn_DEF_ABRT_apdu_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ABRT_apdu_tags_1) |
||||
/sizeof(asn_DEF_ABRT_apdu_tags_1[0]), /* 2 */ |
||||
0, /* No PER visible constraints */ |
||||
asn_MBR_ABRT_apdu_1, |
||||
3, /* Elements count */ |
||||
&asn_SPC_ABRT_apdu_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ABRT_apdu_H_ |
||||
#define _ABRT_apdu_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "ABRT-source.h" |
||||
#include "ABRT-diagnostic.h" |
||||
#include "constr_SEQUENCE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Forward declarations */ |
||||
struct Association_information; |
||||
|
||||
/* ABRT-apdu */ |
||||
typedef struct ABRT_apdu { |
||||
ABRT_source_t abort_source; |
||||
ABRT_diagnostic_t *abort_diagnostic /* OPTIONAL */; |
||||
struct Association_information *user_information /* OPTIONAL */; |
||||
/*
|
||||
* This type is extensible, |
||||
* possible extensions are below. |
||||
*/ |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} ABRT_apdu_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ABRT_apdu; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
/* Referred external types */ |
||||
#include "Association-information.h" |
||||
|
||||
#endif /* _ABRT_apdu_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ABRT-diagnostic.h" |
||||
|
||||
int |
||||
ABRT_diagnostic_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
||||
/* Replace with underlying type checker */ |
||||
td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; |
||||
return td->check_constraints(td, sptr, ctfailcb, app_key); |
||||
} |
||||
|
||||
/*
|
||||
* This type is implemented using NativeEnumerated, |
||||
* so here we adjust the DEF accordingly. |
||||
*/ |
||||
static void |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
||||
td->free_struct = asn_DEF_NativeEnumerated.free_struct; |
||||
td->print_struct = asn_DEF_NativeEnumerated.print_struct; |
||||
td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; |
||||
td->ber_decoder = asn_DEF_NativeEnumerated.ber_decoder; |
||||
td->der_encoder = asn_DEF_NativeEnumerated.der_encoder; |
||||
td->xer_decoder = asn_DEF_NativeEnumerated.xer_decoder; |
||||
td->xer_encoder = asn_DEF_NativeEnumerated.xer_encoder; |
||||
td->uper_decoder = asn_DEF_NativeEnumerated.uper_decoder; |
||||
td->uper_encoder = asn_DEF_NativeEnumerated.uper_encoder; |
||||
if(!td->per_constraints) |
||||
td->per_constraints = asn_DEF_NativeEnumerated.per_constraints; |
||||
td->elements = asn_DEF_NativeEnumerated.elements; |
||||
td->elements_count = asn_DEF_NativeEnumerated.elements_count; |
||||
/* td->specifics = asn_DEF_NativeEnumerated.specifics; // Defined explicitly */ |
||||
} |
||||
|
||||
void |
||||
ABRT_diagnostic_free(asn_TYPE_descriptor_t *td, |
||||
void *struct_ptr, int contents_only) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
td->free_struct(td, struct_ptr, contents_only); |
||||
} |
||||
|
||||
int |
||||
ABRT_diagnostic_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_diagnostic_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const void *bufptr, size_t size, int tag_mode) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_diagnostic_encode_der(asn_TYPE_descriptor_t *td, |
||||
void *structure, int tag_mode, ber_tlv_tag_t tag, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_diagnostic_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_diagnostic_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
||||
int ilevel, enum xer_encoder_flags_e flags, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_diagnostic_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_diagnostic_encode_uper(asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, |
||||
void *structure, asn_per_outp_t *per_out) { |
||||
ABRT_diagnostic_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_encoder(td, constraints, structure, per_out); |
||||
} |
||||
|
||||
static asn_per_constraints_t asn_PER_type_ABRT_diagnostic_constr_1 GCC_NOTUSED = { |
||||
{ APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 5 } /* (0..5,...) */, |
||||
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, |
||||
0, 0 /* No PER value map */ |
||||
}; |
||||
static const asn_INTEGER_enum_map_t asn_MAP_ABRT_diagnostic_value2enum_1[] = { |
||||
{ 1, 15, "no-reason-given" }, |
||||
{ 2, 14, "protocol-error" }, |
||||
{ 3, 44, "authentication-mechanism-name-not-recognized" }, |
||||
{ 4, 38, "authentication-mechanism-name-required" }, |
||||
{ 5, 22, "authentication-failure" }, |
||||
{ 6, 23, "authentication-required" } |
||||
/* This list is extensible */ |
||||
}; |
||||
static const unsigned int asn_MAP_ABRT_diagnostic_enum2value_1[] = { |
||||
4, /* authentication-failure(5) */ |
||||
2, /* authentication-mechanism-name-not-recognized(3) */ |
||||
3, /* authentication-mechanism-name-required(4) */ |
||||
5, /* authentication-required(6) */ |
||||
0, /* no-reason-given(1) */ |
||||
1 /* protocol-error(2) */ |
||||
/* This list is extensible */ |
||||
}; |
||||
static const asn_INTEGER_specifics_t asn_SPC_ABRT_diagnostic_specs_1 = { |
||||
asn_MAP_ABRT_diagnostic_value2enum_1, /* "tag" => N; sorted by tag */ |
||||
asn_MAP_ABRT_diagnostic_enum2value_1, /* N => "tag"; sorted by N */ |
||||
6, /* Number of elements in the maps */ |
||||
7, /* Extensions before this member */ |
||||
1, /* Strict enumeration */ |
||||
0, /* Native long size */ |
||||
0 |
||||
}; |
||||
static const ber_tlv_tag_t asn_DEF_ABRT_diagnostic_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ABRT_diagnostic = { |
||||
"ABRT-diagnostic", |
||||
"ABRT-diagnostic", |
||||
ABRT_diagnostic_free, |
||||
ABRT_diagnostic_print, |
||||
ABRT_diagnostic_constraint, |
||||
ABRT_diagnostic_decode_ber, |
||||
ABRT_diagnostic_encode_der, |
||||
ABRT_diagnostic_decode_xer, |
||||
ABRT_diagnostic_encode_xer, |
||||
ABRT_diagnostic_decode_uper, |
||||
ABRT_diagnostic_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ABRT_diagnostic_tags_1, |
||||
sizeof(asn_DEF_ABRT_diagnostic_tags_1) |
||||
/sizeof(asn_DEF_ABRT_diagnostic_tags_1[0]), /* 1 */ |
||||
asn_DEF_ABRT_diagnostic_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ABRT_diagnostic_tags_1) |
||||
/sizeof(asn_DEF_ABRT_diagnostic_tags_1[0]), /* 1 */ |
||||
&asn_PER_type_ABRT_diagnostic_constr_1, |
||||
0, 0, /* Defined elsewhere */ |
||||
&asn_SPC_ABRT_diagnostic_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ABRT_diagnostic_H_ |
||||
#define _ABRT_diagnostic_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "NativeEnumerated.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum ABRT_diagnostic { |
||||
ABRT_diagnostic_no_reason_given = 1, |
||||
ABRT_diagnostic_protocol_error = 2, |
||||
ABRT_diagnostic_authentication_mechanism_name_not_recognized = 3, |
||||
ABRT_diagnostic_authentication_mechanism_name_required = 4, |
||||
ABRT_diagnostic_authentication_failure = 5, |
||||
ABRT_diagnostic_authentication_required = 6 |
||||
/*
|
||||
* Enumeration is extensible |
||||
*/ |
||||
} e_ABRT_diagnostic; |
||||
|
||||
/* ABRT-diagnostic */ |
||||
typedef long ABRT_diagnostic_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ABRT_diagnostic; |
||||
asn_struct_free_f ABRT_diagnostic_free; |
||||
asn_struct_print_f ABRT_diagnostic_print; |
||||
asn_constr_check_f ABRT_diagnostic_constraint; |
||||
ber_type_decoder_f ABRT_diagnostic_decode_ber; |
||||
der_type_encoder_f ABRT_diagnostic_encode_der; |
||||
xer_type_decoder_f ABRT_diagnostic_decode_xer; |
||||
xer_type_encoder_f ABRT_diagnostic_encode_xer; |
||||
per_type_decoder_f ABRT_diagnostic_decode_uper; |
||||
per_type_encoder_f ABRT_diagnostic_encode_uper; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ABRT_diagnostic_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,147 @@
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ABRT-source.h" |
||||
|
||||
int |
||||
ABRT_source_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
||||
long value; |
||||
|
||||
if(!sptr) { |
||||
ASN__CTFAIL(app_key, td, sptr, |
||||
"%s: value not given (%s:%d)", |
||||
td->name, __FILE__, __LINE__); |
||||
return -1; |
||||
} |
||||
|
||||
value = *(const long *)sptr; |
||||
|
||||
if((value >= 0 && value <= 1)) { |
||||
/* Constraint check succeeded */ |
||||
return 0; |
||||
} else { |
||||
ASN__CTFAIL(app_key, td, sptr, |
||||
"%s: constraint failed (%s:%d)", |
||||
td->name, __FILE__, __LINE__); |
||||
return -1; |
||||
} |
||||
} |
||||
|
||||
/*
|
||||
* This type is implemented using NativeInteger, |
||||
* so here we adjust the DEF accordingly. |
||||
*/ |
||||
static void |
||||
ABRT_source_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
||||
td->free_struct = asn_DEF_NativeInteger.free_struct; |
||||
td->print_struct = asn_DEF_NativeInteger.print_struct; |
||||
td->check_constraints = asn_DEF_NativeInteger.check_constraints; |
||||
td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; |
||||
td->der_encoder = asn_DEF_NativeInteger.der_encoder; |
||||
td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; |
||||
td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; |
||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; |
||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; |
||||
if(!td->per_constraints) |
||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints; |
||||
td->elements = asn_DEF_NativeInteger.elements; |
||||
td->elements_count = asn_DEF_NativeInteger.elements_count; |
||||
td->specifics = asn_DEF_NativeInteger.specifics; |
||||
} |
||||
|
||||
void |
||||
ABRT_source_free(asn_TYPE_descriptor_t *td, |
||||
void *struct_ptr, int contents_only) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
td->free_struct(td, struct_ptr, contents_only); |
||||
} |
||||
|
||||
int |
||||
ABRT_source_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_source_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const void *bufptr, size_t size, int tag_mode) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_source_encode_der(asn_TYPE_descriptor_t *td, |
||||
void *structure, int tag_mode, ber_tlv_tag_t tag, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_source_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_source_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
||||
int ilevel, enum xer_encoder_flags_e flags, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ABRT_source_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ABRT_source_encode_uper(asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, |
||||
void *structure, asn_per_outp_t *per_out) { |
||||
ABRT_source_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_encoder(td, constraints, structure, per_out); |
||||
} |
||||
|
||||
static asn_per_constraints_t asn_PER_type_ABRT_source_constr_1 GCC_NOTUSED = { |
||||
{ APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */, |
||||
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, |
||||
0, 0 /* No PER value map */ |
||||
}; |
||||
static const ber_tlv_tag_t asn_DEF_ABRT_source_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ABRT_source = { |
||||
"ABRT-source", |
||||
"ABRT-source", |
||||
ABRT_source_free, |
||||
ABRT_source_print, |
||||
ABRT_source_constraint, |
||||
ABRT_source_decode_ber, |
||||
ABRT_source_encode_der, |
||||
ABRT_source_decode_xer, |
||||
ABRT_source_encode_xer, |
||||
ABRT_source_decode_uper, |
||||
ABRT_source_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ABRT_source_tags_1, |
||||
sizeof(asn_DEF_ABRT_source_tags_1) |
||||
/sizeof(asn_DEF_ABRT_source_tags_1[0]), /* 1 */ |
||||
asn_DEF_ABRT_source_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ABRT_source_tags_1) |
||||
/sizeof(asn_DEF_ABRT_source_tags_1[0]), /* 1 */ |
||||
&asn_PER_type_ABRT_source_constr_1, |
||||
0, 0, /* Defined elsewhere */ |
||||
0 /* No specifics */ |
||||
}; |
||||
|
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ABRT_source_H_ |
||||
#define _ABRT_source_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "NativeInteger.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum ABRT_source { |
||||
ABRT_source_acse_service_user = 0, |
||||
ABRT_source_acse_service_provider = 1 |
||||
} e_ABRT_source; |
||||
|
||||
/* ABRT-source */ |
||||
typedef long ABRT_source_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ABRT_source; |
||||
asn_struct_free_f ABRT_source_free; |
||||
asn_struct_print_f ABRT_source_print; |
||||
asn_constr_check_f ABRT_source_constraint; |
||||
ber_type_decoder_f ABRT_source_decode_ber; |
||||
der_type_encoder_f ABRT_source_encode_der; |
||||
xer_type_decoder_f ABRT_source_decode_xer; |
||||
xer_type_encoder_f ABRT_source_encode_xer; |
||||
per_type_decoder_f ABRT_source_decode_uper; |
||||
per_type_encoder_f ABRT_source_encode_uper; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ABRT_source_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,101 @@
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ACSE-apdu.h" |
||||
|
||||
static asn_per_constraints_t asn_PER_type_ACSE_apdu_constr_1 GCC_NOTUSED = { |
||||
{ APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 4 } /* (0..4,...) */, |
||||
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, |
||||
0, 0 /* No PER value map */ |
||||
}; |
||||
static asn_TYPE_member_t asn_MBR_ACSE_apdu_1[] = { |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.aarq), |
||||
(ASN_TAG_CLASS_APPLICATION | (0 << 2)), |
||||
0, |
||||
&asn_DEF_AARQ_apdu, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aarq" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.aare), |
||||
(ASN_TAG_CLASS_APPLICATION | (1 << 2)), |
||||
0, |
||||
&asn_DEF_AARE_apdu, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aare" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.rlrq), |
||||
(ASN_TAG_CLASS_APPLICATION | (2 << 2)), |
||||
0, |
||||
&asn_DEF_RLRQ_apdu, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"rlrq" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.rlre), |
||||
(ASN_TAG_CLASS_APPLICATION | (3 << 2)), |
||||
0, |
||||
&asn_DEF_RLRE_apdu, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"rlre" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.abrt), |
||||
(ASN_TAG_CLASS_APPLICATION | (4 << 2)), |
||||
0, |
||||
&asn_DEF_ABRT_apdu, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"abrt" |
||||
}, |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_ACSE_apdu_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_APPLICATION | (0 << 2)), 0, 0, 0 }, /* aarq */ |
||||
{ (ASN_TAG_CLASS_APPLICATION | (1 << 2)), 1, 0, 0 }, /* aare */ |
||||
{ (ASN_TAG_CLASS_APPLICATION | (2 << 2)), 2, 0, 0 }, /* rlrq */ |
||||
{ (ASN_TAG_CLASS_APPLICATION | (3 << 2)), 3, 0, 0 }, /* rlre */ |
||||
{ (ASN_TAG_CLASS_APPLICATION | (4 << 2)), 4, 0, 0 } /* abrt */ |
||||
}; |
||||
static asn_CHOICE_specifics_t asn_SPC_ACSE_apdu_specs_1 = { |
||||
sizeof(struct ACSE_apdu), |
||||
offsetof(struct ACSE_apdu, _asn_ctx), |
||||
offsetof(struct ACSE_apdu, present), |
||||
sizeof(((struct ACSE_apdu *)0)->present), |
||||
asn_MAP_ACSE_apdu_tag2el_1, |
||||
5, /* Count of tags in the map */ |
||||
0, |
||||
5 /* Extensions start */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ACSE_apdu = { |
||||
"ACSE-apdu", |
||||
"ACSE-apdu", |
||||
CHOICE_free, |
||||
CHOICE_print, |
||||
CHOICE_constraint, |
||||
CHOICE_decode_ber, |
||||
CHOICE_encode_der, |
||||
CHOICE_decode_xer, |
||||
CHOICE_encode_xer, |
||||
CHOICE_decode_uper, |
||||
CHOICE_encode_uper, |
||||
CHOICE_outmost_tag, |
||||
0, /* No effective tags (pointer) */ |
||||
0, /* No effective tags (count) */ |
||||
0, /* No tags (pointer) */ |
||||
0, /* No tags (count) */ |
||||
&asn_PER_type_ACSE_apdu_constr_1, |
||||
asn_MBR_ACSE_apdu_1, |
||||
5, /* Elements count */ |
||||
&asn_SPC_ACSE_apdu_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ACSE_apdu_H_ |
||||
#define _ACSE_apdu_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "AARQ-apdu.h" |
||||
#include "AARE-apdu.h" |
||||
#include "RLRQ-apdu.h" |
||||
#include "RLRE-apdu.h" |
||||
#include "ABRT-apdu.h" |
||||
#include "constr_CHOICE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum ACSE_apdu_PR { |
||||
ACSE_apdu_PR_NOTHING, /* No components present */ |
||||
ACSE_apdu_PR_aarq, |
||||
ACSE_apdu_PR_aare, |
||||
ACSE_apdu_PR_rlrq, |
||||
ACSE_apdu_PR_rlre, |
||||
ACSE_apdu_PR_abrt, |
||||
/* Extensions may appear below */ |
||||
|
||||
} ACSE_apdu_PR; |
||||
|
||||
/* ACSE-apdu */ |
||||
typedef struct ACSE_apdu { |
||||
ACSE_apdu_PR present; |
||||
union ACSE_apdu_u { |
||||
AARQ_apdu_t aarq; |
||||
AARE_apdu_t aare; |
||||
RLRQ_apdu_t rlrq; |
||||
RLRE_apdu_t rlre; |
||||
ABRT_apdu_t abrt; |
||||
/*
|
||||
* This type is extensible, |
||||
* possible extensions are below. |
||||
*/ |
||||
} choice; |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} ACSE_apdu_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ACSE_apdu; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ACSE_apdu_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ACSE-requirements.h" |
||||
|
||||
int |
||||
ACSE_requirements_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
||||
/* Replace with underlying type checker */ |
||||
td->check_constraints = asn_DEF_BIT_STRING.check_constraints; |
||||
return td->check_constraints(td, sptr, ctfailcb, app_key); |
||||
} |
||||
|
||||
/*
|
||||
* This type is implemented using BIT_STRING, |
||||
* so here we adjust the DEF accordingly. |
||||
*/ |
||||
static void |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
||||
td->free_struct = asn_DEF_BIT_STRING.free_struct; |
||||
td->print_struct = asn_DEF_BIT_STRING.print_struct; |
||||
td->check_constraints = asn_DEF_BIT_STRING.check_constraints; |
||||
td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; |
||||
td->der_encoder = asn_DEF_BIT_STRING.der_encoder; |
||||
td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; |
||||
td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; |
||||
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; |
||||
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; |
||||
if(!td->per_constraints) |
||||
td->per_constraints = asn_DEF_BIT_STRING.per_constraints; |
||||
td->elements = asn_DEF_BIT_STRING.elements; |
||||
td->elements_count = asn_DEF_BIT_STRING.elements_count; |
||||
td->specifics = asn_DEF_BIT_STRING.specifics; |
||||
} |
||||
|
||||
void |
||||
ACSE_requirements_free(asn_TYPE_descriptor_t *td, |
||||
void *struct_ptr, int contents_only) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
td->free_struct(td, struct_ptr, contents_only); |
||||
} |
||||
|
||||
int |
||||
ACSE_requirements_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ACSE_requirements_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const void *bufptr, size_t size, int tag_mode) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ACSE_requirements_encode_der(asn_TYPE_descriptor_t *td, |
||||
void *structure, int tag_mode, ber_tlv_tag_t tag, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ACSE_requirements_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ACSE_requirements_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
||||
int ilevel, enum xer_encoder_flags_e flags, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ACSE_requirements_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ACSE_requirements_encode_uper(asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, |
||||
void *structure, asn_per_outp_t *per_out) { |
||||
ACSE_requirements_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_encoder(td, constraints, structure, per_out); |
||||
} |
||||
|
||||
static const ber_tlv_tag_t asn_DEF_ACSE_requirements_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ACSE_requirements = { |
||||
"ACSE-requirements", |
||||
"ACSE-requirements", |
||||
ACSE_requirements_free, |
||||
ACSE_requirements_print, |
||||
ACSE_requirements_constraint, |
||||
ACSE_requirements_decode_ber, |
||||
ACSE_requirements_encode_der, |
||||
ACSE_requirements_decode_xer, |
||||
ACSE_requirements_encode_xer, |
||||
ACSE_requirements_decode_uper, |
||||
ACSE_requirements_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ACSE_requirements_tags_1, |
||||
sizeof(asn_DEF_ACSE_requirements_tags_1) |
||||
/sizeof(asn_DEF_ACSE_requirements_tags_1[0]), /* 1 */ |
||||
asn_DEF_ACSE_requirements_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ACSE_requirements_tags_1) |
||||
/sizeof(asn_DEF_ACSE_requirements_tags_1[0]), /* 1 */ |
||||
0, /* No PER visible constraints */ |
||||
0, 0, /* Defined elsewhere */ |
||||
0 /* No specifics */ |
||||
}; |
||||
|
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ACSE-1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ACSE_requirements_H_ |
||||
#define _ACSE_requirements_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "BIT_STRING.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum ACSE_requirements { |
||||
ACSE_requirements_authentication = 0, |
||||
ACSE_requirements_application_context_negotiation = 1 |
||||
} e_ACSE_requirements; |
||||
|
||||
/* ACSE-requirements */ |
||||
typedef BIT_STRING_t ACSE_requirements_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ACSE_requirements; |
||||
asn_struct_free_f ACSE_requirements_free; |
||||
asn_struct_print_f ACSE_requirements_print; |
||||
asn_constr_check_f ACSE_requirements_constraint; |
||||
ber_type_decoder_f ACSE_requirements_decode_ber; |
||||
der_type_encoder_f ACSE_requirements_encode_der; |
||||
xer_type_decoder_f ACSE_requirements_decode_xer; |
||||
xer_type_encoder_f ACSE_requirements_encode_xer; |
||||
per_type_decoder_f ACSE_requirements_decode_uper; |
||||
per_type_encoder_f ACSE_requirements_encode_uper; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ACSE_requirements_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ADSMessageSetVersion2" |
||||
* found in "../../../dumpvdl2.asn1/atn-b2_adsc_v2.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ADSAccept.h" |
||||
|
||||
int |
||||
ADSAccept_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
||||
/* Replace with underlying type checker */ |
||||
td->check_constraints = asn_DEF_ADSReport.check_constraints; |
||||
return td->check_constraints(td, sptr, ctfailcb, app_key); |
||||
} |
||||
|
||||
/*
|
||||
* This type is implemented using ADSReport, |
||||
* so here we adjust the DEF accordingly. |
||||
*/ |
||||
static void |
||||
ADSAccept_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
||||
td->free_struct = asn_DEF_ADSReport.free_struct; |
||||
td->print_struct = asn_DEF_ADSReport.print_struct; |
||||
td->check_constraints = asn_DEF_ADSReport.check_constraints; |
||||
td->ber_decoder = asn_DEF_ADSReport.ber_decoder; |
||||
td->der_encoder = asn_DEF_ADSReport.der_encoder; |
||||
td->xer_decoder = asn_DEF_ADSReport.xer_decoder; |
||||
td->xer_encoder = asn_DEF_ADSReport.xer_encoder; |
||||
td->uper_decoder = asn_DEF_ADSReport.uper_decoder; |
||||
td->uper_encoder = asn_DEF_ADSReport.uper_encoder; |
||||
if(!td->per_constraints) |
||||
td->per_constraints = asn_DEF_ADSReport.per_constraints; |
||||
td->elements = asn_DEF_ADSReport.elements; |
||||
td->elements_count = asn_DEF_ADSReport.elements_count; |
||||
td->specifics = asn_DEF_ADSReport.specifics; |
||||
} |
||||
|
||||
void |
||||
ADSAccept_free(asn_TYPE_descriptor_t *td, |
||||
void *struct_ptr, int contents_only) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
td->free_struct(td, struct_ptr, contents_only); |
||||
} |
||||
|
||||
int |
||||
ADSAccept_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ADSAccept_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const void *bufptr, size_t size, int tag_mode) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ADSAccept_encode_der(asn_TYPE_descriptor_t *td, |
||||
void *structure, int tag_mode, ber_tlv_tag_t tag, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ADSAccept_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ADSAccept_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
||||
int ilevel, enum xer_encoder_flags_e flags, |
||||
asn_app_consume_bytes_f *cb, void *app_key) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
||||
} |
||||
|
||||
asn_dec_rval_t |
||||
ADSAccept_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); |
||||
} |
||||
|
||||
asn_enc_rval_t |
||||
ADSAccept_encode_uper(asn_TYPE_descriptor_t *td, |
||||
asn_per_constraints_t *constraints, |
||||
void *structure, asn_per_outp_t *per_out) { |
||||
ADSAccept_1_inherit_TYPE_descriptor(td); |
||||
return td->uper_encoder(td, constraints, structure, per_out); |
||||
} |
||||
|
||||
static asn_per_constraints_t asn_PER_type_ADSAccept_constr_1 GCC_NOTUSED = { |
||||
{ APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, |
||||
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, |
||||
0, 0 /* No PER value map */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ADSAccept = { |
||||
"ADSAccept", |
||||
"ADSAccept", |
||||
ADSAccept_free, |
||||
ADSAccept_print, |
||||
ADSAccept_constraint, |
||||
ADSAccept_decode_ber, |
||||
ADSAccept_encode_der, |
||||
ADSAccept_decode_xer, |
||||
ADSAccept_encode_xer, |
||||
ADSAccept_decode_uper, |
||||
ADSAccept_encode_uper, |
||||
CHOICE_outmost_tag, |
||||
0, /* No effective tags (pointer) */ |
||||
0, /* No effective tags (count) */ |
||||
0, /* No tags (pointer) */ |
||||
0, /* No tags (count) */ |
||||
0, /* No PER visible constraints */ |
||||
0, 0, /* Defined elsewhere */ |
||||
0 /* No specifics */ |
||||
}; |
||||
|
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ADSMessageSetVersion2" |
||||
* found in "../../../dumpvdl2.asn1/atn-b2_adsc_v2.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ADSAccept_H_ |
||||
#define _ADSAccept_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "ADSReport.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* ADSAccept */ |
||||
typedef ADSReport_t ADSAccept_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ADSAccept; |
||||
asn_struct_free_f ADSAccept_free; |
||||
asn_struct_print_f ADSAccept_print; |
||||
asn_constr_check_f ADSAccept_constraint; |
||||
ber_type_decoder_f ADSAccept_decode_ber; |
||||
der_type_encoder_f ADSAccept_encode_der; |
||||
xer_type_decoder_f ADSAccept_decode_xer; |
||||
xer_type_encoder_f ADSAccept_encode_xer; |
||||
per_type_decoder_f ADSAccept_decode_uper; |
||||
per_type_encoder_f ADSAccept_encode_uper; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ADSAccept_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,141 @@
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "PMADSCAPDUVersion1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_pmadsc.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ADSAircraftPDU.h" |
||||
|
||||
static asn_per_constraints_t asn_PER_type_ADSAircraftPDU_constr_1 GCC_NOTUSED = { |
||||
{ APC_CONSTRAINED | APC_EXTENSIBLE, 4, 4, 0, 8 } /* (0..8,...) */, |
||||
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, |
||||
0, 0 /* No PER value map */ |
||||
}; |
||||
static asn_TYPE_member_t asn_MBR_ADSAircraftPDU_1[] = { |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_report_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Report, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-report-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_accepted_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Report, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-accepted-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_rejected_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (2 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Reject, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-rejected-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_ncn_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_NonCompliance, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-ncn-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_positive_acknowledgement_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (4 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_PositiveAcknowledgement, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-positive-acknowledgement-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_cancel_positive_acknowledgement_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_CancelPositiveAcknowledgement, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-cancel-positive-acknowledgement-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_cancel_negative_acknowledgement_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (6 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_CancelRejectReason, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-cancel-negative-acknowledgement-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_provider_abort_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (7 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ProviderAbortReason, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-provider-abort-PDU" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDU, choice.aDS_user_abort_PDU), |
||||
(ASN_TAG_CLASS_CONTEXT | (8 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_UserAbortReason, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"aDS-user-abort-PDU" |
||||
}, |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_ADSAircraftPDU_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* aDS-report-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* aDS-accepted-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* aDS-rejected-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* aDS-ncn-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* aDS-positive-acknowledgement-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* aDS-cancel-positive-acknowledgement-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* aDS-cancel-negative-acknowledgement-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* aDS-provider-abort-PDU */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 } /* aDS-user-abort-PDU */ |
||||
}; |
||||
static asn_CHOICE_specifics_t asn_SPC_ADSAircraftPDU_specs_1 = { |
||||
sizeof(struct ADSAircraftPDU), |
||||
offsetof(struct ADSAircraftPDU, _asn_ctx), |
||||
offsetof(struct ADSAircraftPDU, present), |
||||
sizeof(((struct ADSAircraftPDU *)0)->present), |
||||
asn_MAP_ADSAircraftPDU_tag2el_1, |
||||
9, /* Count of tags in the map */ |
||||
0, |
||||
9 /* Extensions start */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ADSAircraftPDU = { |
||||
"ADSAircraftPDU", |
||||
"ADSAircraftPDU", |
||||
CHOICE_free, |
||||
CHOICE_print, |
||||
CHOICE_constraint, |
||||
CHOICE_decode_ber, |
||||
CHOICE_encode_der, |
||||
CHOICE_decode_xer, |
||||
CHOICE_encode_xer, |
||||
CHOICE_decode_uper, |
||||
CHOICE_encode_uper, |
||||
CHOICE_outmost_tag, |
||||
0, /* No effective tags (pointer) */ |
||||
0, /* No effective tags (count) */ |
||||
0, /* No tags (pointer) */ |
||||
0, /* No tags (count) */ |
||||
&asn_PER_type_ADSAircraftPDU_constr_1, |
||||
asn_MBR_ADSAircraftPDU_1, |
||||
9, /* Elements count */ |
||||
&asn_SPC_ADSAircraftPDU_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "PMADSCAPDUVersion1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_pmadsc.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ADSAircraftPDU_H_ |
||||
#define _ADSAircraftPDU_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "Report.h" |
||||
#include "Reject.h" |
||||
#include "NonCompliance.h" |
||||
#include "PositiveAcknowledgement.h" |
||||
#include "CancelPositiveAcknowledgement.h" |
||||
#include "CancelRejectReason.h" |
||||
#include "ProviderAbortReason.h" |
||||
#include "UserAbortReason.h" |
||||
#include "constr_CHOICE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Dependencies */ |
||||
typedef enum ADSAircraftPDU_PR { |
||||
ADSAircraftPDU_PR_NOTHING, /* No components present */ |
||||
ADSAircraftPDU_PR_aDS_report_PDU, |
||||
ADSAircraftPDU_PR_aDS_accepted_PDU, |
||||
ADSAircraftPDU_PR_aDS_rejected_PDU, |
||||
ADSAircraftPDU_PR_aDS_ncn_PDU, |
||||
ADSAircraftPDU_PR_aDS_positive_acknowledgement_PDU, |
||||
ADSAircraftPDU_PR_aDS_cancel_positive_acknowledgement_PDU, |
||||
ADSAircraftPDU_PR_aDS_cancel_negative_acknowledgement_PDU, |
||||
ADSAircraftPDU_PR_aDS_provider_abort_PDU, |
||||
ADSAircraftPDU_PR_aDS_user_abort_PDU, |
||||
/* Extensions may appear below */ |
||||
|
||||
} ADSAircraftPDU_PR; |
||||
|
||||
/* ADSAircraftPDU */ |
||||
typedef struct ADSAircraftPDU { |
||||
ADSAircraftPDU_PR present; |
||||
union ADSAircraftPDU_u { |
||||
Report_t aDS_report_PDU; |
||||
Report_t aDS_accepted_PDU; |
||||
Reject_t aDS_rejected_PDU; |
||||
NonCompliance_t aDS_ncn_PDU; |
||||
PositiveAcknowledgement_t aDS_positive_acknowledgement_PDU; |
||||
CancelPositiveAcknowledgement_t aDS_cancel_positive_acknowledgement_PDU; |
||||
CancelRejectReason_t aDS_cancel_negative_acknowledgement_PDU; |
||||
ProviderAbortReason_t aDS_provider_abort_PDU; |
||||
UserAbortReason_t aDS_user_abort_PDU; |
||||
/*
|
||||
* This type is extensible, |
||||
* possible extensions are below. |
||||
*/ |
||||
} choice; |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} ADSAircraftPDU_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ADSAircraftPDU; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ADSAircraftPDU_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "PMADSCAPDUVersion1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_pmadsc.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ADSAircraftPDUs.h" |
||||
|
||||
static asn_TYPE_member_t asn_MBR_ADSAircraftPDUs_1[] = { |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDUs, timestamp), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_PMADSCDateTimeGroup, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"timestamp" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSAircraftPDUs, adsAircraftPdu), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ADSAircraftPDU, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"adsAircraftPdu" |
||||
}, |
||||
}; |
||||
static const ber_tlv_tag_t asn_DEF_ADSAircraftPDUs_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_ADSAircraftPDUs_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* timestamp */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* adsAircraftPdu */ |
||||
}; |
||||
static asn_SEQUENCE_specifics_t asn_SPC_ADSAircraftPDUs_specs_1 = { |
||||
sizeof(struct ADSAircraftPDUs), |
||||
offsetof(struct ADSAircraftPDUs, _asn_ctx), |
||||
asn_MAP_ADSAircraftPDUs_tag2el_1, |
||||
2, /* Count of tags in the map */ |
||||
0, 0, 0, /* Optional elements (not needed) */ |
||||
-1, /* Start extensions */ |
||||
-1 /* Stop extensions */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ADSAircraftPDUs = { |
||||
"ADSAircraftPDUs", |
||||
"ADSAircraftPDUs", |
||||
SEQUENCE_free, |
||||
SEQUENCE_print, |
||||
SEQUENCE_constraint, |
||||
SEQUENCE_decode_ber, |
||||
SEQUENCE_encode_der, |
||||
SEQUENCE_decode_xer, |
||||
SEQUENCE_encode_xer, |
||||
SEQUENCE_decode_uper, |
||||
SEQUENCE_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ADSAircraftPDUs_tags_1, |
||||
sizeof(asn_DEF_ADSAircraftPDUs_tags_1) |
||||
/sizeof(asn_DEF_ADSAircraftPDUs_tags_1[0]), /* 1 */ |
||||
asn_DEF_ADSAircraftPDUs_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ADSAircraftPDUs_tags_1) |
||||
/sizeof(asn_DEF_ADSAircraftPDUs_tags_1[0]), /* 1 */ |
||||
0, /* No PER visible constraints */ |
||||
asn_MBR_ADSAircraftPDUs_1, |
||||
2, /* Elements count */ |
||||
&asn_SPC_ADSAircraftPDUs_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "PMADSCAPDUVersion1" |
||||
* found in "../../../dumpvdl2.asn1/atn-b1_pmadsc.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#ifndef _ADSAircraftPDUs_H_ |
||||
#define _ADSAircraftPDUs_H_ |
||||
|
||||
|
||||
#include "asn_application.h" |
||||
|
||||
/* Including external dependencies */ |
||||
#include "PMADSCDateTimeGroup.h" |
||||
#include "ADSAircraftPDU.h" |
||||
#include "constr_SEQUENCE.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* ADSAircraftPDUs */ |
||||
typedef struct ADSAircraftPDUs { |
||||
PMADSCDateTimeGroup_t timestamp; |
||||
ADSAircraftPDU_t adsAircraftPdu; |
||||
|
||||
/* Context for parsing across buffer boundaries */ |
||||
asn_struct_ctx_t _asn_ctx; |
||||
} ADSAircraftPDUs_t; |
||||
|
||||
/* Implementation */ |
||||
extern asn_TYPE_descriptor_t asn_DEF_ADSAircraftPDUs; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ADSAircraftPDUs_H_ */ |
||||
#include "asn_internal.h" |
||||
@ -0,0 +1,202 @@
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "ADSMessageSetVersion2" |
||||
* found in "../../../dumpvdl2.asn1/atn-b2_adsc_v2.asn1" |
||||
* `asn1c -fcompound-names -fincludes-quoted -gen-PER` |
||||
*/ |
||||
|
||||
#include "ADSDataReport.h" |
||||
|
||||
static asn_TYPE_member_t asn_MBR_ADSDataReport_1[] = { |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSDataReport, position), |
||||
(ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ThreeDPosition, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"position" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSDataReport, time), |
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ADSv2DateTimeGroup, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"time" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSDataReport, fom), |
||||
(ASN_TAG_CLASS_CONTEXT | (2 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_FigureOfMerit, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"fom" |
||||
}, |
||||
{ ATF_NOFLAGS, 0, offsetof(struct ADSDataReport, contract_number), |
||||
(ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ContractNumber, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"contract-number" |
||||
}, |
||||
{ ATF_POINTER, 11, offsetof(struct ADSDataReport, projected_profile), |
||||
(ASN_TAG_CLASS_CONTEXT | (4 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ProjectedProfile, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"projected-profile" |
||||
}, |
||||
{ ATF_POINTER, 10, offsetof(struct ADSDataReport, ground_vector), |
||||
(ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_GroundVector, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"ground-vector" |
||||
}, |
||||
{ ATF_POINTER, 9, offsetof(struct ADSDataReport, air_vector), |
||||
(ASN_TAG_CLASS_CONTEXT | (6 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_AirVector, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"air-vector" |
||||
}, |
||||
{ ATF_POINTER, 8, offsetof(struct ADSDataReport, met_info), |
||||
(ASN_TAG_CLASS_CONTEXT | (7 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_MetInfo, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"met-info" |
||||
}, |
||||
{ ATF_POINTER, 7, offsetof(struct ADSDataReport, extended_projected_profile), |
||||
(ASN_TAG_CLASS_CONTEXT | (8 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ExtendedProjectedProfile, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"extended-projected-profile" |
||||
}, |
||||
{ ATF_POINTER, 6, offsetof(struct ADSDataReport, speed_schedule_profile), |
||||
(ASN_TAG_CLASS_CONTEXT | (9 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_SpeedScheduleProfile, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"speed-schedule-profile" |
||||
}, |
||||
{ ATF_POINTER, 5, offsetof(struct ADSDataReport, emergency_urgency_status), |
||||
(ASN_TAG_CLASS_CONTEXT | (10 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_ADSEmergencyUrgencyStatus, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"emergency-urgency-status" |
||||
}, |
||||
{ ATF_POINTER, 4, offsetof(struct ADSDataReport, toa_range), |
||||
(ASN_TAG_CLASS_CONTEXT | (11 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_TOARange, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"toa-range" |
||||
}, |
||||
{ ATF_POINTER, 3, offsetof(struct ADSDataReport, rta_status_data), |
||||
(ASN_TAG_CLASS_CONTEXT | (12 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_RTAStatusData, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"rta-status-data" |
||||
}, |
||||
{ ATF_POINTER, 2, offsetof(struct ADSDataReport, rnp_profile), |
||||
(ASN_TAG_CLASS_CONTEXT | (13 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_RNPProfile, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"rnp-profile" |
||||
}, |
||||
{ ATF_POINTER, 1, offsetof(struct ADSDataReport, planned_final_approach_speed), |
||||
(ASN_TAG_CLASS_CONTEXT | (14 << 2)), |
||||
+1, /* EXPLICIT tag at current level */ |
||||
&asn_DEF_Ias, |
||||
0, /* Defer constraints checking to the member type */ |
||||
0, /* No PER visible constraints */ |
||||
0, |
||||
"planned-final-approach-speed" |
||||
}, |
||||
}; |
||||
static const int asn_MAP_ADSDataReport_oms_1[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; |
||||
static const ber_tlv_tag_t asn_DEF_ADSDataReport_tags_1[] = { |
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
||||
}; |
||||
static const asn_TYPE_tag2member_t asn_MAP_ADSDataReport_tag2el_1[] = { |
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* position */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* time */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* fom */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* contract-number */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* projected-profile */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* ground-vector */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* air-vector */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* met-info */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 }, /* extended-projected-profile */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 9, 0, 0 }, /* speed-schedule-profile */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 10, 0, 0 }, /* emergency-urgency-status */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 11, 0, 0 }, /* toa-range */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (12 << 2)), 12, 0, 0 }, /* rta-status-data */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (13 << 2)), 13, 0, 0 }, /* rnp-profile */ |
||||
{ (ASN_TAG_CLASS_CONTEXT | (14 << 2)), 14, 0, 0 } /* planned-final-approach-speed */ |
||||
}; |
||||
static asn_SEQUENCE_specifics_t asn_SPC_ADSDataReport_specs_1 = { |
||||
sizeof(struct ADSDataReport), |
||||
offsetof(struct ADSDataReport, _asn_ctx), |
||||
asn_MAP_ADSDataReport_tag2el_1, |
||||
15, /* Count of tags in the map */ |
||||
asn_MAP_ADSDataReport_oms_1, /* Optional members */ |
||||
9, 2, /* Root/Additions */ |
||||
12, /* Start extensions */ |
||||
16 /* Stop extensions */ |
||||
}; |
||||
asn_TYPE_descriptor_t asn_DEF_ADSDataReport = { |
||||
"ADSDataReport", |
||||
"ADSDataReport", |
||||
SEQUENCE_free, |
||||
SEQUENCE_print, |
||||
SEQUENCE_constraint, |
||||
SEQUENCE_decode_ber, |
||||
SEQUENCE_encode_der, |
||||
SEQUENCE_decode_xer, |
||||
SEQUENCE_encode_xer, |
||||
SEQUENCE_decode_uper, |
||||
SEQUENCE_encode_uper, |
||||
0, /* Use generic outmost tag fetcher */ |
||||
asn_DEF_ADSDataReport_tags_1, |
||||
sizeof(asn_DEF_ADSDataReport_tags_1) |
||||
/sizeof(asn_DEF_ADSDataReport_tags_1[0]), /* 1 */ |
||||
asn_DEF_ADSDataReport_tags_1, /* Same as above */ |
||||
sizeof(asn_DEF_ADSDataReport_tags_1) |
||||
/sizeof(asn_DEF_ADSDataReport_tags_1[0]), /* 1 */ |
||||
0, /* No PER visible constraints */ |
||||
asn_MBR_ADSDataReport_1, |
||||
15, /* Elements count */ |
||||
&asn_SPC_ADSDataReport_specs_1 /* Additional specs */ |
||||
}; |
||||
|
||||