1
0
mirror of https://github.com/JvanKatwijk/dab-cmdline synced 2025-10-05 15:42:46 +02:00

some refinements

This commit is contained in:
Jan
2025-06-24 20:49:38 +02:00
parent f6a1aed1c7
commit a7a84e7965
23 changed files with 78 additions and 86 deletions

View File

@@ -178,6 +178,7 @@ extern "C" {
//
typedef struct {
uint8_t dabMode;
int16_t thresholdValue;
syncsignal_t syncsignal_Handler;
systemdata_t systemdata_Handler;
name_of_ensemble_t name_of_ensemble;

View File

@@ -14,8 +14,7 @@
* jan van Katwijk
* Lazy Chair Computing
*/
#ifndef __AIRSPY_HANDLER__
#define __AIRSPY_HANDLER__
#pragma once
#include "ringbuffer.h"
#include "device-handler.h"
@@ -151,7 +150,6 @@ static
int callback(airspy_transfer_t *);
int data_available (void *buf, int buf_size);
const char * getSerial (void);
int open (void);
int open (void);
};
#endif

View File

@@ -4,8 +4,7 @@
// different readers, with one "mother" reader.
// Note that the cardreader is quite different here
// and its code is elsewhere
#ifndef __COMMON_READERS
#define __COMMON_READERS
#pragma once
#include "virtual-reader.h"
@@ -49,5 +48,4 @@ private:
int16_t convIndex;
};
#endif

View File

@@ -21,8 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __EXTIO_HANDLER_
#define __EXTIO_HANDLER_
#pragma once
#
#include <QWidget>
#include <QComboBox>
@@ -229,5 +228,4 @@ private:
signals:
// The following signals originate from the Winrad Extio interface
};
#endif

View File

@@ -3,8 +3,7 @@
// For the different formats for input, we have
// different readers, with one "mother" reader.
// Note that the cardreader is quite different here
#ifndef __READER
#define __READER
#pragma once
#include <stdint.h>
#include <stdio.h>
@@ -162,5 +161,4 @@ int16_t bitDepth (void) {
}
};
#endif

View File

@@ -3,8 +3,7 @@
// For the different formats for input, we have
// different readers, with one "mother" reader.
// Note that the cardreader is quite different here
#ifndef __VIRTUAL_READER
#define __VIRTUAL_READER
#pragma once
#include <stdint.h>
#include <stdio.h>
@@ -39,5 +38,4 @@ private:
};
#endif

View File

