diff --git a/ExtIO_NetSDR/ExtIO_NetSDR.vcxproj b/ExtIO_NetSDR/ExtIO_NetSDR.vcxproj
index e9b527f..97b8a5f 100644
--- a/ExtIO_NetSDR/ExtIO_NetSDR.vcxproj
+++ b/ExtIO_NetSDR/ExtIO_NetSDR.vcxproj
@@ -14,7 +14,7 @@
{F6D8A813-8B8D-46B5-B015-B5BE1BC467BE}
Win32Proj
ExtIO_NetSDR
- ExtIO_RFspaceNetSDR
+ ExtIO_RFspaceSDR
@@ -66,7 +66,7 @@
Windows
true
Ws2_32.lib;%(AdditionalDependencies)
- 2018.3
+ 2018.4
..\src\ExtIO_RFspaceNetSDR.def
@@ -90,11 +90,12 @@
false
true
true
- 2018.3
+ 2018.4
..\src\ExtIO_RFspaceNetSDR.def
/PDBSTRIPPED
false
Ws2_32.lib;%(AdditionalDependencies)
+ $(OutDir)$(TargetName)$(TargetExt)
diff --git a/README.md b/README.md
index 5d2deaa..6532be4 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,17 @@
-# ExtIO_RFspaceNetSDR
-Winrad/HDSDR plugin ExtIO for the RFspace NetSDR receiver
+# ExtIO_RFspaceSDR
+Winrad/HDSDR plugin ExtIO for the RFspace NetSDR, NetSDR+ and CloudIQ receiver
URL: https://github.com/hayguen/ExtIO_RFspaceNetSDR
## Software Defined Radio (SDR) receiver
-The hardware receiver was manufactured by RFspace.
+The hardware receiver(s) were/are manufactured by RFspace.
See http://www.rfspace.com/
This software was initially developed for for the NetSDR model.
-It does also run with the NetSDR+.
+It does also run with the compatible NetSDR+ model.
+And also with the different CloudIQ model.
Network protocol specification for the interface is available at
http://www.moetronix.com/svdownload.htm
@@ -32,13 +33,15 @@ Authors are Sebastian Balthasar and Hayati Ayguen. On questions, contact Hayati
## Step-by-step installation
* install your favorite SDR software, e.g. HDSDR from http://www.hdsdr.de/ .
-Other ExtIO compatible software like Winrad or Studio1 should also work.
+Other ExtIO compatible software like Winrad or Studio1 might also work.
* download ExtIO_RFspaceNetSDR.DLL https://github.com/hayguen/ExtIO_RFspaceNetSDR/releases
* copy downloaded file into your SDR software's installation directory (default=C:\Program Files (x86)\HDSDR).
Do NOT try to unzip directly into this directory! Because of Windows' user rights management this will fail. Unzip somewhere else first, then copy it to the installation directory.
+* start the SDR software and close it again, after getting an error message, caused by wrong configuration.
+
* Edit one of config_Default-profile.reg (or config_NetSDR-profile.reg) with a Text-Editor,
e.g. Notepad++. Enter your IP address(es) and check if you need to modify the portnumber.
Use config_Default-profile.reg if you start HDSDR with it's installed shortcut.
@@ -49,7 +52,7 @@ you might edit config_NetSDR-profile.reg
* Then doubleclick to import those settings, when HDSDR is closed
-* exit and restart SDR software and select ExtIO_RFspaceNetSDR.DLL if demanded
+* exit and restart SDR software and select ExtIO_RFspaceSDR.DLL if demanded
## Compilation notes
@@ -71,5 +74,5 @@ Compiles. In test.
ExtIO control GUI for configuration is missing! To be implemented ..
Workaround by editing Windows' registry directly with 'regedit.exe' for use with HDSDR.
- Registry path: HKEY_CURRENT_USER\Software\HDSDR\ExtIO_RFspaceNetSDR.dll
+ Registry path: HKEY_CURRENT_USER\Software\HDSDR\ExtIO_RFspaceSDR.dll
diff --git a/config_CloudIQ-profile.reg b/config_CloudIQ-profile.reg
new file mode 100644
index 0000000..f8cc164
Binary files /dev/null and b/config_CloudIQ-profile.reg differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f96b797..77ecb12 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -74,6 +74,7 @@ LIST(APPEND NETSDREMU_SOURCES ${NETSDREMU_HEADERS})
add_definitions(-DEXTIO_EXPORTS)
+
# OS and compiler checks.
if(UNIX)
# linux / normal unix
@@ -123,3 +124,10 @@ TARGET_LINK_LIBRARIES( ExtIO_RFspaceNetSDR ${PROJECT_LIBS} )
ADD_EXECUTABLE( netsdremu ${NETSDREMU_SOURCES} ${CLSOCKET_SOURCES} )
TARGET_LINK_LIBRARIES( netsdremu ${PROJECT_LIBS} )
+set(CXX_STANDARD_REQUIRED ON)
+set_property(TARGET netsdremu PROPERTY CXX_STANDARD 11)
+set_property(TARGET ExtIO_RFspaceNetSDR PROPERTY CXX_STANDARD 11)
+
+set_property(TARGET netsdremu PROPERTY CXX_EXTENSIONS ON)
+set_property(TARGET ExtIO_RFspaceNetSDR PROPERTY CXX_EXTENSIONS ON)
+
diff --git a/src/ExtIO_RFspaceNetSDR.cpp b/src/ExtIO_RFspaceNetSDR.cpp
index 060cdd3..1200a6d 100644
--- a/src/ExtIO_RFspaceNetSDR.cpp
+++ b/src/ExtIO_RFspaceNetSDR.cpp
@@ -1,7 +1,12 @@
+#define SETTINGS_IDENTIFIER "RFspace-0.7"
+
#define HWNAME "RFspace"
-#define HWMODEL "RFspace NetSDR"
-#define SETTINGS_IDENTIFIER "RFspace NetSDR-0.5"
+#if 0
+#define HWMODEL "NetSDR"
+#else
+#define HWMODEL "CloudIQ"
+#endif
#include "ExtIO_RFspaceNetSDR.h"
#include "rfspace_netsdr_receiver.h"
@@ -92,10 +97,11 @@ static void ReceiverThreadProc( void* lpParameter )
// @todo: move everything to gpoReceiver->ThreadProc() - including gbExitControlThread ...
const uint16_t uiWaitMs = 5;
+ const int iWaitMs = uiWaitMs;
while ( !gbExitControlThread )
{
- tthread::this_thread::sleep_for( tthread::chrono::milliseconds( uiWaitMs ) );
- gpoReceiver->TimerProc(uiWaitMs);
+ gpoReceiver->TimerProc(iWaitMs);
+ tthread::this_thread::sleep_for(tthread::chrono::milliseconds(uiWaitMs));
}
gbExitControlThread = false;
gbControlThreadRunning = false;
@@ -166,18 +172,21 @@ bool EXTIO_CALL InitHW( char* name, char* model, int& type )
{
type = RFspaceNetReceiver::getDefaultHWType();
strcpy( name, HWNAME );
- strcpy( model, HWMODEL );
+ strcpy( model, "" );
if ( !gbInitHW )
{
// read default values from Settings: giRcvFreq, giAgcIdx, ..
// do not overwrite them
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
if ( gpoSettings->iAttenuationIdx < 0 || gpoSettings->iAttenuationIdx >= RFspaceNetReceiver::miNumAttenuations )
gpoSettings->iAttenuationIdx = 0;
+ RFspaceNetReceiver::applyHwModel(*gpoSettings);
+ strcpy(model, gpoSettings->acModel );
+
gbInitHW = true;
}
@@ -187,7 +196,7 @@ bool EXTIO_CALL InitHW( char* name, char* model, int& type )
//---------------------------------------------------------------------------
bool EXTIO_CALL OpenHW(void)
{
- LOG_PRO(LOG_DEBUG, "OpenHW() called .. returning gbInitHw = %s", (gbInitHW ? "true" : "false"));
+ LOG_PRO(LOG_DEBUG, "*** OpenHW() called .. returning gbInitHw = %s", (gbInitHW ? "true" : "false"));
return gbInitHW; // open on demand!
}
@@ -200,7 +209,7 @@ static bool InternalOpenHW(void)
if ( !gpoReceiver )
{
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
gpoReceiver = new RFspaceNetReceiver();
bOpenOK = false;
@@ -208,10 +217,14 @@ static bool InternalOpenHW(void)
{
gpoReceiver->setExtIoCallback(gpfnExtIOCallbackPtr);
stopThread();
- LOG_PRO(LOG_DEBUG, "InternalOpenHW(): trying to open/connect device ..");
+ LOG_PRO(LOG_DEBUG, "*** InternalOpenHW(): trying to open/connect device ..");
bOpenOK = gpoReceiver->openHW(gpoSettings);
if (bOpenOK)
+ {
startThread();
+ tthread::this_thread::sleep_for(tthread::chrono::milliseconds(300));
+ LOG_PRO(LOG_DEBUG, "*** InternalOpenHW(): continue after sleep of 300 ms");
+ }
else
{
delete gpoReceiver;
@@ -223,7 +236,7 @@ static bool InternalOpenHW(void)
::MessageBoxA(0, acMsg, "Error", MB_OK);
#endif
}
- LOG_PRO(LOG_DEBUG, "InternalOpenHW() returns gbInitHW && bOpenOK = %s && %s", (gbInitHW ? "true" : "false"), (bOpenOK ? "true" : "false"));
+ LOG_PRO(LOG_DEBUG, "*** InternalOpenHW() returns gbInitHW && bOpenOK = %s && %s", (gbInitHW ? "true" : "false"), (bOpenOK ? "true" : "false"));
}
}
}
@@ -241,7 +254,7 @@ int EXTIO_CALL StartHW( long LOfreq )
//---------------------------------------------------------------------------
int64_t EXTIO_CALL StartHW64( int64_t LOfreq )
{
- LOG_PRO( LOG_DEBUG, "StartHW64() called" );
+ LOG_PRO( LOG_DEBUG, "*** StartHW64() called" );
const bool bConnected = InternalOpenHW();
if (!bConnected && gpfnExtIOCallbackPtr)
@@ -252,15 +265,7 @@ int64_t EXTIO_CALL StartHW64( int64_t LOfreq )
bool bStartOK = gpoReceiver->startHW(LOfreq);
- LOG_PRO( LOG_DEBUG, "StartHW64(): %s", (bStartOK ? "successful":"failed") );
-
- if (0)
- {
- int sampleFmt = gpoReceiver->getExtHwSampleFormat();
- int bitDepth = gpoReceiver->getExtHwBitDepth();
- LOG_PRO(LOG_PROTOCOL, "SEND STATUS CHANGE AT START TO SDR: NEW BIT DEPTH %d Bit.", bitDepth);
- EXTIO_STATUS_CHANGE(gpfnExtIOCallbackPtr, sampleFmt);
- }
+ LOG_PRO( LOG_DEBUG, "*** StartHW64(): %s", (bStartOK ? "successful":"failed") );
// number of complex elements returned each
// invocation of the callback routine
@@ -270,16 +275,25 @@ int64_t EXTIO_CALL StartHW64( int64_t LOfreq )
//---------------------------------------------------------------------------
void EXTIO_CALL StopHW( void )
{
- LOG_PRO( LOG_DEBUG, "StopHW() called" );
+ LOG_PRO( LOG_DEBUG, "*** StopHW() called" );
if ( !gbInitHW || !gpoReceiver )
return;
+ LOG_PRO(LOG_DEBUG, "*** * StopHW() -> calling stopDataStream()");
+ bool bOk = false;
+ const bool bWasRunning = gpoReceiver->rcv.isUDPDataStreamRunning(&bOk) && bOk;
gpoReceiver->rcv.stopDataStream();
+ if (bWasRunning)
+ tthread::this_thread::sleep_for(tthread::chrono::milliseconds(300));
+ const bool bIsRunning = gpoReceiver->rcv.isUDPDataStreamRunning(&bOk) && bOk;
+ LOG_PRO(LOG_DEBUG, "*** * StopHW() -> DataStream is %s%s"
+ , (bIsRunning ? "still running" : "stopped now")
+ , (bWasRunning ? ", after sleep of 300 ms" : ""));
}
void EXTIO_CALL CloseHW( void )
{
- LOG_PRO( LOG_DEBUG, "CloseHW() called" );
+ LOG_PRO( LOG_DEBUG, "*** CloseHW() called" );
// ..... here you can shutdown your graphical interface, if any............
if ( gbInitHW )
{
@@ -300,11 +314,10 @@ int EXTIO_CALL SetHWLO( long LOfreq )
int64_t EXTIO_CALL SetHWLO64( int64_t LOfreq )
{
- LOG_PRO( LOG_DEBUG, "************************************** SetHWLO(%ld) *********************************", long(LOfreq));
- LOG_PRO( LOG_DEBUG, "SetHWLO64(%ld Hz) called", long(LOfreq) );
+ LOG_PRO( LOG_DEBUG, "*** SetHWLO64(%ld) called", long(LOfreq));
if ( !gpoReceiver )
{
- LOG_PRO( LOG_DEBUG, "SetHWLO64(): ERROR: No Receiver");
+ LOG_PRO( LOG_DEBUG, "*** * SetHWLO64(): ERROR: No Receiver");
return 1; // Error
}
gpoReceiver->setHWLO(LOfreq);
@@ -321,10 +334,10 @@ int EXTIO_CALL GetStatus( void )
void EXTIO_CALL SetCallback( pfnExtIOCallback funcptr )
{
gpfnExtIOCallbackPtr = funcptr;
- if ( !gpoReceiver )
+ LOG_PRO(LOG_DEBUG, "*** SetCallback(%p) called", funcptr);
+ if (!gpoReceiver)
return;
gpoReceiver->setExtIoCallback(funcptr);
- LOG_PRO( LOG_DEBUG, "SetCallback(%p) called .. after having set callback function", funcptr);
}
//---------------------------------------------------------------------------
@@ -334,9 +347,7 @@ int64_t EXTIO_CALL GetHWLO64( void )
return 0;
uint64_t f = gpoReceiver->getHWLO();
-
return f;
-
}
long EXTIO_CALL GetHWLO( void )
@@ -348,19 +359,19 @@ long EXTIO_CALL GetHWLO( void )
}
//---------------------------------------------------------------------------
-long EXTIO_CALL GetHWSR( void )
+long EXTIO_CALL GetHWSR(void)
{
- LOG_PRO( LOG_DEBUG, "GetHWSR() called");
+ LOG_PRO( LOG_DEBUG, "*** GetHWSR() called");
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
long srate = long(gpoSettings->uiSamplerate);
- LOG_PRO(LOG_DEBUG, "GetHWSR(): %ld Hz", srate);
+ LOG_PRO(LOG_DEBUG, "*** * GetHWSR() --> %ld Hz", srate);
return long(srate);
}
int EXTIO_CALL ExtIoGetFreqRanges(int idx, int64_t * freq_low, int64_t * freq_high )
{
- LOG_PRO( LOG_DEBUG, "************************************** GET FREQRANGES( )*********************************");
+ LOG_PRO(LOG_DEBUG, "*** ExtIoGetFreqRanges(%d) called", idx);
if ( !gpoReceiver )
return 0;
@@ -368,8 +379,9 @@ int EXTIO_CALL ExtIoGetFreqRanges(int idx, int64_t * freq_low, int64_t * freq_hi
if(range)
{
- * freq_low = range[0];
- * freq_high = range[1];
+ *freq_low = range[0];
+ *freq_high = range[1];
+ LOG_PRO(LOG_DEBUG, "*** ExtIoGetFreqRanges(%d) --> %ld - %ld Hz", idx, long(*freq_low), long(*freq_high));
return 0;
}
else
@@ -386,7 +398,7 @@ int EXTIO_CALL ExtIoGetFreqRanges(int idx, int64_t * freq_low, int64_t * freq_hi
int EXTIO_CALL GetAttenuators( int atten_idx, float* gain )
{
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
// fill in attenuation (gain)
// use positive attenuation levels if signal is amplified (LNA)
@@ -399,10 +411,10 @@ int EXTIO_CALL GetAttenuators( int atten_idx, float* gain )
if ( atten_idx >= 0 && atten_idx < RFspaceNetReceiver::miNumAttenuations )
{
*gain = (RFspaceNetReceiver::mafAttenuationATTs[atten_idx] + RFspaceNetReceiver::mafAttenuationADGainsdB[atten_idx]) ;
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> %.2f *********************************", atten_idx, *gain );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> %.2f dB", atten_idx, *gain );
return 0;
}
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> ERR *********************************", atten_idx );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> ERR", atten_idx );
}
else
{
@@ -411,20 +423,20 @@ int EXTIO_CALL GetAttenuators( int atten_idx, float* gain )
if ( atten_idx >= 0 && atten_idx < RFspaceNetReceiver::miNumCompatibilityGains )
{
*gain = (RFspaceNetReceiver::mafVUHFCompatibilityGainValues[atten_idx] ) ;
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> %.2f *********************************", atten_idx, *gain );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> %.2f dB", atten_idx, *gain );
return 0;
}
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> ERR *********************************", atten_idx );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> ERR", atten_idx );
}
else
{
if ( atten_idx >= 0 && atten_idx < RFspaceNetReceiver::miNumMultiGains )
{
*gain = (RFspaceNetReceiver::mafVUHFMultiGainValues[atten_idx] ) ;
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> %.2f *********************************", atten_idx, *gain );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> %.2f dB", atten_idx, *gain );
return 0;
}
- LOG_PRO( LOG_DEBUG, "************************************** GetAttenuators(%d) --> ERR *********************************", atten_idx );
+ LOG_PRO(LOG_DEBUG, "*** GetAttenuators(idx %d) called --> ERR", atten_idx );
}
}
return 1;
@@ -432,18 +444,17 @@ int EXTIO_CALL GetAttenuators( int atten_idx, float* gain )
int EXTIO_CALL GetActualAttIdx( void )
{
-
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
int ret = RFspaceNetReceiver::getActualAttIdx(gpoSettings);
- LOG_PRO( LOG_DEBUG, "************************************** GetActualAttIdx() --> %d *********************************", ret );
+ LOG_PRO(LOG_DEBUG, "*** GetActualAttIdx() called --> %d", ret );
return ret;
}
int EXTIO_CALL SetAttenuator( int atten_idx )
{
- LOG_PRO( LOG_DEBUG, "************************************** SetAttenuator(%d)*********************************", atten_idx);
+ LOG_PRO(LOG_DEBUG, "*** SetAttenuator(idx %d) called", atten_idx);
if(!gpoSettings->bIsVUHFRange)
{
if ( atten_idx < 0 || atten_idx >= RFspaceNetReceiver::miNumAttenuations )
@@ -472,8 +483,8 @@ int EXTIO_CALL SetAttenuator( int atten_idx )
else
{
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
- LOG_PRO( LOG_DEBUG, "SetAttenuator (%d) : Fallback ", atten_idx);
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
+ LOG_PRO(LOG_DEBUG, "*** * SetAttenuator(idx %d) : Fallback without receiver", atten_idx);
if(!gpoSettings->bIsVUHFRange)
gpoSettings->iAttenuationIdx = atten_idx;
else
@@ -493,12 +504,12 @@ int EXTIO_CALL SetAttenuator( int atten_idx )
int EXTIO_CALL ExtIoGetSrates( int srate_idx, double* samplerate )
{
-
-if( srate_idx >= 0 && srate_idx < RFspaceNetReceiver::miNumSamplerates)
- {
- *samplerate = RFspaceNetReceiver::srate_bws[srate_idx].srate;
- return 0;
- }
+ if( srate_idx >= 0 && srate_idx < RFspaceNetReceiver::miNumSamplerates)
+ {
+ *samplerate = RFspaceNetReceiver::srate_bws[srate_idx].srate;
+ LOG_PRO(LOG_DEBUG, "*** ExtIoGetSrates(%d) called --> %.1f kHz", srate_idx, *samplerate);
+ return 0;
+ }
else
{
return 1; // ERROR
@@ -508,7 +519,7 @@ if( srate_idx >= 0 && srate_idx < RFspaceNetReceiver::miNumSamplerates)
int EXTIO_CALL ExtIoGetActualSrateIdx( void )
{
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
int ret = gpoSettings->iSampleRateIdx;
return ret;
@@ -516,21 +527,24 @@ int EXTIO_CALL ExtIoGetActualSrateIdx( void )
int EXTIO_CALL ExtIoSetSrate( int srate_idx )
{
- LOG_PRO( LOG_DEBUG, "************************************** ExtIoSetSrate(%d)*********************************", srate_idx);
int clippedIdx = PROCLIP(srate_idx, 0, RFspaceNetReceiver::miNumSamplerates - 1);
if ( gpoReceiver )
{
+ LOG_PRO(LOG_DEBUG, "*** ExtIoSetSrate(idx %d) called. setting for idx %d, %u Hz", srate_idx, clippedIdx, RFspaceNetReceiver::srate_bws[clippedIdx].srate);
gpoReceiver->setSamplerate(clippedIdx);
return (srate_idx == clippedIdx ? 0 : 1);
}
else
{
- if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
- LOG_PRO( LOG_DEBUG, "************************************** ExtIoSetSrate(): receiver does not exist. set settings *********************************");
-
- gpoSettings->iSampleRateIdx = clippedIdx;
- return (srate_idx == clippedIdx ? 0 : 1);
+ LOG_PRO(LOG_DEBUG, "*** ExtIoSetSrate(idx %d) called --> receiver does not exist. Ignoring call.", srate_idx);
+ return 0;
+ //if (!gpoSettings)
+ // gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
+ //gpoSettings->iSampleRateIdx = clippedIdx;
+ //gpoSettings->uiSamplerate = RFspaceNetReceiver::srate_bws[clippedIdx].srate;
+ //gpoSettings->uiBandwidth = RFspaceNetReceiver::srate_bws[clippedIdx].bw;
+ //LOG_PRO(LOG_DEBUG, "*** ExtIoSetSrate(idx %d) called --> receiver does not exist. set idx %d for %u Hz in settings", srate_idx, clippedIdx, gpoSettings->uiSamplerate);
+ //return (srate_idx == clippedIdx ? 0 : 1);
}
}
@@ -551,16 +565,17 @@ long EXTIO_CALL ExtIoGetBandwidth( int srate_idx )
enum class Setting {
ID = 0 // enum values MUST be incremental without gaps!
+ , MODEL
, CTRL_IP, CTRL_PORT // NetSDR IP/Port
, DATA_IP, DATA_PORT // myPC Data IP/Port
, CONNECT_TIMEOUT_MILLIS
, AVAIL_SRATES
, AVAIL_BWS
, SAMPLERATE_IDX
+ , USE_16BIT_FOR_ALL
, RCV_FRQ
, RCV_BW
, RCV_ATTEN_IDX
- , BITDEPTH_CHANGE_SMPRATE
, BAND1_RANGE_MINFREQ
, BAND1_RANGE_MAXFREQ
, IS_VUHF_RANGE
@@ -580,7 +595,7 @@ int EXTIO_CALL ExtIoGetSetting( int idx, char* description, char* value )
int k;
size_t off;
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
switch( Setting(idx) )
{
@@ -589,6 +604,11 @@ int EXTIO_CALL ExtIoGetSetting( int idx, char* description, char* value )
snprintf( value, 1024, "%s", SETTINGS_IDENTIFIER );
return 0;
+ case Setting::MODEL:
+ snprintf(description, 1024, "%s", "Model: 'NetSDR' / 'CloudIQ'");
+ snprintf(value, 1024, "%s", gpoSettings->acModel);
+ return 0;
+
case Setting::CTRL_IP:
snprintf( description, 1024, "%s", "CONTROL IP: IP-Address of 'RFspace NetSDR' for receiver control" );
snprintf( value, 1024, "%s", gpoSettings->acCtrlIP );
@@ -603,7 +623,7 @@ int EXTIO_CALL ExtIoGetSetting( int idx, char* description, char* value )
snprintf( value, 1024, "%s", gpoSettings->acDataIP );
return 0;
case Setting::DATA_PORT:
- snprintf( description, 1024, "%s", "DATA PortNo: port number of Client PC to receive streaming data (default: as CONTROL PortNo)" );
+ snprintf( description, 1024, "%s", "DATA PortNo: port number of Client PC to receive streaming data (default: as CONTROL PortNo). Entry ignored when DATA_IP empty" );
snprintf( value, 1024, "%d", gpoSettings->uDataPortNo );
return 0;
@@ -643,6 +663,11 @@ int EXTIO_CALL ExtIoGetSetting( int idx, char* description, char* value )
snprintf( value, 1024, "%d", gpoSettings->iSampleRateIdx );
return 0;
+ case Setting::USE_16BIT_FOR_ALL:
+ snprintf(description, 1024, "%s", "Use 16 Bit for All Samplerates?");
+ snprintf(value, 1024, "%d", (gpoSettings->bUse16BitForAll ? 1 : 0) );
+ return 0;
+
case Setting::RCV_FRQ:
snprintf( description, 1024, "%s", "frequency for Receiver" );
snprintf( value, 1024, "%ld", gpoSettings->iFrequency );
@@ -658,11 +683,6 @@ int EXTIO_CALL ExtIoGetSetting( int idx, char* description, char* value )
snprintf( value, 1024, "%u", gpoSettings->iAttenuationIdx);
return 0;
- case Setting::BITDEPTH_CHANGE_SMPRATE:
- snprintf( description, 1024, "%s", "Samplerate at which bitdepth is reduced from 24 to 16 bit. For samplerates <= value, you get 24 Bit, else 16 bit. From Specification: 1 333 333 Hz." );
- snprintf( value, 1024, "%u", gpoSettings->iBitDepthThresSamplerate);
- return 0;
-
case Setting::BAND1_RANGE_MINFREQ:
snprintf( description, 1024, "%s", "Receiver Frequency Range Min Frequency" );
snprintf( value, 1024, "%lu", gpoSettings->iBand_minFreq);
@@ -762,7 +782,7 @@ static const char * trimmedIP(const char * value, const char * logText)
void EXTIO_CALL ExtIoSetSetting( int idx, const char* value )
{
if (!gpoSettings)
- gpoSettings = new RFspaceNetReceiver::Settings();
+ gpoSettings = new RFspaceNetReceiver::Settings(HWMODEL);
int64_t tempI64;
int tempInt;
@@ -782,6 +802,9 @@ void EXTIO_CALL ExtIoSetSetting( int idx, const char* value )
SDR_settings_valid = ( value && !strcmp( value, SETTINGS_IDENTIFIER ) );
// make identifier version specific??? - or not ==> never change order of idx!
break;
+ case Setting::MODEL:
+ snprintf(gpoSettings->acModel, 32, "%s", value);
+ break;
case Setting::CTRL_IP:
snprintf(gpoSettings->acCtrlIP, 64, "%s", trimmedIP(value, "CTRL_IP"));
break;
@@ -805,6 +828,9 @@ void EXTIO_CALL ExtIoSetSetting( int idx, const char* value )
case Setting::SAMPLERATE_IDX:
gpoSettings->iSampleRateIdx = atoi( value );
break;
+ case Setting::USE_16BIT_FOR_ALL:
+ gpoSettings->bUse16BitForAll = atoi(value) ? true : false;
+ break;
case Setting::RCV_FRQ:
sscanf( value, "%ld", &gpoSettings->iFrequency );
break;
@@ -814,31 +840,28 @@ void EXTIO_CALL ExtIoSetSetting( int idx, const char* value )
case Setting::RCV_ATTEN_IDX:
gpoSettings->iAttenuationIdx = atoi( value );
break;
- case Setting::BITDEPTH_CHANGE_SMPRATE:
- gpoSettings->iBitDepthThresSamplerate = atoi( value );
- break;
case Setting::BAND1_RANGE_MINFREQ:
- gpoSettings->iBand_minFreq = atol( value );
- break;
+ gpoSettings->iBand_minFreq = atol( value );
+ break;
case Setting::BAND1_RANGE_MAXFREQ:
tempI64 = atol(value);
if (gpoSettings->iBand_minFreq < tempI64) // reject when min > max
gpoSettings->iBand_maxFreq = tempI64;
break;
case Setting::IS_VUHF_RANGE:
- gpoSettings->bIsVUHFRange = atoi( value ) ? true : false;
- break;
+ gpoSettings->bIsVUHFRange = atoi( value ) ? true : false;
+ break;
case Setting::COMPATIBILITY_VALUE:
- gpoSettings->iCompatibilityValue = atoi( value );
- break;
+ gpoSettings->iCompatibilityValue = atoi( value );
+ break;
case Setting::USE_VUHF_MULTIGAIN:
- gpoSettings->bUseVUHFExpert = atoi( value ) ? true : false;
- break;
+ gpoSettings->bUseVUHFExpert = atoi( value ) ? true : false;
+ break;
case Setting::GAIN_CONTROL_MODE:
snprintf( gpoSettings->acGainControlMode, 63, "%s", value );
break;
/* gpoSettings->bUseVUHFAutoMode = bool(atoi( value ));
- break;*/
+ break;*/
case Setting::LNA_VALUE:
gpoSettings->iLNAValue = atoi( value );
break;
diff --git a/src/ExtIO_RFspaceNetSDR.def b/src/ExtIO_RFspaceNetSDR.def
index 260ed7d..606e12f 100644
--- a/src/ExtIO_RFspaceNetSDR.def
+++ b/src/ExtIO_RFspaceNetSDR.def
@@ -1,6 +1,4 @@
-LIBRARY "ExtIO_RFspaceNetSDR"
-
; Explicit exports
EXPORTS
diff --git a/src/NetSDREmu.cpp b/src/NetSDREmu.cpp
index 42319e4..a33c9e7 100644
--- a/src/NetSDREmu.cpp
+++ b/src/NetSDREmu.cpp
@@ -27,6 +27,7 @@ volatile bool gRunUDP = false;
volatile bool gPrepData = true;
volatile int gBitDepth = 16;
volatile unsigned gSampleRate = 32000;
+const char * gszTarget = "NetSDR";
int NonExtIOCallback(int cnt, int status, float IQoffs, void *IQdata)
@@ -196,6 +197,10 @@ class RcvEmu
break;
case Info::OPTIONS:
case Info::NAK:
+ break;
+ case Info::REQ_TARGET:
+ mCtrl.setTargetName(gszTarget);
+ fprintf(stderr, "\n\nreport Target '%s'\n\n", gszTarget);
default: ;
}
@@ -253,6 +258,11 @@ int main(int argc, char **argv)
dataPort = atoi( argv[i] );
fprintf(stderr, "parsed dataPort %u from %s\n", dataPort, argv[i] );
}
+ if ( ++i < argc )
+ {
+ gszTarget = argv[i];
+ fprintf(stderr, "using target %s\n", argv[i] );
+ }
break;
}
@@ -271,7 +281,7 @@ int main(int argc, char **argv)
if ( printUsage )
{
- fprintf(stderr, "usage: NetSDRemu \n" );
+ fprintf(stderr, "usage: NetSDRemu \n" );
return 10;
}
diff --git a/src/procitec_replacements.h b/src/procitec_replacements.h
index d16e9c7..fe889d3 100644
--- a/src/procitec_replacements.h
+++ b/src/procitec_replacements.h
@@ -151,3 +151,16 @@ T PROCLIP(T val, T minVal, T maxVal)
return val;
}
+inline float PRO_INTN_TO_FLOAT(int16_t v, int)
+{
+ return v * (1.0F / 32768.0F);
+}
+
+inline float PRO_INTN_TO_FLOAT(const LITTLE_INT24_T & r, int)
+{
+ const void *vp = &r.lo - 1;
+ const int32_t *p = (const int32_t *)vp;
+ int32_t v = (*p) & 0xFFFFFF00;
+ return v * (1.0F / 2147483648.0F);
+}
+
diff --git a/src/rfspace_netsdr_control.cpp b/src/rfspace_netsdr_control.cpp
index 74a0477..87db28d 100644
--- a/src/rfspace_netsdr_control.cpp
+++ b/src/rfspace_netsdr_control.cpp
@@ -234,12 +234,14 @@ void RFspaceNetSDRControl::resetReceiverData()
mADModes.clear();
mHasADModes = false;
- mIQOutSmpRate = RFspaceNetSDRControl::IQOutSmpRate::SR_500kHz;
+ mIQOutSmpRate = 500 * 1000;
mHasIQOutSmpRate = false;
mUDPPacketSize = UDPPacketSize::LARGE;
mHasUDPPacketSize = false;
+ mTriggeredStop = true;
+
mUDPIpAddress[0] = 0;
mUDPPortNum = 0;
mHasIPandPortNum = false;
@@ -260,7 +262,6 @@ void RFspaceNetSDRControl::resetReceiverData()
bool RFspaceNetSDRControl::connect(const char * ip, unsigned portNo, int nConnectTimeoutMillis)
{
-
if ( mSocket.IsSocketPeerOpen() )
{
LOG_PRO( LOG_ERROR, "ERROR: Socket already connected !");
@@ -291,6 +292,7 @@ bool RFspaceNetSDRControl::connect(const char * ip, unsigned portNo, int nConnec
requestInterfaceVersion();
requestHwFwVersions(RFspaceNetSDRControl::HwFw::BOOT_CODE);
requestProductId();
+ requestRcvFrequencyRanges();
requestStatus();
}
@@ -619,7 +621,7 @@ const RFspaceNetSDRControl::CWStartup & RFspaceNetSDRControl::getCWStartup(bool
}
-const RFspaceNetSDRControl::IQOutSmpRate RFspaceNetSDRControl::getIQOutSmpRate(bool *pbOk) const
+const uint32_t RFspaceNetSDRControl::getIQOutSmpRate(bool *pbOk) const
{
if(pbOk)
*pbOk = mHasIQOutSmpRate;
@@ -770,8 +772,6 @@ void RFspaceNetSDRControl::setRcvFreq( int64_t rcvFreqHz)
WRITE_LITTLE_INT64( rcvFreqHz , wp ); //write frequency to last 5 bytes of buffer
mSocket.Send(acBuf, len);
- requestRcvFrequency();
- requestRcvFrequencyRanges();
}
@@ -855,12 +855,8 @@ void RFspaceNetSDRControl::setADModes( bool isDithering, ADGain gain )
{
if ( mSocket.IsSocketInvalid() )
return;
- uint8_t dither;
- if(isDithering)
- dither = uint8_t(ADDither::DITH_ON);
- else
- dither = uint8_t(ADDither::DITH_OFF);
+ uint8_t dither = (isDithering) ? uint8_t(ADDither::DITH_ON) : uint8_t(ADDither::DITH_OFF);
const unsigned int len = 6;
unsigned char acBuf[len] = { 6, 0, 0x8A, 0, 0, 0 };
@@ -872,10 +868,9 @@ void RFspaceNetSDRControl::setADModes( bool isDithering, ADGain gain )
WRITE_LITTLE_INT8( mode , wp ); //write frequency to last byte of buffer
mSocket.Send(acBuf, len);
- requestADMode();
}
-void RFspaceNetSDRControl::setIQOutSmpRate( IQOutSmpRate smpRate )
+void RFspaceNetSDRControl::setIQOutSmpRate(uint32_t smpRate)
{
if ( mSocket.IsSocketInvalid() )
return;
@@ -885,7 +880,7 @@ void RFspaceNetSDRControl::setIQOutSmpRate( IQOutSmpRate smpRate )
void * wp = &acBuf[len-4];
// channel information can be ignored since all channels have to have the same value
- WRITE_LITTLE_INT32( uint32_t(smpRate) , wp ); //write frequency to last 4 bytes of buffer
+ WRITE_LITTLE_INT32( smpRate, wp ); //write frequency to last 4 bytes of buffer
mSocket.Send(acBuf, len);
}
@@ -906,9 +901,6 @@ void RFspaceNetSDRControl::setUPDPacketSize ( UDPPacketSize packetSize)
void RFspaceNetSDRControl::setUDPInterface ( const char * ip, uint16_t portNum )
{
- //requestUDPInterface();
- // return;
-
if ( mSocket.IsSocketInvalid() )
return;
@@ -973,18 +965,49 @@ void RFspaceNetSDRControl::setCWStartup ( uint8_t wpm, CWFreq cwFreq, const char
mSocket.Send(acBuf, len);
}
+void RFspaceNetSDRControl::setTargetName(const char * name)
+{
+ if ( mSocket.IsSocketInvalid() )
+ return;
+
+ int slen = strlen(name);
+ uint8_t len = uint8_t(4 + slen + 1);
+ PROASSERT(len <= 32);
+
+ uint8_t acBuf[4+32] = { len, 0x0, 0x1, 0x0
+ , 0, 0, 0, 0, 0, 0, 0, 0
+ , 0, 0, 0, 0, 0, 0, 0, 0
+ , 0, 0, 0, 0, 0, 0, 0, 0
+ , 0, 0, 0, 0, 0, 0, 0, 0 };
+ void * p = &acBuf[4];
+ char * pc = (char*)p;
+ strncpy( pc, name, 31 );
+
+ unsigned msgLen = len; // 0 1 2 3 4 5 6 7 8 9
+ LOG_PRO( LOG_PROTOCOL, "\n\nfor target '%s' transmitting %u bytes. %x %x %x %x %c%c%c%c%c%c%c%c%c%c"
+ , name, msgLen
+ , unsigned(acBuf[0]), unsigned(acBuf[1]), unsigned(acBuf[2]), unsigned(acBuf[3])
+ , pc[0], pc[1], pc[2], pc[3], pc[4], pc[5], pc[6], pc[7], pc[8], pc[9]
+ );
+ mSocket.Send(acBuf, msgLen);
+}
+
+
void RFspaceNetSDRControl::start24BitDataStream()
{
setRcvState( UDPstate::START_UDP_DATA, ADCstate::SET_IQ_BASEBAND_DATA, BitDepthState::SET_24BIT_MODE, CaptureMode::SET_CONTIGUOUS_MODE );
+ mTriggeredStop = false;
}
void RFspaceNetSDRControl::start16BitDataStream()
{
setRcvState( UDPstate::START_UDP_DATA, ADCstate::SET_IQ_BASEBAND_DATA, BitDepthState::SET_16BIT_MODE, CaptureMode::SET_CONTIGUOUS_MODE);
+ mTriggeredStop = false;
}
void RFspaceNetSDRControl::stopDataStream()
{
+ mTriggeredStop = true;
setRcvState( UDPstate::STOP_UDP_DATA, ADCstate::SET_IQ_BASEBAND_DATA, BitDepthState::SET_16BIT_MODE, CaptureMode::SET_CONTIGUOUS_MODE); // args 2,3,4 are dummy values --> ignored by NetSDR
}
@@ -993,7 +1016,6 @@ void RFspaceNetSDRControl::stopDataStream()
bool RFspaceNetSDRControl::poll( )
{
-
if ( mSocket.IsSocketInvalid() )
return false;
@@ -1029,6 +1051,7 @@ bool RFspaceNetSDRControl::poll( )
}
else
{
+ //LOG_PRO( LOG_PROTOCOL, "\n\nreceived Type %u Len %u\n", mRxType, mRxMsgLen);
processReceivedControlMessage(true);
mRxLen = 0;
mRxMsgLen = 2;
@@ -1090,10 +1113,18 @@ bool RFspaceNetSDRControl::processReceivedControlMessage(bool isValidMessage)
break;
case 0x0001: // 4.1.1 Target Name
- wp = &mRxBuffer[4];
- strncpy(mTargetName,(const char*)(wp),31 );
- mHasTargetName = true;
- LOG_PRO( LOG_DEBUG, "received %s : '%s'", getControlItemText(uControlItemCode), mTargetName);
+ LOG_PRO( LOG_DEBUG, "received Target : Type %u Len %u", mRxType, mRxMsgLen );
+ if ( MsgType(mRxType << 5) == MsgType::SET_CTRL_ITEM )
+ {
+ wp = &mRxBuffer[4];
+ memset(mTargetName, 0, sizeof(mTargetName));
+ strncpy(mTargetName,(const char*)(wp), mRxMsgLen);
+ mHasTargetName = true;
+ LOG_PRO( LOG_DEBUG, "received %s : '%s'", getControlItemText(uControlItemCode), mTargetName);
+ mpCallBack->receiveRFspaceNetSDRControlInfo(CallbackIfc::Info::SET_TARGET);
+ }
+ else if ( MsgType(mRxType << 5) == MsgType::REQ_CTRL_ITEM )
+ mpCallBack->receiveRFspaceNetSDRControlInfo(CallbackIfc::Info::REQ_TARGET);
break;
case 0x0002: // 4.1.2 Serial Number
@@ -1273,7 +1304,7 @@ bool RFspaceNetSDRControl::processReceivedControlMessage(bool isValidMessage)
case 0x00B8: // 4.2.10 IQ Output Data Samplerate
mHasIQOutSmpRate = true;
wp = &mRxBuffer[5];
- mIQOutSmpRate = IQOutSmpRate(READ_LITTLE_INT32( wp ));
+ mIQOutSmpRate = READ_LITTLE_INT32( wp );
//printText(mIQOutSmpRate);
if(mpCallBack)
mpCallBack->receiveRFspaceNetSDRControlInfo(CallbackIfc::Info::IQ_OUT_SAMPLERATE);
@@ -1354,7 +1385,7 @@ void RFspaceNetSDRControl::parseOptionBits( ) // parameter2-bits currently not d
}
-void RFspaceNetSDRControl::parseRcvStateBytes( ) // parameter2-bits currently not defined !
+void RFspaceNetSDRControl::parseRcvStateBytes() // parameter2-bits currently not defined !
{
void * wp = &mRxBuffer[4];
unsigned int parBytes = READ_BIG_INT32( wp ); //Big Endian because information fields are only 1 byte each --> Little Endian for fields bigger than 8bits
@@ -1403,62 +1434,71 @@ void RFspaceNetSDRControl::parseRcvFrequencies( ) //data up to 40bits when frequ
mHasRcvFrequencyRanges = true;
wp = &mRxBuffer[4];
const RFspaceNetSDRControl::NCOChannel channel = RFspaceNetSDRControl::NCOChannel( READ_LITTLE_INT8(wp) );
+ const char * channelStr = (RFspaceNetSDRControl::NCOChannel::CHN1 == channel) ? "1"
+ : (RFspaceNetSDRControl::NCOChannel::CHN2 == channel) ? "2"
+ : (RFspaceNetSDRControl::NCOChannel::CHN12 == channel) ? "1+2" : "?";
+
wp = &mRxBuffer[5];
- unsigned char rangeNum = READ_LITTLE_INT8(wp);
+ const unsigned char rangeNum = READ_LITTLE_INT8(wp);
+ const int numRanges = rangeNum;
int dataIdx = 6;
- for(unsigned char i = 0 ; i < rangeNum; i++)
- {
- uint64_t minFrequency = 0;
- uint64_t maxFrequency = 0;
- uint64_t VCOFrequency = 0;
+ for (int i = 0; i < numRanges; ++i)
+ {
wp = &mRxBuffer[dataIdx];
- minFrequency = READ_LITTLE_INT64(wp);
+ uint64_t minFrequency = READ_LITTLE_INT64(wp);
wp = &mRxBuffer[dataIdx+5];
- maxFrequency = READ_LITTLE_INT64(wp);
+ uint64_t maxFrequency = READ_LITTLE_INT64(wp);
wp = &mRxBuffer[dataIdx+10];
- VCOFrequency = READ_LITTLE_INT64(wp);
+ uint64_t VCOFrequency = READ_LITTLE_INT64(wp);
+ dataIdx += 15;
+
+ minFrequency &= 0xFFFFFFFFFF;
+ maxFrequency &= 0xFFFFFFFFFF;
+ VCOFrequency &= 0xFFFFFFFFFF;
+
+ LOG_PRO(LOG_DEBUG, "<-- received CTRL_RANGE: channel %s, range %d of %d: %ld - %ld Hz. VCO %ld Hz"
+ , channelStr, i, numRanges
+ , long(minFrequency), long(maxFrequency), long(VCOFrequency));
- dataIdx = dataIdx+15;
if(channel == RFspaceNetSDRControl::NCOChannel::CHN1)
{
- if(i == 0)
+ if (i == 0)
{
- mRcvFrequencies.Chn1_Bnd1_MinFreq = minFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn1_Bnd1_MaxFreq = maxFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn1_Bnd1_VCO_DwnConvFreq = VCOFrequency & 0xFFFFFFFFFF;
+ mRcvFrequencies.Chn1_Bnd1_MinFreq = mRcvFrequencyRanges[0] = minFrequency;
+ mRcvFrequencies.Chn1_Bnd1_MaxFreq = mRcvFrequencyRanges[1] = maxFrequency;
+ mRcvFrequencies.Chn1_Bnd1_VCO_DwnConvFreq = VCOFrequency;
}
- else
+ else if (i == 1)
{
- mRcvFrequencies.Chn1_Bnd2_MinFreq = minFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn1_Bnd2_MaxFreq = maxFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn1_Bnd2_VCO_DwnConvFreq = VCOFrequency & 0xFFFFFFFFFF;
+ mRcvFrequencies.Chn1_Bnd2_MinFreq = mRcvFrequencyRanges[2] = minFrequency;
+ mRcvFrequencies.Chn1_Bnd2_MaxFreq = mRcvFrequencyRanges[3] = maxFrequency;
+ mRcvFrequencies.Chn1_Bnd2_VCO_DwnConvFreq = VCOFrequency;
}
}
else if(channel == RFspaceNetSDRControl::NCOChannel::CHN2)
{
- if(i == 0)
+ if (i == 0)
{
- mRcvFrequencies.Chn2_Bnd1_MinFreq = minFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn2_Bnd1_MaxFreq = maxFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn2_Bnd1_VCO_DwnConvFreq = VCOFrequency & 0xFFFFFFFFFF;
+ mRcvFrequencies.Chn2_Bnd1_MinFreq = minFrequency;
+ mRcvFrequencies.Chn2_Bnd1_MaxFreq = maxFrequency;
+ mRcvFrequencies.Chn2_Bnd1_VCO_DwnConvFreq = VCOFrequency;
}
- else
+ else if (i == 1)
{
- mRcvFrequencies.Chn2_Bnd2_MinFreq = minFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn2_Bnd2_MaxFreq = maxFrequency & 0xFFFFFFFFFF;
- mRcvFrequencies.Chn2_Bnd2_VCO_DwnConvFreq = VCOFrequency & 0xFFFFFFFFFF;
+ mRcvFrequencies.Chn2_Bnd2_MinFreq = minFrequency;
+ mRcvFrequencies.Chn2_Bnd2_MaxFreq = maxFrequency;
+ mRcvFrequencies.Chn2_Bnd2_VCO_DwnConvFreq = VCOFrequency;
}
}
else
LOG_PRO( LOG_DEBUG, "ERROR ! --> Channel selection not allowed (?) ");
-
- //Only one channel is supported by current NetSDR setup
- mRcvFrequencyRanges[0] = mRcvFrequencies.Chn1_Bnd1_MinFreq;
- mRcvFrequencyRanges[1] = mRcvFrequencies.Chn1_Bnd1_MaxFreq;
- mRcvFrequencyRanges[2] = mRcvFrequencies.Chn1_Bnd2_MinFreq;
- mRcvFrequencyRanges[3] = mRcvFrequencies.Chn1_Bnd2_MaxFreq;
}
+
+ LOG_PRO(LOG_DEBUG, "<-- -- received CTRL_RANGE: %ld - %ld, %ld - %ld Hz",
+ long(mRcvFrequencyRanges[0]), long(mRcvFrequencyRanges[1]),
+ long(mRcvFrequencyRanges[2]), long(mRcvFrequencyRanges[3]) );
+
break;
}
@@ -1611,7 +1651,7 @@ void RFspaceNetSDRControl::printText(const VUHFGains & vuhfGains, const char * p
LOG_PRO( LOG_DEBUG, " V/UHF IF Gain: %u", vuhfGains.IFOutputGainLevel );
}
-void RFspaceNetSDRControl::printText(const IQOutSmpRate & smpRate, const char * pacPreText)
+void RFspaceNetSDRControl::printSrateText(const uint32_t smpRate, const char * pacPreText)
{
LOG_PRO(LOG_DEBUG, "%s IQ Sample Rate: %u Hz", pacPreText, unsigned(smpRate));
}
@@ -1858,6 +1898,8 @@ const char * getText( RFspaceNetSDRControl::CallbackIfc::Info e)
case RFspaceNetSDRControl::CallbackIfc::Info::RCV_STATE : return "RCV_STATE";
case RFspaceNetSDRControl::CallbackIfc::Info::OPTIONS : return "OPTIONS";
case RFspaceNetSDRControl::CallbackIfc::Info::NAK : return "NAK";
+ case RFspaceNetSDRControl::CallbackIfc::Info::REQ_TARGET : return "REQ_TARGET";
+ case RFspaceNetSDRControl::CallbackIfc::Info::SET_TARGET : return "SET_TARGET";
default: return "ERROR !";
}
}
diff --git a/src/rfspace_netsdr_control.h b/src/rfspace_netsdr_control.h
index 75c4aba..5f4febb 100644
--- a/src/rfspace_netsdr_control.h
+++ b/src/rfspace_netsdr_control.h
@@ -8,8 +8,6 @@
// forward declaration
class CSimpleSocket;
-//*********************TODOs*************************************************************************************
-//***************************************************************************************************************
class RFspaceNetSDRControl
{
@@ -19,7 +17,22 @@ class RFspaceNetSDRControl
{
public:
- enum class Info { FREQUENCY, ADC_SCALE, RF_GAIN, VUHF_INFO, RF_FILTER, ADC_MODE, IQ_OUT_SAMPLERATE, UDP_PACKET_SIZE, UDP_INTERFACE, RCV_STATE , OPTIONS, NAK };
+ enum class Info {
+ FREQUENCY
+ , ADC_SCALE
+ , RF_GAIN
+ , VUHF_INFO
+ , RF_FILTER
+ , ADC_MODE
+ , IQ_OUT_SAMPLERATE
+ , UDP_PACKET_SIZE
+ , UDP_INTERFACE
+ , RCV_STATE
+ , OPTIONS
+ , NAK
+ , REQ_TARGET // Target got requested
+ , SET_TARGET // Target got set
+ };
virtual ~CallbackIfc() { }
virtual void receiveRFspaceNetSDRControlInfo(Info info) = 0;
@@ -61,35 +74,6 @@ class RFspaceNetSDRControl
// 4.2.8 A/D Modes ***************
enum class ADGain : uint8_t { ADGain_1_5 = 0x02, ADGain_1 = 0x00 };
- // A/D Converter frequency = 80 MHz
- static const uint32_t ADC_FREQ = 80 * 1000 * 1000;
-
- // 4.2.9I/Q Output Data Sample Rate ***************
- // this enum has to be in sync with RFspaceNetReceiver::srate_bws[]
- enum class IQOutSmpRate : uint32_t {
- SR_12kHz = ADC_FREQ / 6400
- , SR_16kHz = ADC_FREQ / 5000
- , SR_32kHz = ADC_FREQ / 2500
- , SR_62kHz = ADC_FREQ / 1280
- , SR_80kHz = ADC_FREQ / 1000
- , SR_100kHz = ADC_FREQ / 800
- , SR_125kHz = ADC_FREQ / 640
- , SR_160kHz = ADC_FREQ / 500
- , SR_200kHz = ADC_FREQ / 400
- , SR_250kHz = ADC_FREQ / 320
- , SR_312kHz = ADC_FREQ / 256
- , SR_400kHz = ADC_FREQ / 200
- , SR_500kHz = ADC_FREQ / 160
- , SR_625kHz = ADC_FREQ / 128
- , SR_800kHz = ADC_FREQ / 100
- , SR_1000kHz = ADC_FREQ / 80
- , SR_1250kHz = ADC_FREQ / 64
- , SR_1538kHz = ADC_FREQ / 52
- , SR_1666kHz = ADC_FREQ / 48
- , SR_1818kHz = ADC_FREQ / 44
- , SR_2000kHz = ADC_FREQ / 40
- };
-
// 4.4.2 Data Output Packet Size ***************
enum class UDPPacketSize : uint8_t { SMALL = 1, LARGE = 0 };
@@ -126,7 +110,7 @@ class RFspaceNetSDRControl
const unsigned getUDPPortNum(bool *pbOk) const;
const CWStartup & getCWStartup(bool *pbOk) const;
- const IQOutSmpRate getIQOutSmpRate(bool *pbOk) const;
+ const uint32_t getIQOutSmpRate(bool *pbOk) const;
const UDPPacketSize getUDPPacketSize(bool *pbOk) const;
const int64_t getRcvFrequency(bool *pbOk) const;
@@ -150,14 +134,16 @@ class RFspaceNetSDRControl
void setVUHFGains( bool isAutoMode, int LNAGain, int MixGain, int IFOutGain );
void setRFFilterSelection( RfFilterSel );
void setADModes( bool isDithering, ADGain );
- void setIQOutSmpRate ( IQOutSmpRate );
+ void setIQOutSmpRate(uint32_t);
void setUPDPacketSize ( UDPPacketSize );
void setUDPInterface( const char * ip, uint16_t portNum );
void setCWStartup ( uint8_t wpm, CWFreq , const char * asciiMessage);
+ void setTargetName(const char * name);
void start24BitDataStream();
void start16BitDataStream();
void stopDataStream();
+ inline bool dataStreamShouldRun() const { return !mTriggeredStop; }
void requestReceiverState();
void requestOptions();
@@ -182,7 +168,7 @@ class RFspaceNetSDRControl
static void printFilterText(const int &, const char * pacPreText = "received from device:");
static void printText(const bool &, const char * pacPreText = "received from device:");
static void printText(const float &, const char * pacPreText = "received from device:");
- static void printText(const IQOutSmpRate &, const char * pacPreText = "received from device:");
+ static void printSrateText(const uint32_t, const char * pacPreText = "received from device:");
static void printText(const UDPPacketSize &, const char * pacPreText = "received from device:");
static void printText(const RfGain &, const char * pacPreText = "received from device:");
static void printUDPIPText(const char * ip, const char * pacPreText = "received from device:");
@@ -259,6 +245,7 @@ class RFspaceNetSDRControl
private:
+ // Msg Type Byte == (3 Bit) << 1
enum class MsgType : uint8_t { SET_CTRL_ITEM = 0x00, REQ_CTRL_ITEM = 0x20, REQ_CTRL_RANGE = 0x40};
// 4.2.1 Receiver State ***************
@@ -464,12 +451,13 @@ class RFspaceNetSDRControl
float mRcvADAmplScale;
bool mHasRcvADAmplScale = false;
- IQOutSmpRate mIQOutSmpRate;
+ uint32_t mIQOutSmpRate;
bool mHasIQOutSmpRate = false;
UDPPacketSize mUDPPacketSize;
bool mHasUDPPacketSize = false;
+ volatile bool mTriggeredStop = true;
uint8_t mHexArray[10];
@@ -485,7 +473,7 @@ class RFspaceNetSDRControl
const char * getText( RFspaceNetSDRControl::RfGain);
const char * getFilterText( int filterSel );
const char * getText( RFspaceNetSDRControl::ADGain );
-const char * getText( RFspaceNetSDRControl::IQOutSmpRate );
+const char * getSrateText(uint32_t);
const char * getText( RFspaceNetSDRControl::UDPPacketSize );
const char * getText( RFspaceNetSDRControl::CWFreq );
const char * getText( uint8_t chnSetup );
diff --git a/src/rfspace_netsdr_receiver.cpp b/src/rfspace_netsdr_receiver.cpp
index c115eb1..46f8756 100644
--- a/src/rfspace_netsdr_receiver.cpp
+++ b/src/rfspace_netsdr_receiver.cpp
@@ -18,33 +18,73 @@
#define KHZ *1000
-const RFspaceNetReceiver::srate_bw RFspaceNetReceiver::srate_bws[] =
+// NetSDR A/D Converter frequency = 80 MHz
+static const uint32_t NETSDR_ADC_FREQ = 80 * 1000 * 1000;
+const int RFspaceNetReceiver::netsdr_default_srateIdx = 2; // == 32 kHz
+
+const RFspaceNetReceiver::srate_bw RFspaceNetReceiver::netsdr_srate_bws[] =
+{
+ { 12500, 10 KHZ, 24, "12.5 kHz" } // 0
+ , { 16 KHZ, 12 KHZ, 24, "16 kHz" }
+ , { 32 KHZ, 25 KHZ, 24, "32 kHz" } // 2
+ , { 62500, 50 KHZ, 24, "62.5 kHz" }
+ , { 80 KHZ, 64 KHZ, 24, "80 kHz" }
+ , { 100 KHZ, 80 KHZ, 24, "100 kHz" } // 5
+ , { 125 KHZ, 100 KHZ, 24, "125 kHz" }
+ , { 160 KHZ, 128 KHZ, 24, "160 kHz" }
+ , { 200 KHZ, 160 KHZ, 24, "200 kHz" }
+ , { 250 KHZ, 200 KHZ, 24, "250 kHz" }
+ , { 312500, 250 KHZ, 24, "312.5 kHz" } // 10
+ , { 400 KHZ, 320 KHZ, 24, "400 kHz" }
+ , { 500 KHZ, 400 KHZ, 24, "500 kHz" }
+ , { 625 KHZ, 500 KHZ, 24, "625 kHz" }
+ , { 800 KHZ, 640 KHZ, 24, "800 kHz" }
+ , { 1000 KHZ, 800 KHZ, 24, "1 MHz" } // 15
+ , { 1250 KHZ, 1000 KHZ, 24, "1.25 MHz" }
+ , { 1538461, 1200 KHZ, 16, "1.538 MHz" }
+ , { 1666666, 1300 KHZ, 16, "1.666 MHz" }
+ , { 1818181, 1400 KHZ, 16, "1.818 MHz" }
+ , { 2000 KHZ, 1600 KHZ, 16, "2 MHz" } // 20
+};
+
+// CloudIQ A/D Converter frequency = 122.88 MHz
+static const uint32_t CLOUDIQ_ADC_FREQ = 122880 * 1000;
+const int RFspaceNetReceiver::cloudiq_default_srateIdx = 0; // == 48 kHz
+
+const RFspaceNetReceiver::srate_bw RFspaceNetReceiver::cloudiq_srate_bws[] =
{
- { 6400, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_12kHz ), 12500, 10 KHZ, "12.5 kHz" } // 0
-, { 5000, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_16kHz ), 16 KHZ, 12 KHZ, "16 kHz" }
-, { 2500, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_32kHz ), 32 KHZ, 25 KHZ, "32 kHz" }
-, { 1280, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_62kHz ), 62500, 50 KHZ, "62.5 kHz" }
-, { 1000, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_80kHz ), 80 KHZ, 64 KHZ, "80 kHz" }
-, { 800, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_100kHz ), 100 KHZ, 80 KHZ, "100 kHz" } // 5
-, { 640, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_125kHz ), 125 KHZ, 100 KHZ, "125 kHz" }
-, { 500, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_160kHz ), 160 KHZ, 128 KHZ, "160 kHz" }
-, { 400, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_200kHz ), 200 KHZ, 160 KHZ, "200 kHz" }
-, { 320, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_250kHz ), 250 KHZ, 200 KHZ, "250 kHz" }
-, { 256, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_312kHz ), 312500, 250 KHZ, "312.5 kHz" } // 10
-, { 200, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_400kHz ), 400 KHZ, 320 KHZ, "400 kHz" }
-, { 160, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_500kHz ), 500 KHZ, 400 KHZ, "500 kHz" }
-, { 128, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_625kHz ), 625 KHZ, 500 KHZ, "625 kHz" }
-, { 100, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_800kHz ), 800 KHZ, 640 KHZ, "800 kHz" }
-, { 80, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_1000kHz), 1000 KHZ, 800 KHZ, "1 MHz" } // 15
-, { 64, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_1250kHz), 1250 KHZ, 1000 KHZ, "1.25 MHz" }
-, { 52, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_1538kHz), 1538461, 1200 KHZ, "1.538 MHz" }
-, { 48, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_1666kHz), 1666666, 1300 KHZ, "1.666 MHz" }
-, { 44, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_1818kHz), 1818181, 1400 KHZ, "1.818 MHz" }
-, { 40, uint32_t(RFspaceNetSDRControl::IQOutSmpRate::SR_2000kHz), 2000 KHZ, 1600 KHZ, "2 MHz" } // 20
+ // , { 12 KHZ, 9 KHZ, 24, "12 kHz" } // 0
+ // , { 16 KHZ, 12 KHZ, 24, "16 kHz" }
+ // , { 24 KHZ, 19 KHZ, 24, "24 kHz" }
+ // , { 32 KHZ, 25 KHZ, 24, "32 kHz" }
+ { 48 KHZ, 38 KHZ, 24, "48 kHz" } // 0
+ , { 64 KHZ, 51 KHZ, 24, "64 kHz" }
+ , { 96 KHZ, 76 KHZ, 24, "96 kHz" }
+ , { 128 KHZ, 102 KHZ, 24, "128 kHz" }
+ , { 160 KHZ, 128 KHZ, 24, "160 kHz" }
+ , { 192 KHZ, 153 KHZ, 24, "192 kHz" } // 5
+ , { 256 KHZ, 204 KHZ, 24, "256 kHz" }
+ , { 384 KHZ, 307 KHZ, 24, "384 kHz" }
+ , { 512 KHZ, 409 KHZ, 24, "512 kHz" }
+ , { 640 KHZ, 512 KHZ, 24, "640 kHz" }
+ , { 768 KHZ, 614 KHZ, 24, "768 kHz" } // 10
+ , { 960 KHZ, 768 KHZ, 24, "960 kHz" }
+ , { 1024 KHZ, 819 KHZ, 24, "1024 kHz" }
+ , { 1280 KHZ, 1024 KHZ, 24, "1280 kHz" }
+ , { 1536 KHZ, 1228 KHZ, 16, "1536 kHz" }
+ , { 1616842, 1290 KHZ, 16, "1616.8 kHz" } // 15: divisor=76
+ , { 1706666, 1365 KHZ, 16, "1706.6 kHz" }
+ , { 1807058, 1445 KHZ, 16, "1807.1 kHz" } // divisor=68
+ //, { 1920 KHZ, 1536 KHZ, 16, "1920 kHz" } // divisor=64 -> stuttering
+ //, { 2048 KHZ, 1638 KHZ, 16, "2048 kHz" } // divisor=60 -> stuttering
};
#undef KHZ
+const RFspaceNetReceiver::srate_bw * RFspaceNetReceiver::srate_bws = netsdr_srate_bws;
+int RFspaceNetReceiver::miNumSamplerates = (int)(NUMEL(RFspaceNetReceiver::netsdr_srate_bws));
+int RFspaceNetReceiver::miDefaultSrateIdx = RFspaceNetReceiver::netsdr_default_srateIdx;
+
// 0 1 2 3 4 5 6 7
const float RFspaceNetReceiver::mafAttenuationATTs[] = { -30.0F, -30.0F, -20.0F, -20.0F, -10.0F, -10.0F, 0.0F, 0.0F };
const float RFspaceNetReceiver::mafActualAttenuationATTs[] = { -30.0F, -26.5F, -20.0F, -16.5F, -10.0F, -6.5F, 0.0F, 3.5F };
@@ -65,11 +105,36 @@ const RFspaceNetSDRControl::RfGain RFspaceNetReceiver::mVUHF_RFGainAttenuations[
const int RFspaceNetReceiver::miNumAttenuations = (int)( NUMEL(mafAttenuationATTs) );
const int RFspaceNetReceiver::miNumCompatibilityGains = (int)( sizeof(mafVUHFCompatibilityGainValues) / sizeof(mafVUHFCompatibilityGainValues[0]) );
const int RFspaceNetReceiver::miNumMultiGains = (int)( sizeof(mafVUHFMultiGainValues) / sizeof(mafVUHFMultiGainValues[0]) );
-const int RFspaceNetReceiver::miNumSamplerates = (int)(sizeof(srate_bws) / sizeof(srate_bws[0]));
#define NORMALIZE_DATA 0
+bool RFspaceNetReceiver::applyHwModel(const RFspaceNetReceiver::Settings & roSet)
+{
+ if (!strcmp(roSet.acModel, "NetSDR"))
+ {
+ if (srate_bws != netsdr_srate_bws)
+ {
+ srate_bws = netsdr_srate_bws;
+ miNumSamplerates = (int)(NUMEL(netsdr_srate_bws));
+ miDefaultSrateIdx = netsdr_default_srateIdx;
+ return true;
+ }
+ }
+ else if (!strcmp(roSet.acModel, "CloudIQ"))
+ {
+ if (srate_bws != cloudiq_srate_bws)
+ {
+ srate_bws = cloudiq_srate_bws;
+ miNumSamplerates = (int)(NUMEL(cloudiq_srate_bws));
+ miDefaultSrateIdx = cloudiq_default_srateIdx;
+ return true;
+ }
+ }
+ return false;
+}
+
+
int RFspaceNetReceiver::getDefaultHWType()
{
#if NORMALIZE_DATA
@@ -149,6 +214,8 @@ RFspaceNetReceiver::RFspaceNetReceiver()
mHasVUHFFreqRange = true;
mHasOptions = false;
+ mReportChangedSamplerates = false;
+
mStartUDPTimer = 0;
mStartData = false;
@@ -156,13 +223,13 @@ RFspaceNetReceiver::RFspaceNetReceiver()
mGainControlMode = GainControlMode::AUTO;
- mNetSdrBitDepth = 16;
+ mDeviceBitDepth = 16;
#if NORMALIZE_DATA
mLastReportedSampleFormat = mExtHwSampleFormat = extHw_SampleFormat_FLT32;
mExtHwBitDepth = 32;
#else
- mLastReportedSampleFormat = mExtHwSampleFormat = (mNetSdrBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
- mExtHwBitDepth = (mNetSdrBitDepth == 24) ? 24 : 16;
+ mLastReportedSampleFormat = mExtHwSampleFormat = (mDeviceBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
+ mExtHwBitDepth = (mDeviceBitDepth == 24) ? 24 : 16;
#endif
}
@@ -183,27 +250,29 @@ void RFspaceNetReceiver::receiveRfspaceNetSDRUdpData(const unsigned fmt, const v
mTimeWithoutDataInMilliseconds = 0;
if (!mExtIOCallbackPtr)
{
- LOG_PRO(LOG_ERROR, "RFspaceNetReceiver::receiveRfspaceNetSDRUdpData(): mExtIOCallbackPtr == NULL");
+ LOG_PRO(LOG_ERROR, "<-- RFspaceNetReceiver::receiveRfspaceNetSDRUdpData(): mExtIOCallbackPtr == NULL");
return;
}
+ if (!rcv.dataStreamShouldRun())
+ return;
if (mLastReportedFmt != fmt || bSequenceNumError)
{
mSampleBufferLenInFrames = 0;
if (!fmt || fmt > 4)
- LOG_PRO(LOG_ERROR, "Received format %u of sample data from UDP is unknown!", mLastReportedFmt);
+ LOG_PRO(LOG_ERROR, "<-- Received format %u of sample data from UDP is unknown!", mLastReportedFmt);
- mNetSdrBitDepth = (fmt <= 2) ? 16 : 24;
+ mDeviceBitDepth = (fmt <= 2) ? 16 : 24;
#if NORMALIZE_DATA
mExtHwSampleFormat = extHw_SampleFormat_FLT32;
mExtHwBitDepth = 32;
#else
- mExtHwSampleFormat = (mNetSdrBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
- mExtHwBitDepth = (mNetSdrBitDepth == 24) ? 24 : 16;
+ mExtHwSampleFormat = (mDeviceBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
+ mExtHwBitDepth = (mDeviceBitDepth == 24) ? 24 : 16;
#endif
if (mLastReportedSampleFormat != mExtHwSampleFormat)
{
- LOG_PRO(LOG_ERROR, "SEND STATUS CHANGE TO SDR: NEW BIT DEPTH %d Bit. while running => ERROR!.", mExtHwBitDepth);
+ LOG_PRO(LOG_ERROR, "<-- SEND STATUS CHANGE TO SDR: NEW BIT DEPTH %d Bit. while running => ERROR!.", mExtHwBitDepth);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, mExtHwSampleFormat);
mLastReportedSampleFormat = mExtHwSampleFormat;
}
@@ -249,7 +318,7 @@ void RFspaceNetReceiver::receiveRfspaceNetSDRUdpData(const unsigned fmt, const v
numFramesToProcFromInput = (EXT_BLOCKLEN - mSampleBufferLenInFrames);
for ( int k = 0; k < numFramesToProcFromInput*2; ++k )
- mSampleBufferFlt[mSampleBufferLenInFrames*2 + k] = PRO_INTN_TO_FLOAT( int32_t( puInputSamples[srcFrameOffset*2 + k] ), 24 ) * factor;
+ mSampleBufferFlt[mSampleBufferLenInFrames*2 + k] = PRO_INTN_TO_FLOAT( puInputSamples[srcFrameOffset*2 + k], 24 ) * factor;
mSampleBufferLenInFrames += numFramesToProcFromInput;
if ( mSampleBufferLenInFrames == EXT_BLOCKLEN )
@@ -328,19 +397,18 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
int64_t actualFrequency = rcv.getRcvFrequency(&pbOk);
if(pbOk)
{
- EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_LO );
if(actualFrequency != mpoSettings->iFrequency || mHasDifferentLOFrequency)
{
mpoSettings->iFrequency = actualFrequency;
- LOG_PRO( LOG_ERROR, " RECEIVED CALLBACK WITH UNEXPECTED FREQUENCY : %ld Hz ", long(actualFrequency) );
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH UNEXPECTED LO FREQUENCY : %ld Hz ", long(actualFrequency) );
mHasDifferentLOFrequency = false;
+ EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, extHw_Changed_LO);
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH EXPECTED FREQUENCY : %ld Hz ", long(actualFrequency) );
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH EXPECTED LO FREQUENCY : %ld Hz ", long(actualFrequency) );
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF FREQUENCY : %ld Hz --> ERROR !", long(actualFrequency) );
-
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH ERRONEOUS RETURN OF LO FREQUENCY : %ld Hz --> ERROR !", long(actualFrequency) );
pbOk = false;
const int64_t * actualFrequencyRange = rcv.getRcvFrequencyRanges(&pbOk);
@@ -369,11 +437,11 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
mpoSettings->mfGainCompensationFactor = 1.0F / ( pow(10.0F,(mafActualAttenuationATTs[mpoSettings->iControlValue]/20.0F)) ); // log20 to linear --> lin = 10 ^ (db/20) (voltage)
- LOG_PRO( LOG_ERROR, " RECEIVED CALLBACK WITH UNEXPECTED RF_GAIN : %d dB. New RFGainIdx : %d", mRFGaindB, mpoSettings->iControlValue);
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH UNEXPECTED RF_GAIN : %d dB. New RFGainIdx : %d", mRFGaindB, mpoSettings->iControlValue);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_ATT );
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH EXPECTED RF_GAIN : %d dB. New RFGainIdx : %d", mRFGaindB, mpoSettings->iControlValue);
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH EXPECTED RF_GAIN : %d dB. New RFGainIdx : %d", mRFGaindB, mpoSettings->iControlValue);
break;
}
@@ -384,7 +452,7 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
mRFGaindB = actualRFGain;
mpoSettings->iControlValue = getAttIdx();
- LOG_PRO( LOG_ERROR, " RECEIVED CALLBACK WITH UNEXPECTED COMPATIBILITY_GAIN_VALUE : %d", mpoSettings->iControlValue);
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH UNEXPECTED COMPATIBILITY_GAIN_VALUE : %d", mpoSettings->iControlValue);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_ATT );
}
@@ -393,15 +461,14 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
case ReceiverMode::VUHF_EXP:
break; // no implementation of VUHF_EXP in this Callback
default:
- LOG_PRO( LOG_ERROR, "*** SWITCH CASE ERROR: UNKNOWN RECEIVER MODE !");
+ LOG_PRO(LOG_ERROR, "<-- UNKNOWN RECEIVER MODE !");
}
}
else
if(mReceiverMode == ReceiverMode::HF)
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF RF_GAIN : %d --> ERROR !", actualRFGain );
+ LOG_PRO(LOG_DEBUG, " <-- RECEIVED CALLBACK WITH ERRONEOUS RETURN OF RF_GAIN : %d --> ERROR !", actualRFGain );
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF COMPATIBILITY_GAIN_VALUE --> ERROR !" );
-
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH ERRONEOUS RETURN OF COMPATIBILITY_GAIN_VALUE --> ERROR !" );
break;
}
@@ -444,15 +511,15 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
mpoSettings->mfGainCompensationFactor = 1.0F / ( pow(10.0F,(mafActualAttenuationATTs[mpoSettings->iControlValue]/20.0F)) ); // log20 to linear --> lin = 10 ^ (db/20) (voltage)
- LOG_PRO( LOG_ERROR, " RECEIVED CALLBACK WITH UNEXPECTED AD_GAIN : %.1f . New GainIdx : %d ", mADGain, mpoSettings->iControlValue);
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH UNEXPECTED AD_GAIN : %.1f . New GainIdx : %d ", mADGain, mpoSettings->iControlValue);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_ATT ); // Different Gains (RFGain and MGC) are summed up in Attenuation "ATT"
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH EXPECTED AD_GAIN : %.1f . New GainIdx : %d ", mADGain, mpoSettings->iControlValue);
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH EXPECTED AD_GAIN : %.1f . New GainIdx : %d ", mADGain, mpoSettings->iControlValue);
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF AD_GAIN : %.1f --> ERROR ! ", actualADGain);
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH ERRONEOUS RETURN OF AD_GAIN : %.1f --> ERROR ! ", actualADGain);
break;
}
@@ -464,18 +531,18 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
{
if(actualIQSmpRate != mpoSettings->uiLastReportedSamplerate) //Debug ==
{
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH UNEXPECTED IQ_OUT_SAMPLERATE %u Hz. Expected was %u Hz", actualIQSmpRate, mpoSettings->uiLastReportedSamplerate);
mpoSettings->uiSamplerate = actualIQSmpRate;
mpoSettings->uiLastReportedSamplerate = mpoSettings->uiSamplerate;
mpoSettings->iSampleRateIdx = getSmpRateIdx(actualIQSmpRate);
mpoSettings->uiBandwidth = srate_bws[mpoSettings->iSampleRateIdx].bw;
- LOG_PRO( LOG_ERROR, " RECEIVED CALLBACK WITH UNEXPECTED IQ_OUT_SAMPLERATE : %u Hz", actualIQSmpRate);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_SampleRate );
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH EXPECTED IQ_OUT_SAMPLERATE : %u Hz", actualIQSmpRate);
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH EXPECTED IQ_OUT_SAMPLERATE : %u Hz", actualIQSmpRate);
}
else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF IQ_OUT_SAMPLERATE : %d Hz --> ERROR !", actualIQSmpRate );
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH ERRONEOUS IQ_OUT_SAMPLERATE : %d Hz --> ERROR !", actualIQSmpRate );
break;
}
@@ -487,13 +554,25 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
{
mControlPingTime = 0;
bool bOk = false;
- bool isUDPRunning = rcv.isUDPDataStreamRunning(&bOk);
- if(bOk)
+ const bool isUDPRunning = rcv.isUDPDataStreamRunning(&bOk);
+ const bool bChanged = (mIsUDPRunning != isUDPRunning);
+ if (bOk && bChanged)
{
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH RCV_STATE --> now UDP state changed to '%s'"
+ , (isUDPRunning ? "running" : "stopped"));
mIsUDPRunning = isUDPRunning;
}
- else
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH ERRONEOUS RETURN OF RCV_STATE --> ERROR !" );
+ else if (!bOk)
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH ERRONEOUS RETURN OF RCV_STATE --> ERROR !" );
+
+
+ const int bitDepth = rcv.getStreamBitDepth(&bOk);
+ const bool isRunning = rcv.isUDPDataStreamRunning(&bOk);
+ if (bOk && rcv.dataStreamShouldRun())
+ {
+ if (mDeviceBitDepth != bitDepth)
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH RCV_STATE --> RCV_STATE bitDepth %d differs from expected %d Bit @ %u", bitDepth, mDeviceBitDepth, mpoSettings->uiSamplerate);
+ }
break;
}
@@ -509,12 +588,33 @@ void RFspaceNetReceiver::receiveRFspaceNetSDRControlInfo(Info info)
{
mHasVUHFFreqRange = mReceiverOptions.DownConverterBoard_Present;
mHasOptions = true;
- LOG_PRO( LOG_DEBUG, " RECEIVED CALLBACK WITH OPTIONS !" );
+ LOG_PRO(LOG_DEBUG, "<-- RECEIVED CALLBACK WITH OPTIONS !" );
}
}
break;
}
+ case Info::SET_TARGET:
+ {
+ bool bOk;
+ const char * pTarget = rcv.getTargetName(&bOk);
+ if (bOk)
+ {
+ strcpy(mpoSettings->acModel, pTarget);
+ bool bAppliedTargetSrates = applyHwModel(*mpoSettings);
+ if (bAppliedTargetSrates)
+ {
+ LOG_PRO(LOG_PROTOCOL, "<-- RECEIVED CALLBACK WITH TARGET '%s' - modified Samplerates", pTarget);
+ mReportChangedSamplerates = true;
+ }
+ else
+ LOG_PRO(LOG_PROTOCOL, "<-- RECEIVED CALLBACK WITH TARGET '%s' - unknown or same target", pTarget);
+ }
+ else
+ LOG_PRO(LOG_ERROR, "<-- RECEIVED CALLBACK WITH unknown/erroneous TARGET");
+ break;
+ }
+
default:
break;
}
@@ -528,19 +628,19 @@ bool RFspaceNetReceiver::openHW(Settings * poSettings)
bool bTCPConnOK = rcv.connect( mpoSettings->acCtrlIP, mpoSettings->uCtrlPortNo, mpoSettings->nConnectTimeoutMillis );
if ( !bTCPConnOK )
{
- LOG_PRO( LOG_ERROR, "Error connecting to receiver %s:%u for control", mpoSettings->acCtrlIP, mpoSettings->uCtrlPortNo );
+ LOG_PRO( LOG_ERROR, "*** *** RFspaceNetReceiver::openHW(): Error connecting to receiver %s:%u for control", mpoSettings->acCtrlIP, mpoSettings->uCtrlPortNo );
return false;
}
poSettings->bIsTCPConnected = true;
int samplerateIdx = poSettings->iSampleRateIdx;
- samplerateIdx = PROCLIP(samplerateIdx, 0, int(NUMEL(srate_bws)));
-
- poSettings->uiSamplerate = srate_bws[samplerateIdx].srate;
- LOG_PRO( LOG_DEBUG, "********************************** RFspaceNetReceiver::openHW() : SENDING SAMPLERATE FREQUENCY TO NETSDR: %dHz (idx: %d)", poSettings->uiSamplerate, poSettings->iSampleRateIdx);
+ samplerateIdx = PROCLIP(samplerateIdx, 0, miNumSamplerates - 1);
poSettings->iSampleRateIdx = samplerateIdx;
+ poSettings->uiSamplerate = srate_bws[samplerateIdx].srate;
+ poSettings->uiBandwidth = srate_bws[samplerateIdx].bw;
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::openHW()");
if(!poSettings->bIsVUHFRange)
{
@@ -589,28 +689,36 @@ bool RFspaceNetReceiver::openHW(Settings * poSettings)
}
}
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::openHW() -> calling setGain()");
setGain(poSettings->iControlValue);
- rcv.setIQOutSmpRate( RFspaceNetSDRControl::IQOutSmpRate(poSettings->uiSamplerate) );
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::openHW() -> calling setRFFilterSelection()");
rcv.setRFFilterSelection(RFspaceNetSDRControl::RfFilterSel::F_AUTO); // arg1 -> Filter Selection
- rcv.setUPDPacketSize( RFspaceNetSDRControl::UDPPacketSize::LARGE );
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::openHW() -> calling setUPDPacketSize()");
+ rcv.setUPDPacketSize(RFspaceNetSDRControl::UDPPacketSize::LARGE);
//rcv.setRcvADAmplScale( 0.5 ); // arg1 -> Skalierung
-
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::openHW() -> calling setIQOutSmpRate(%u Hz)", poSettings->uiSamplerate);
+ rcv.setIQOutSmpRate(poSettings->uiSamplerate);
return true;
}
bool RFspaceNetReceiver::startHW(int64_t LOfreq)
{
- if(!mpoSettings->bIsSocketBound)
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::startHW() called");
+ if (!mpoSettings->bIsSocketBound)
{
//initial binding and start streaming
- LOG_PRO(LOG_DEBUG, "Binding %s:%u for UDP data reception", mpoSettings->acDataIP, mpoSettings->uDataPortNo);
- bool bBindOK = udp.bindIfc( mpoSettings->acDataIP, mpoSettings->uDataPortNo );
+ const uint32_t ipSend = (mpoSettings->acDataIP[0]) ? CSimpleSocket::GetIPv4AddrInfoStatic(mpoSettings->acDataIP) : 0;
+ const uint16_t uDataPort = (ipSend) ? mpoSettings->uDataPortNo : mpoSettings->uCtrlPortNo;
+
+ LOG_PRO(LOG_DEBUG, "*** *** * Binding %s:%u for UDP data reception", mpoSettings->acDataIP, uDataPort);
+ bool bBindOK = udp.bindIfc(mpoSettings->acDataIP, uDataPort);
if ( !bBindOK )
{
- LOG_PRO( LOG_ERROR, "Error binding to socket %s:%u for UDP data reception", mpoSettings->acDataIP, mpoSettings->uDataPortNo );
+ LOG_PRO(LOG_ERROR, "*** *** * Error binding to socket %s:%u for UDP data reception", mpoSettings->acDataIP, uDataPort);
return false;
}
- rcv.setUDPInterface( mpoSettings->acDataIP, mpoSettings->uDataPortNo );
+ if (ipSend)
+ rcv.setUDPInterface(mpoSettings->acDataIP, uDataPort);
mpoSettings->bIsSocketBound = true;
}
@@ -626,7 +734,8 @@ bool RFspaceNetReceiver::startHW(int64_t LOfreq)
{
//restart udp data (24bit/16bit) after "mStartUDPTimer" ms in "TimerProc" --> NetSDR sometimes streams wrong bitrate (although claiming it would stream the right bitrate).
//--> give samplerate change (and sometimes therefore bitdepth change) more time.
- mStartUDPTimer = 200; //in ms
+ mStartUDPTimer = 50; //in ms
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::startHW(): will command to start streaming in %d ms", mStartUDPTimer);
mStartData = true;
}
@@ -636,31 +745,28 @@ bool RFspaceNetReceiver::startHW(int64_t LOfreq)
void RFspaceNetReceiver::setHWLO( int64_t LOFreq )
{
-
- if( LOFreq >= VUHF_FREQUENCY && !mHasVUHFFreqRange && mHasOptions)
- {
- LOG_PRO( LOG_ERROR, "**** RECEIVER SEEMS TO HAVE NO DOWNCONVERTER HARDWARE FOR VUHF FREQUENCY RANGE --> SETTING FREQUENCY TO 10MHZ !");
- int64_t defaultFreq = 10*1000*1000;
- rcv.setRcvFreq( defaultFreq );
- mpoSettings->iFrequency = defaultFreq;
- return;
- }
- else
+ //if( LOFreq >= VUHF_FREQUENCY && !mHasVUHFFreqRange && mHasOptions)
+ //{
+ // LOG_PRO( LOG_ERROR, "*** *** RFspaceNetReceiver::setHWLO(): RECEIVER SEEMS TO HAVE NO DOWNCONVERTER HARDWARE FOR VUHF FREQUENCY RANGE --> SETTING FREQUENCY TO 10MHZ !");
+ // int64_t defaultFreq = 10*1000*1000;
+ // rcv.setRcvFreq( defaultFreq );
+ // mpoSettings->iFrequency = defaultFreq;
+ // return;
+ //}
+ //else
{
- LOG_PRO( LOG_DEBUG, "RFspaceNetReceiver::setHWLO() : RECEIVED LOFreq : %ld Hz", long(LOFreq));
-
+ LOG_PRO( LOG_DEBUG, "*** *** RFspaceNetReceiver::setHWLO(%ld Hz) called", long(LOFreq));
int64_t actualSetLOFreq = LOFreq;
//Set frequency according to available frequency ranges (information received from NetSDR)
- if(LOFreq < mpoSettings->iBand_minFreq || LOFreq > mpoSettings->iBand_maxFreq)
- {
- actualSetLOFreq = PROCLIP( LOFreq, mpoSettings->iBand_minFreq, mpoSettings->iBand_maxFreq);
- mHasDifferentLOFrequency = true;
- LOG_PRO( LOG_ERROR, "RFspaceNetReceiver::setHWLO(%ld) : OUT OF AVAILABLE FREQUENCY RANGE! SETTING mpoSettings->iFrequency = %ld Hz", long(LOFreq), long(actualSetLOFreq));
- }
- else
- LOG_PRO( LOG_DEBUG, "RFspaceNetReceiver::setHWLO(%ld) : SETTING mpoSettings->iFrequency = %ld Hz", long(LOFreq), long(actualSetLOFreq));
-
+ //if(LOFreq < mpoSettings->iBand_minFreq || LOFreq > mpoSettings->iBand_maxFreq)
+ //{
+ // actualSetLOFreq = PROCLIP( LOFreq, mpoSettings->iBand_minFreq, mpoSettings->iBand_maxFreq);
+ // mHasDifferentLOFrequency = true;
+ // LOG_PRO( LOG_ERROR, "*** *** * RFspaceNetReceiver::setHWLO(%ld) : OUT OF AVAILABLE FREQUENCY RANGE! SETTING mpoSettings->iFrequency = %ld Hz", long(LOFreq), long(actualSetLOFreq));
+ //}
+ //else
+ // LOG_PRO( LOG_DEBUG, "*** *** * RFspaceNetReceiver::setHWLO(%ld) : SETTING mpoSettings->iFrequency = %ld Hz", long(LOFreq), long(actualSetLOFreq));
if(mpoSettings->iFrequency != actualSetLOFreq)
{
@@ -672,7 +778,6 @@ void RFspaceNetReceiver::setHWLO( int64_t LOFreq )
void RFspaceNetReceiver::setGain( int idx )
{
-
switch(mReceiverMode)
{
case ReceiverMode::HF:
@@ -691,7 +796,7 @@ void RFspaceNetReceiver::setGain( int idx )
rcv.setADModes(mIsDithering, RFspaceNetSDRControl::ADGain::ADGain_1_5);
rcv.setRFGain(RFspaceNetSDRControl::RfGain(mRFGaindB));
- LOG_PRO( LOG_DEBUG, "setting ADGain = %f, RFGain %d for Att Idx = %i", mADGain, mRFGaindB, mpoSettings->iControlValue);
+ LOG_PRO( LOG_DEBUG, "*** *** setting ADGain = %f, RFGain %d for Att Idx = %i", mADGain, mRFGaindB, mpoSettings->iControlValue);
mpoSettings->iControlValue = idx;
break;
@@ -705,7 +810,7 @@ void RFspaceNetReceiver::setGain( int idx )
mRFGaindB = int(mVUHF_RFGainAttenuations[idx]); // has ot be set here
rcv.setRFGain(mVUHF_RFGainAttenuations[idx]); // in VUHF Compatibility Mode: Auto Gain -> -30dB ; Low Gain -> -20dB; Medium Gain -> -10dB; High Gain -> 0dB
// --> So we can use madAttenuationATTs[] for VUHF Compatibility Settings
- LOG_PRO( LOG_DEBUG, "setting Compatibility Value Idx : %d", idx);
+ LOG_PRO( LOG_DEBUG, "*** *** setting Compatibility Value Idx : %d", idx);
mpoSettings->iControlValue = idx;
break;
@@ -743,7 +848,7 @@ void RFspaceNetReceiver::setGain( int idx )
rcv.setVUHFGains(isAutoMode, LNAValue , MixValue, IFOutputValue);
- LOG_PRO( LOG_DEBUG, "setting AutoMode: %s ", isAutoMode ? "ON" : "OFF" );
+ LOG_PRO( LOG_DEBUG, "*** *** setting AutoMode: %s ", isAutoMode ? "ON" : "OFF" );
if(!isAutoMode)
{
LOG_PRO( LOG_DEBUG, "setting LNA Value: %d ", LNAValue );
@@ -759,48 +864,47 @@ void RFspaceNetReceiver::setGain( int idx )
void RFspaceNetReceiver::setSamplerate( int idx )
{
- int numSamplerates = int(NUMEL(srate_bws));
+ const int numSamplerates = RFspaceNetReceiver::miNumSamplerates;
if ( idx < 0 || idx > numSamplerates )
{
int newIdx = PROCLIP(idx, 0, numSamplerates);
- LOG_PRO( LOG_ERROR, "RFspaceNetReceiver::setSamplerate(idx %d) : idx out of bounds --> Setting to %d", idx, newIdx);
+ LOG_PRO( LOG_ERROR, "*** *** RFspaceNetReceiver::setSamplerate(idx %d) : idx out of bounds --> Setting to %d", idx, newIdx);
idx = newIdx;
}
- mpoSettings->iSampleRateIdx = idx;
- mpoSettings->uiSamplerate = srate_bws[idx].srate;
- mpoSettings->uiBandwidth = srate_bws[idx].bw;
-
bool bOk = false;
-
- bool bIsStreaming = rcv.isUDPDataStreamRunning(&bOk);
+ const bool bIsStreaming = rcv.isUDPDataStreamRunning(&bOk);
if (bIsStreaming && bOk)
{
- LOG_PRO( LOG_ERROR, "************************************** RFspaceNetReceiver::setSamplerate(): send ChangedSamplerate-Callback while running! *********************************");
- EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_SampleRate );
+ LOG_PRO( LOG_ERROR, "*** *** RFspaceNetReceiver::setSamplerate(): send ChangedSamplerate-Callback while running!");
+ EXTIO_STATUS_CHANGE(mExtIOCallbackPtr , extHw_Changed_SampleRate);
mpoSettings->uiLastReportedSamplerate = mpoSettings->uiSamplerate;
return;
}
+ mpoSettings->iSampleRateIdx = idx;
+ mpoSettings->uiSamplerate = srate_bws[idx].srate;
+ mpoSettings->uiBandwidth = srate_bws[idx].bw;
+
// currently not streaming:
- LOG_PRO(LOG_DEBUG, "************************************** RFspaceNetReceiver::setSamplerate(%u): set Samplerate ************************", mpoSettings->uiSamplerate);
- rcv.setIQOutSmpRate(RFspaceNetSDRControl::IQOutSmpRate(mpoSettings->uiSamplerate));
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::setSamplerate(%u): calling setIQOutSmpRate()", mpoSettings->uiSamplerate);
+ rcv.setIQOutSmpRate(mpoSettings->uiSamplerate);
{
- int changeBitRangeSmpRateIdx = getMaxSmpRateIdx(mpoSettings->iBitDepthThresSamplerate);
- mNetSdrBitDepth = (mpoSettings->iSampleRateIdx <= changeBitRangeSmpRateIdx) ? 24 : 16;
+ mDeviceBitDepth = (mpoSettings->bUse16BitForAll) ? 16 : srate_bws[mpoSettings->iSampleRateIdx].maxBitDepth;
+ LOG_PRO(LOG_DEBUG, "*** *** * RFspaceNetReceiver::setSamplerate(%u): deviceBitDepth %d Bit", mpoSettings->uiSamplerate, mDeviceBitDepth);
#if NORMALIZE_DATA
mExtHwSampleFormat = extHw_SampleFormat_FLT32;
mExtHwBitDepth = 32;
#else
- mExtHwSampleFormat = (mNetSdrBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
- mExtHwBitDepth = (mNetSdrBitDepth == 24) ? 24 : 16;
+ mExtHwSampleFormat = (mDeviceBitDepth == 24) ? extHw_SampleFormat_PCM24 : extHw_SampleFormat_PCM16;
+ mExtHwBitDepth = (mDeviceBitDepth == 24) ? 24 : 16;
#endif
if (mLastReportedSampleFormat != mExtHwSampleFormat)
{
- LOG_PRO(LOG_PROTOCOL, "SEND STATUS CHANGE TO SDR: NEW BIT DEPTH %d Bit.", mExtHwBitDepth);
+ LOG_PRO(LOG_PROTOCOL, "*** *** * SEND STATUS CHANGE TO SDR: NEW BIT DEPTH %d Bit.", mExtHwBitDepth);
EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, mExtHwSampleFormat);
mLastReportedSampleFormat = mExtHwSampleFormat;
}
@@ -818,8 +922,8 @@ int RFspaceNetReceiver::getAttIdx()
int ret = -1;
for(int idx = 0; idx <= miNumAttenuations-1; ++idx)
{
- if( ( mafAttenuationATTs[idx] == mRFGaindB) && ( fabsf(mafAttenuationADGains[idx] - mADGain) < 0.1 ) )
- LOG_PRO( LOG_DEBUG, "******** RFspaceNetReceiver::getAttIdx() : ADGain: %.1f, RFGain: %.1f --> idx: %d", mafAttenuationATTs[idx], mafAttenuationADGains[idx] , idx);
+ if( fabsf( mafAttenuationATTs[idx] - mRFGaindB) < 0.1 && ( fabsf(mafAttenuationADGains[idx] - mADGain) < 0.1 ) )
+ LOG_PRO( LOG_DEBUG, "*** *** RFspaceNetReceiver::getAttIdx() : ADGain: %.1f, RFGain: %.1f --> idx: %d", mafAttenuationATTs[idx], mafAttenuationADGains[idx] , idx);
ret = idx;
break;
}
@@ -827,27 +931,6 @@ int RFspaceNetReceiver::getAttIdx()
}
int RFspaceNetReceiver::getSmpRateIdx( uint32_t smpRate )
-{
- int ret = -1;
- for(int idx = 0; idx < miNumSamplerates; ++idx)
- {
- int32_t delta = smpRate - srate_bws[idx].srate;
- if( -10 <= delta && delta <= 10 ) // +/- 10 Hz tolerance
- {
- LOG_PRO( LOG_DEBUG, "********* RFspaceNetReceiver::getSmpRateIdx(%u) --> idx: %d", smpRate, idx);
- ret = idx;
- break;
- }
- }
-
- if(ret == -1)
- LOG_PRO(LOG_ERROR, "********* RFspaceNetReceiver::getSmpRateIdx(%u) --> idx: ERROR !", smpRate);
-
- return ret;
-}
-
-
-int RFspaceNetReceiver::getMaxSmpRateIdx(uint32_t smpRate)
{
int ret = -1;
for (int idx = 0; idx < miNumSamplerates; ++idx)
@@ -855,10 +938,16 @@ int RFspaceNetReceiver::getMaxSmpRateIdx(uint32_t smpRate)
if (smpRate >= srate_bws[idx].srate)
ret = idx;
}
+
if (ret == -1)
- LOG_PRO(LOG_ERROR, "********* RFspaceNetReceiver::getMaxSmpRateIdx(%u) --> idx: ERROR !", smpRate);
+ {
+ ret = RFspaceNetReceiver::miDefaultSrateIdx;
+ LOG_PRO(LOG_ERROR, "*** *** RFspaceNetReceiver::getSmpRateIdx(%u) --> idx: ERROR. Returning default idx %d = %u Hz!", smpRate, ret, srate_bws[ret].srate);
+ }
+ else if (smpRate == srate_bws[ret].srate)
+ LOG_PRO(LOG_ERROR, "*** *** RFspaceNetReceiver::getSmpRateIdx(%u) --> idx: %d fits exactly", smpRate, ret);
else
- LOG_PRO(LOG_DEBUG, "********* RFspaceNetReceiver::getMaxSmpRateIdx(%u) --> idx: %d", smpRate, ret);
+ LOG_PRO(LOG_ERROR, "*** *** RFspaceNetReceiver::getSmpRateIdx(%u) --> idx: %d with %u Hz is nearest", smpRate, ret, srate_bws[ret].srate);
return ret;
}
@@ -870,19 +959,16 @@ const int64_t * RFspaceNetReceiver::getFrequencyRanges(int idx)
{
switch(idx)
{
- case 0:
- return &mRcvFrequencyRanges[0];
- case 1:
- return &mRcvFrequencyRanges[2];
- default :
- return nullptr;
+ case 0: return &mRcvFrequencyRanges[0];
+ case 1: return &mRcvFrequencyRanges[2];
+ default: return nullptr;
}
}
else
return nullptr;
}
-void RFspaceNetReceiver::TimerProc(uint16_t waitMs)
+void RFspaceNetReceiver::TimerProc(int waitMs)
{
if(mStartData)
{
@@ -893,14 +979,14 @@ void RFspaceNetReceiver::TimerProc(uint16_t waitMs)
mStartData = false;
setGain(mpoSettings->iControlValue);
- if (mNetSdrBitDepth==24)
+ if (mDeviceBitDepth == 24)
{
- LOG_PRO(LOG_DEBUG, "**************** RFspaceNetReceiver::setSamplerate(): START 24 BIT DATA STREAM *********************************");
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(): START DATA STREAM with 24 BIT");
rcv.start24BitDataStream();
}
- else if (mNetSdrBitDepth==16)
+ else if (mDeviceBitDepth == 16)
{
- LOG_PRO(LOG_DEBUG, "**************** RFspaceNetReceiver::setSamplerate(): START 16 BIT DATA STREAM *********************************");
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(): START DATA STREAM with 16 BIT");
rcv.start16BitDataStream();
}
}
@@ -913,26 +999,38 @@ void RFspaceNetReceiver::TimerProc(uint16_t waitMs)
rcv.poll();
udp.poll();
+ //if (mReportChangedSamplerates) // -> checkReportChangedSamplerates()
+ // EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, extHw_Stop);
+
if(mTime >= mWaitTimeInMilliseconds)
{
rcv.requestReceiverState();
mTime = 0;
if( (mControlPingTime >= mWaitTimeInMilliseconds ) )
- {
- LOG_PRO( LOG_DEBUG, "********* RFspaceNetReceiver::ThreadProc(%u ms/ThreadCycle): HAVEN'T RECEIVED CONTROL HEARTBEAT FOR %d MILLISECONDS ! ", waitMs, mControlPingTime);
- }
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(every %d ms): HAVEN'T RECEIVED CONTROL HEARTBEAT FOR %d MILLISECONDS!", waitMs, mControlPingTime);
else
- LOG_PRO( LOG_DEBUG, "********* RCV_STATE : CONTROL HEARTBEAT IS UP AND RUNNING" );
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(every %d ms): RCV_STATE : CONTROL HEARTBEAT IS UP AND RUNNING", waitMs );
- if( mTimeWithoutDataInMilliseconds >= mUDPWaitTimeInMilliseconds )
+ if (mStartData)
{
- LOG_PRO( LOG_DEBUG, "********* RFspaceNetReceiver::ThreadProc(%u ms/ThreadCycle): HAVEN'T RECEIVED UDP HEARTBEAT FOR %d MILLISECONDS ! ", waitMs, mTimeWithoutDataInMilliseconds);
+ if (mTimeWithoutDataInMilliseconds >= mUDPWaitTimeInMilliseconds)
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(every %d ms): HAVEN'T RECEIVED UDP HEARTBEAT FOR %d MILLISECONDS!", waitMs, mTimeWithoutDataInMilliseconds);
+ else
+ LOG_PRO(LOG_DEBUG, "*** *** RFspaceNetReceiver::TimerProc(every %d ms): UDP DATA IS UP AND RUNNING", waitMs);
}
- else
- LOG_PRO( LOG_DEBUG, "********* RFspaceNetReceiver::ThreadProc(%u ms/ThreadCycle): UDP DATA IS UP AND RUNNING, TIME WITHOUT DATA: %u ms", waitMs, mTimeWithoutDataInMilliseconds);
}
}
+void RFspaceNetReceiver::checkReportChangedSamplerates()
+{
+ if (mReportChangedSamplerates)
+ {
+ EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, extHw_Changed_SRATES);
+ EXTIO_STATUS_CHANGE(mExtIOCallbackPtr, extHw_Changed_SampleRate);
+ mReportChangedSamplerates = false;
+ }
+}
+
diff --git a/src/rfspace_netsdr_receiver.h b/src/rfspace_netsdr_receiver.h
index e10d42e..c797c50 100644
--- a/src/rfspace_netsdr_receiver.h
+++ b/src/rfspace_netsdr_receiver.h
@@ -19,22 +19,20 @@ class RFspaceNetReceiver
static const int EXT_BLOCKLEN = 4096; /* only multiples of 512 */
- static int getDefaultHWType();
-
// zu speichernde Einstellungen
class Settings
{
public:
- Settings()
+ Settings(const char * defaultModel)
{
- strcpy(acCtrlIP, "192.168.8.101"); // "10.10.11.2"
+ strcpy(acModel, defaultModel); // NetSDR / CloudIQ
+ strcpy(acCtrlIP, "192.168.8.100"); // "10.10.11.2"
strcpy(acDataIP, ""); // "" main PC: 192.168.8.100 PC2: 192.168.8.102
uCtrlPortNo = uDataPortNo = 50000; // 50000 / 50002
iSampleRateIdx = 2; // 2: 32 kHz samplerate
+ bUse16BitForAll = false; // => use 24 Bit on low samplerates
iAttenuationIdx = 6; // 6: 0 dB - no ATT & no ADC Gain
- iBitDepthThresSamplerate = 1333333; // 1333.333 kHz == 80 MHz / 60
-
iBand_minFreq = 0;
iBand_maxFreq = 34 * 1000L * 1000L; // 0 - 34 MHz
@@ -55,8 +53,24 @@ class RFspaceNetReceiver
mfGainCompensationFactor = 1.0F;
nConnectTimeoutMillis = 1000;
+
+ if (!strcmp(defaultModel, "NetSDR"))
+ {
+ iSampleRateIdx = 2; // => srate 32 kHz
+ uiSamplerate = RFspaceNetReceiver::netsdr_srate_bws[iSampleRateIdx].srate;
+ uiBandwidth = RFspaceNetReceiver::netsdr_srate_bws[iSampleRateIdx].bw;
+ bUse16BitForAll = false; // => use 24 Bit on low samplerates
+ }
+ else if (!strcmp(defaultModel, "CloudIQ"))
+ {
+ iSampleRateIdx = 4; // => srate 48 kHz
+ uiSamplerate = RFspaceNetReceiver::cloudiq_srate_bws[iSampleRateIdx].srate;
+ uiBandwidth = RFspaceNetReceiver::cloudiq_srate_bws[iSampleRateIdx].bw;
+ bUse16BitForAll = true; // => use 24 Bit on low samplerates
+ }
}
+ char acModel[32];
char acCtrlIP[64];
uint16_t uCtrlPortNo;
@@ -66,10 +80,9 @@ class RFspaceNetReceiver
char acGainControlMode[64];
int iSampleRateIdx;
+ bool bUse16BitForAll;
int iAttenuationIdx;
- int32_t iBitDepthThresSamplerate;
-
int64_t iBand_minFreq;
int64_t iBand_maxFreq;
@@ -95,15 +108,26 @@ class RFspaceNetReceiver
int nConnectTimeoutMillis;
};
- static const struct srate_bw {
- uint32_t decim;
+
+ static bool applyHwModel(const RFspaceNetReceiver::Settings &);
+ static int getDefaultHWType();
+
+ struct srate_bw
+ {
uint32_t srate;
- uint32_t srateval;
uint32_t bw;
+ int maxBitDepth;
const char * srateTxt;
- } srate_bws[];
+ };
+
+ static const int netsdr_default_srateIdx;
+ static const RFspaceNetReceiver::srate_bw netsdr_srate_bws[];
+ static const int cloudiq_default_srateIdx;
+ static const RFspaceNetReceiver::srate_bw cloudiq_srate_bws[];
+ static const struct srate_bw * srate_bws;
- static const int miNumSamplerates;
+ static int miNumSamplerates;
+ static int miDefaultSrateIdx;
static const float mafAttenuationATTs[];
static const float mafActualAttenuationATTs[];
@@ -141,13 +165,15 @@ class RFspaceNetReceiver
int64_t getHWLO( void );
int getAttIdx( void );
int getSmpRateIdx( uint32_t );
- int getMaxSmpRateIdx(uint32_t);
+
const int64_t * getFrequencyRanges( int idx );
int getExtHwSampleFormat() const { return mExtHwSampleFormat; }
int getExtHwBitDepth() const { return mExtHwBitDepth; }
- void TimerProc(uint16_t waitMs);
+ void TimerProc(int waitMs);
+
+ void checkReportChangedSamplerates();
RFspaceNetSDRControl rcv;
RFspaceNetSDRUdpData udp;
@@ -186,18 +212,20 @@ class RFspaceNetReceiver
bool mHasDifferentLOFrequency;
- uint16_t mTime;
- const uint16_t mWaitTimeInMilliseconds = 2000;
- const uint16_t mUDPWaitTimeInMilliseconds = 2000;
- const uint16_t mTimeBufferInMilliseconds = 10;
- uint16_t mTimeWithoutDataInMilliseconds;
- uint16_t mControlPingTime;
+ int mTime;
+ const int mWaitTimeInMilliseconds = 2000;
+ const int mUDPWaitTimeInMilliseconds = 2000;
+ const int mTimeBufferInMilliseconds = 10;
+ int mTimeWithoutDataInMilliseconds;
+ int mControlPingTime;
bool mIsUDPRunning;
uint16_t mNumCallbacks = 0;
bool mHasLostTCPConntection;
bool mHasVUHFFreqRange;
bool mHasOptions;
+ volatile bool mReportChangedSamplerates;
+
int mLastReportedSampleFormat;
unsigned mLastReportedFmt;
@@ -209,8 +237,8 @@ class RFspaceNetReceiver
ReceiverMode mReceiverMode;
GainControlMode mGainControlMode;
- int mNetSdrBitDepth;
+ int mDeviceBitDepth; // 16 / 24
int mExtHwSampleFormat; // HDSDR enum != bit depth
- int mExtHwBitDepth;
+ int mExtHwBitDepth; // 16 / 24 / 32
};