@@ -3,23 +3,20 @@
* Copyright (C) 2015
* Sebastian Held <sebastian.held@imst.de>
*
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
* This file is adapted for use with dab-cmdline
*
* SDR-J is free software; you can redistribute it and/or modify
* dab-cmdline 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J is distributed in the hope that it will be useful,
* dab-cmdline 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 SDR-J; if not, write to the Free Software
* along with dab-cmdline; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "uhd-input.h"
@@ -59,7 +56,7 @@ void uhd_streamer::stop (void) {
wait(1);
}
void uhd_streamer::run (void) {
void uhd_streamer::run () {
while (!m_stop_signal_called) {
// get write position, ignore data2 and size2
int32_t size1, size2;
@@ -153,7 +150,7 @@ void uhd_streamer::run (void) {
*success = true;
}
uhdInput::~uhdInput (void) {
uhdInput::~uhdInput () {
if (theBuffer != NULL) {
stopReader();
uhdSettings -> beginGroup ("uhdSettings");
@@ -181,7 +178,7 @@ int32_t freq = m_usrp -> get_rx_freq ();
return freq;
}
bool uhdInput::restartReader (void) {
bool uhdInput::restartReader () {
if (m_workerHandle != 0)
return true;
@@ -201,7 +198,7 @@ void uhdInput::stopReader (void) {
}
//
// not used:
uint8_t uhdInput::myIdentity (void) {
uint8_t uhdInput::myIdentity () {
return DAB_STICK;
}
@@ -212,11 +209,11 @@ int32_t uhdInput::getSamples (DSPCOMPLEX *v, int32_t size) {
return size;
}
int32_t uhdInput::Samples (void) {
int32_t uhdInput::Samples () {
return theBuffer -> GetRingBufferReadAvailable();
}
void uhdInput::resetBuffer (void) {
void uhdInput::resetBuffer () {
theBuffer -> FlushRingBuffer();
}
@@ -224,7 +221,7 @@ void uhdInput::set_fCorrection (int32_t f) {
(void)f;
}
int16_t uhdInput::maxGain (void) {
int16_t uhdInput::maxGain () {
uhd::gain_range_t range = m_usrp->get_rx_gain_range();
return range.stop();
}
@@ -240,7 +237,7 @@ void uhdInput::set_KhzOffset (int32_t o) {
vfoOffset = o;
}
int16_t uhdInput::bitDepth (void) {
int16_t uhdInput::bitDepth () {
return 16;
}

View File

@@ -22,8 +22,7 @@
* along with SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __UHDINPUT
#define __UHDINPUT
#pragma once
#include "virtual-input.h"
@@ -55,19 +54,19 @@ Q_OBJECT
friend class uhd_streamer;
public:
uhdInput (QSettings *dabSettings, bool *success);
virtual ~uhdInput (void);
virtual ~uhdInput ();
virtual void setVFOFrequency (int32_t freq);
virtual int32_t getVFOFrequency (void);
virtual int32_t getVFOFrequency ();
bool legalFrequency (int32_t) {return true;}
int32_t defaultFrequency (void) {return 100000000;}
virtual bool restartReader (void);
virtual void stopReader (void);
int32_t defaultFrequency () {return 100000000;}
virtual bool restartReader ();
virtual void stopReader ();
virtual int32_t getSamples (DSPCOMPLEX *, int32_t size);
virtual int32_t Samples (void);
uint8_t myIdentity (void);
virtual void resetBuffer (void);
virtual int16_t maxGain (void);
int16_t bitDepth (void);
virtual int32_t Samples ();
uint8_t myIdentity ();
virtual void resetBuffer ();
virtual int16_t maxGain ();
int16_t bitDepth ();
//
private:
QSettings *uhdSettings;
@@ -83,5 +82,4 @@ private slots:
void set_fCorrection (int);
void set_KhzOffset (int);
};
#endif

View File

@@ -21,8 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __XML_DESCRIPTOR__
#define __XML_DESCRIPTOR__
#pragma once
#include <string>
#include <vector>
@@ -71,4 +70,3 @@ public:
void add_modtoBlock (int blockno, std::string modType);
};
#endif

View File

@@ -20,8 +20,7 @@
* along with DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __XML_FILEREADER__
#define __XML_FILEREADER__
#pragma once
#include <string>
#include <atomic>
@@ -54,5 +53,4 @@ private:
xml_Reader *theReader;
};
#endif

View File

@@ -20,8 +20,7 @@
* along with eti-cmdline; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __XML_READER__
#define __XML_READER__
#pragma once
#include <thread>
#include <stdio.h>
@@ -75,4 +74,3 @@ private:
float mapTable_float [2048];
};
#endif

View File

@@ -4,20 +4,20 @@
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of eti-cmdline
* This file is part of dab-cmdline
*
* eti-cmdline is free software; you can redistribute it and/or modify
* dab-cmdline 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 2 of the License, or
* (at your option) any later version.
*
* eti-cmdline is distributed in the hope that it will be useful,
* dab-cmdline 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 eti-cmdline; if not, write to the Free Software
* along with dab-cmdline; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

View File

@@ -300,6 +300,7 @@ deviceHandler *theDevice;
// and with a sound device we now can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = 10;
interface. syncsignal_Handler = syncsignalHandler;
interface. systemdata_Handler = systemData;
interface. ensemblename_Handler = ensemblename_Handler;

View File

@@ -145,11 +145,11 @@ void serviceName (const std::string &s, int SId,
static
void programdata_Handler (audiodata *d, void *ctx) {
(void)ctx;
std::cerr << "\tstartaddress\t= " << d -> startAddr << "\n";
std::cerr << "\tlength\t\t= " << d -> length << "\n";
std::cerr << "\tsubChId\t\t= " << d -> subchId << "\n";
std::cerr << "\tprotection\t= " << d -> protLevel << "\n";
std::cerr << "\tbitrate\t\t= " << d -> bitRate << "\n";
// std::cerr << "\tstartaddress\t= " << d -> startAddr << "\n";
// std::cerr << "\tlength\t\t= " << d -> length << "\n";
// std::cerr << "\tsubChId\t\t= " << d -> subchId << "\n";
// std::cerr << "\tprotection\t= " << d -> protLevel << "\n";
// std::cerr << "\tbitrate\t\t= " << d -> bitRate << "\n";
}
//
@@ -263,59 +263,59 @@ uint8_t theBand = BAND_III;
int lnaGain = 40;
int vgaGain = 40;
int ppmOffset = 0;
const char *optionsString = "D:d:M:B:P:O:A:C:G:g:p:";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:g:p:";
#elif HAVE_LIME
int16_t gain = 70;
std::string antenna = "Auto";
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:g:X:";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:g:X:";
#elif HAVE_PLUTO
int16_t gain = 60;
bool autogain = true;
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:Q";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:Q";
#elif HAVE_SDRPLAY
int16_t GRdB = 30;
int16_t lnaState = 4;
bool autogain = true;
int16_t ppmOffset = 0;
bool X_dump = false;
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:L:Qp:X";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:L:Qp:X";
#elif HAVE_SDRPLAY_V3
int16_t GRdB = 30;
int16_t lnaState = 3;
bool autogain = false;
int16_t ppmOffset = 0;
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:L:Qp:X";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:L:Qp:X";
bool X_dump = false;
#elif HAVE_AIRSPY
int16_t gain = 20;
bool autogain = false;
bool rf_bias = false;
int16_t ppmOffset = 0;
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:p:b";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:p:b";
#elif HAVE_RTLSDR
int16_t gain = 50;
bool autogain = false;
int16_t ppmOffset = 0;
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:p:Q";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:p:Q";
#elif HAVE_WAVFILES
std::string fileName;
bool repeater = true;
const char *optionsString = "T:D:d:M:B:P:O:A:F:R:";
const char *optionsString = "t:T:D:d:M:B:P:O:A:F:R:";
#elif HAVE_RAWFILES
std::string fileName;
bool repeater = true;
const char *optionsString = "T:D:d:M:B:P:O:A:F:R:";
const char *optionsString = "t:T:D:d:M:B:P:O:A:F:R:";
#elif HAVE_XMLFILES
std::string fileName;
bool repeater = true;
const char *optionsString = "T:D:d:M:B:P:O:A:F:R:";
const char *optionsString = "t:T:D:d:M:B:P:O:A:F:R:";
#elif HAVE_RTL_TCP
int gain = 50;
bool autogain = false;
int ppmOffset = 0;
std::string hostname = "127.0.0.1"; // default
int32_t basePort = 1234; // default
const char *optionsString = "T:D:d:M:B:P:O:A:C:G:Qp:H:I";
const char *optionsString = "t:T:D:d:M:B:P:O:A:C:G:Qp:H:I";
#endif
std::string soundChannel = "default";
int16_t latency = 10;
@@ -325,7 +325,7 @@ int opt;
struct sigaction sigact;
bandHandler dabBand;
deviceHandler *theDevice = nullptr;
int16_t thresholdValue = 6; // default;
bool err;
int theDuration = -1; // no limit
//tiiHandler the_tiiHandler;
@@ -345,6 +345,9 @@ int theDuration = -1; // no limit
fprintf (stderr, "options are %s\n", optionsString);
while ((opt = getopt (argc, argv, optionsString)) != -1) {
switch (opt) {
case 't':
thresholdValue = atoi (optarg);
break;
case 'T':
theDuration = 60 * atoi (optarg); // minutes
break;
@@ -649,6 +652,7 @@ int theDuration = -1; // no limit
// and with a sound device we now can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = thresholdValue;
interface. syncsignal_Handler = syncsignalHandler;
interface. systemdata_Handler = systemData;
interface. name_of_ensemble = name_of_ensemble;

View File

@@ -45,7 +45,7 @@ void tiiHandler::run () {
if (known (xx))
continue;
if ((xx. ecc == 0) || (xx. EId == 0)) {
fprintf (stderr, "No further data: %d %d \n",
fprintf (stderr, "No further data available to decode: %d %d \n",
xx. mainId,
xx. subId);
tiiTable. push_back (xx);
@@ -60,13 +60,14 @@ void tiiHandler::run () {
cacheElement *handle = lookup (xx); // in tii database
if (handle == nullptr)
fprintf (stderr, "not found %X %d %d\n",
fprintf (stderr, "not found in database %X %d %d\n",
xx. EId, xx. mainId, xx. subId);
else
fprintf (stderr, " %X %d %d -> %s %s %s %s %f %f (%d %d %d\n",
fprintf (stderr, " %X %d %d\t-> %f %s %s %s %s %f %f (%d %d %d)\n",
handle -> Eid,
handle -> mainId,
handle -> subId,
xx. strength,
handle -> country. c_str (),
handle -> channel. c_str (),
handle -> ensemble. c_str (),

View File

@@ -567,6 +567,7 @@ deviceHandler *theDevice;
// and with a sound device we now can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = 6;
interface. syncsignal_Handler = syncsignal_Handler;
interface. systemdata_Handler = systemData;
interface. name_of_ensemble = name_of_ensemble;

View File

@@ -490,6 +490,7 @@ int theDuration = -1; // infinite
// and with a sound device we now can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = 6;
interface. syncsignal_Handler = syncsignal_Handler;
interface. systemdata_Handler = systemData;
interface. name_of_ensemble = name_of_ensemble;

View File

@@ -463,6 +463,7 @@ bool err;
// and with a sound device we can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = 6;
interface. syncsignal_Handler = syncsignal_Handler;
interface. systemdata_Handler = systemData;
interface. name_of_ensemble = name_of_ensemble;

View File

@@ -297,6 +297,7 @@ bool err;
// and with a sound device we now can create a "backend"
API_struct interface;
interface. dabMode = theMode;
interface. thresholdValue = 6;
interface. syncsignal_Handler = syncsignalHandler;
interface. systemdata_Handler = systemData;
interface. name_of_ensemble = name_of_ensemble;

View File

@@ -349,7 +349,7 @@ stream_parms streamParameters;
#endif
}
else {
fprintf (stderr, "CRC failure with dab+ frame should not happen\n");
// fprintf (stderr, "CRC failure with dab+ frame should not happen\n");
}
}
return true;

View File

@@ -383,7 +383,8 @@ void padHandler::build_MSC_segment (std::vector<uint8_t> data) {
int32_t size = (int)(data. size ()) <
dataGroupLength ? data. size () :
dataGroupLength;
if (size <= 2)
return;
uint8_t groupType = data [0] & 0xF;
uint8_t continuityIndex = (data [1] & 0xF) >> 4;
uint8_t repetitionIndex = data [1] & 0xF;

View File

@@ -66,7 +66,7 @@
this -> carriers = params. get_carriers ();
this -> carrierDiff = params. get_carrierDiff ();
this -> tii_counter = 0;
this -> threshold = 6;
this -> threshold = p -> thresholdValue;
isSynced = false;
snr = 0;
running. store (false);

View File

@@ -19,6 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This implementation of the TII decoder is a modified version
* of the TII decoder used in Qt-DAB, which is itself derived
* from the TII decoder is DABstar and was developed by Rolf Zerr
*/
#include "tii-detector.h"
@@ -109,7 +113,7 @@ uint8_t patternTable [] = {
0360 // 1 1 1 1 0 0 0 0 69
};
TII_Detector::TII_Detector (uint8_t dabMode):
TII_Detector::TII_Detector (uint8_t dabMode):
params (dabMode),
theTable (dabMode),
T_u (params. get_T_u ()),
@@ -154,7 +158,7 @@ void TII_Detector::addBuffer (const std::vector<Complex> &v) {
Complex tmpBuffer [T_u];
for (int i = 0; i < T_u; i ++)
tmpBuffer [i] = v [T_g + i];
tmpBuffer [i] = v [T_g + i] * window [i];
my_fftHandler. fft (tmpBuffer);
for (int i = 0; i < T_u; i ++)
nullSymbolBuffer [i] += tmpBuffer [i];
@@ -214,10 +218,7 @@ int fcmp (const void *a, const void *b) {
if (element1 -> strength > element2 -> strength)
return -1;
else
if (element1 -> strength < element2 -> strength)
return 1;
else
return 0;
return (element1 -> strength < element2 -> strength) ? 1 : 0;
}
std::vector<tiiData> TII_Detector::processNULL (int16_t threshold_db) {