mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-10 04:37:37 +01:00
implemented all user options for harogic devices
This commit is contained in:
parent
bfdfa2b30b
commit
fe9ac6c9a1
@ -11,5 +11,7 @@ if (MSVC)
|
|||||||
target_include_directories(harogic_source PRIVATE "C:/radio/HTRA_API/x64/htra_api/")
|
target_include_directories(harogic_source PRIVATE "C:/radio/HTRA_API/x64/htra_api/")
|
||||||
target_link_libraries(harogic_source PRIVATE htra_api)
|
target_link_libraries(harogic_source PRIVATE htra_api)
|
||||||
else (MSVC)
|
else (MSVC)
|
||||||
# TODO
|
target_link_directories(harogic_source PRIVATE "/opt/htraapi/lib/${CMAKE_SYSTEM_PROCESSOR}/")
|
||||||
|
target_include_directories(harogic_source PRIVATE "/opt/htraapi/inc/")
|
||||||
|
target_link_libraries(harogic_source PRIVATE htraapi)
|
||||||
endif ()
|
endif ()
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
SDRPP_MOD_INFO{
|
SDRPP_MOD_INFO{
|
||||||
/* Name: */ "harogic_source",
|
/* Name: */ "harogic_source",
|
||||||
/* Description: */ "RFNM Source Module",
|
/* Description: */ "harogic Source Module",
|
||||||
/* Author: */ "Ryzerth",
|
/* Author: */ "Ryzerth",
|
||||||
/* Version: */ 0, 1, 0,
|
/* Version: */ 0, 1, 0,
|
||||||
/* Max instances */ -1
|
/* Max instances */ -1
|
||||||
@ -77,14 +77,11 @@ private:
|
|||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
// Attempt to open the device with the given ID
|
// Attempt to open the device with the given ID
|
||||||
int ret = Device_Open(&dev, i, &profile, &binfo);
|
int ret = Device_Open(&dev, i, &profile, &binfo);
|
||||||
if (ret < 0) {
|
if (ret < 0) { break; }
|
||||||
flog::debug("Done searching: {}", ret);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create serial string
|
// Create serial string
|
||||||
char serial[1024];
|
char serial[64];
|
||||||
sprintf(serial, "%016X", binfo.DeviceInfo.DeviceUID);
|
sprintf(serial, "%" PRIX64, binfo.DeviceInfo.DeviceUID);
|
||||||
|
|
||||||
// Add the device to the list
|
// Add the device to the list
|
||||||
devices.define(serial, serial, i);
|
devices.define(serial, serial, i);
|
||||||
@ -140,11 +137,43 @@ private:
|
|||||||
samplerates.define(1 << i, buf, sr);
|
samplerates.define(1 << i, buf, sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define RX ports
|
||||||
|
rxPorts.clear();
|
||||||
|
rxPorts.define("external", "External", ExternalPort);
|
||||||
|
rxPorts.define("internal", "Internal", InternalPort);
|
||||||
|
rxPorts.define("ant", "ANT", ANT_Port);
|
||||||
|
rxPorts.define("tr", "T/R", TR_Port);
|
||||||
|
rxPorts.define("swr", "SWR", SWR_Port);
|
||||||
|
rxPorts.define("int", "INT", INT_Port);
|
||||||
|
|
||||||
|
// Define gain strategies
|
||||||
|
gainStategies.clear();
|
||||||
|
gainStategies.define("lowNoise", "Low Noise", LowNoisePreferred);
|
||||||
|
gainStategies.define("highLinearity", "High Linearity", HighLinearityPreferred);
|
||||||
|
|
||||||
|
// Define preamplifier modes
|
||||||
|
preampModes.clear();
|
||||||
|
preampModes.define("auto", "Auto", AutoOn);
|
||||||
|
preampModes.define("off", "Off", ForcedOff);
|
||||||
|
|
||||||
|
// Define LO modes
|
||||||
|
loModes.clear();
|
||||||
|
loModes.define("auto", "Auto", LOOpt_Auto);
|
||||||
|
loModes.define("speed", "Speed", LOOpt_Speed);
|
||||||
|
loModes.define("spurs", "Spurs", LOOpt_Spur);
|
||||||
|
loModes.define("phaseNoise", "Phase Noise", LOOpt_PhaseNoise);
|
||||||
|
|
||||||
// Close the device
|
// Close the device
|
||||||
Device_Close(&dev);
|
Device_Close(&dev);
|
||||||
|
|
||||||
// TODO: Load configuration
|
// TODO: Load configuration
|
||||||
sampleRate = samplerates.value(0);
|
sampleRate = samplerates.value(0);
|
||||||
|
refLvl = 0;
|
||||||
|
portId = rxPorts.valueId(ExternalPort);
|
||||||
|
gainStratId = gainStategies.valueId(LowNoisePreferred);
|
||||||
|
preampModeId = preampModes.valueId(AutoOn);
|
||||||
|
ifAgc = false;
|
||||||
|
loModeId = loModes.valueId(LOOpt_Auto);
|
||||||
|
|
||||||
// Update the samplerate
|
// Update the samplerate
|
||||||
core::setInputSampleRate(sampleRate);
|
core::setInputSampleRate(sampleRate);
|
||||||
@ -190,17 +219,26 @@ private:
|
|||||||
// Decide to use either 8 or 16bit samples
|
// Decide to use either 8 or 16bit samples
|
||||||
_this->sampsInt8 = (_this->sampleRate > 64e6);
|
_this->sampsInt8 = (_this->sampleRate > 64e6);
|
||||||
|
|
||||||
// Configure the IQ stream
|
// Get the default configuration
|
||||||
IQS_ProfileDeInit(&_this->openDev, &_this->profile);
|
IQS_ProfileDeInit(&_this->openDev, &_this->profile);
|
||||||
_this->profile.CenterFreq_Hz = _this->freq;
|
|
||||||
_this->profile.RefLevel_dBm = -30;
|
// Automatic configuration
|
||||||
_this->profile.DecimateFactor = dec;
|
_this->profile.Atten = -1;
|
||||||
_this->profile.RxPort = ExternalPort;
|
|
||||||
_this->profile.BusTimeout_ms = 100;
|
_this->profile.BusTimeout_ms = 100;
|
||||||
_this->profile.TriggerSource = Bus;
|
_this->profile.TriggerSource = Bus;
|
||||||
_this->profile.TriggerMode = Adaptive;
|
_this->profile.TriggerMode = Adaptive;
|
||||||
_this->profile.DataFormat = _this->sampsInt8 ? Complex8bit : Complex16bit;
|
_this->profile.DataFormat = _this->sampsInt8 ? Complex8bit : Complex16bit;
|
||||||
|
|
||||||
|
// User selectable config
|
||||||
|
_this->profile.CenterFreq_Hz = _this->freq;
|
||||||
|
_this->profile.RefLevel_dBm = _this->refLvl;
|
||||||
|
_this->profile.DecimateFactor = dec;
|
||||||
|
_this->profile.RxPort = _this->rxPorts.value(_this->portId);
|
||||||
|
_this->profile.GainStrategy = _this->gainStategies.value(_this->gainStratId);
|
||||||
|
_this->profile.Preamplifier = _this->preampModes.value(_this->preampModeId);
|
||||||
|
_this->profile.EnableIFAGC = _this->ifAgc;
|
||||||
|
_this->profile.LOOptimization = _this->loModes.value(_this->loModeId);
|
||||||
|
|
||||||
// Apply the configuration
|
// Apply the configuration
|
||||||
IQS_StreamInfo_TypeDef info;
|
IQS_StreamInfo_TypeDef info;
|
||||||
ret = IQS_Configuration(&_this->openDev, &_this->profile, &_this->profile, &info);
|
ret = IQS_Configuration(&_this->openDev, &_this->profile, &_this->profile, &info);
|
||||||
@ -253,25 +291,9 @@ private:
|
|||||||
static void tune(double freq, void* ctx) {
|
static void tune(double freq, void* ctx) {
|
||||||
HarogicSourceModule* _this = (HarogicSourceModule*)ctx;
|
HarogicSourceModule* _this = (HarogicSourceModule*)ctx;
|
||||||
if (_this->running) {
|
if (_this->running) {
|
||||||
// Acquire device
|
|
||||||
std::lock_guard<std::mutex> lck(_this->devMtx);
|
|
||||||
|
|
||||||
// Update the frequency in the configuration
|
// Update the frequency in the configuration
|
||||||
_this->profile.CenterFreq_Hz = freq;
|
_this->profile.CenterFreq_Hz = freq;
|
||||||
|
_this->applyProfile();
|
||||||
// Configure the device
|
|
||||||
IQS_StreamInfo_TypeDef info;
|
|
||||||
int ret = IQS_Configuration(&_this->openDev, &_this->profile, &_this->profile, &info);
|
|
||||||
if (ret < 0) {
|
|
||||||
flog::error("Failed to apply tuning config: {}", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Re-trigger the stream
|
|
||||||
ret = IQS_BusTriggerStart(&_this->openDev);
|
|
||||||
if (ret < 0) {
|
|
||||||
flog::error("Could not start stream: {}", ret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_this->freq = freq;
|
_this->freq = freq;
|
||||||
flog::info("HarogicSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
flog::info("HarogicSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
||||||
@ -284,13 +306,13 @@ private:
|
|||||||
|
|
||||||
SmGui::FillWidth();
|
SmGui::FillWidth();
|
||||||
SmGui::ForceSync();
|
SmGui::ForceSync();
|
||||||
if (SmGui::Combo(CONCAT("##_rfnm_dev_sel_", _this->name), &_this->devId, _this->devices.txt)) {
|
if (SmGui::Combo(CONCAT("##_harogic_dev_sel_", _this->name), &_this->devId, _this->devices.txt)) {
|
||||||
_this->select(_this->devices.key(_this->devId));
|
_this->select(_this->devices.key(_this->devId));
|
||||||
core::setInputSampleRate(_this->sampleRate);
|
core::setInputSampleRate(_this->sampleRate);
|
||||||
// TODO: Save
|
// TODO: Save
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SmGui::Combo(CONCAT("##_rfnm_sr_sel_", _this->name), &_this->srId, _this->samplerates.txt)) {
|
if (SmGui::Combo(CONCAT("##_harogic_sr_sel_", _this->name), &_this->srId, _this->samplerates.txt)) {
|
||||||
_this->sampleRate = _this->samplerates.value(_this->srId);
|
_this->sampleRate = _this->samplerates.value(_this->srId);
|
||||||
core::setInputSampleRate(_this->sampleRate);
|
core::setInputSampleRate(_this->sampleRate);
|
||||||
// TODO: Save
|
// TODO: Save
|
||||||
@ -299,13 +321,89 @@ private:
|
|||||||
SmGui::SameLine();
|
SmGui::SameLine();
|
||||||
SmGui::FillWidth();
|
SmGui::FillWidth();
|
||||||
SmGui::ForceSync();
|
SmGui::ForceSync();
|
||||||
if (SmGui::Button(CONCAT("Refresh##_rfnm_refr_", _this->name))) {
|
if (SmGui::Button(CONCAT("Refresh##_harogic_refr_", _this->name))) {
|
||||||
_this->refresh();
|
_this->refresh();
|
||||||
_this->select(_this->selectedSerial);
|
_this->select(_this->selectedSerial);
|
||||||
core::setInputSampleRate(_this->sampleRate);
|
core::setInputSampleRate(_this->sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this->running) { SmGui::EndDisabled(); }
|
if (_this->running) { SmGui::EndDisabled(); }
|
||||||
|
|
||||||
|
SmGui::LeftLabel("RX Port");
|
||||||
|
SmGui::FillWidth();
|
||||||
|
if (SmGui::Combo(CONCAT("##_harogic_port_", _this->name), &_this->portId, _this->rxPorts.txt)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.RxPort = _this->rxPorts.value(_this->portId);
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
|
||||||
|
SmGui::LeftLabel("LO Mode");
|
||||||
|
SmGui::FillWidth();
|
||||||
|
if (SmGui::Combo(CONCAT("##_lo_mode_", _this->name), &_this->loModeId, _this->loModes.txt)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.LOOptimization = _this->loModes.value(_this->loModeId);
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
|
||||||
|
SmGui::LeftLabel("Gain Mode");
|
||||||
|
SmGui::FillWidth();
|
||||||
|
if (SmGui::Combo(CONCAT("##_harogic_gain_mode_", _this->name), &_this->gainStratId, _this->gainStategies.txt)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.GainStrategy = _this->gainStategies.value(_this->gainStratId);
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
|
||||||
|
SmGui::LeftLabel("Preamp Mode");
|
||||||
|
SmGui::FillWidth();
|
||||||
|
if (SmGui::Combo(CONCAT("##_harogic_preamp_mode_", _this->name), &_this->preampModeId, _this->preampModes.txt)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.Preamplifier = _this->preampModes.value(_this->preampModeId);
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
|
||||||
|
SmGui::LeftLabel("Reference");
|
||||||
|
SmGui::FillWidth();
|
||||||
|
if (SmGui::SliderInt(CONCAT("##_harogic_ref_", _this->name), &_this->refLvl, _this->minRef, _this->maxRef)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.RefLevel_dBm = _this->refLvl;
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SmGui::Checkbox(CONCAT("IF AGC##_harogic_if_agc_", _this->name), &_this->ifAgc)) {
|
||||||
|
if (_this->running) {
|
||||||
|
_this->profile.EnableIFAGC = _this->ifAgc;
|
||||||
|
_this->applyProfile();
|
||||||
|
}
|
||||||
|
// TODO: Save
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyProfile() {
|
||||||
|
// Acquire device
|
||||||
|
std::lock_guard<std::mutex> lck(devMtx);
|
||||||
|
|
||||||
|
// Configure the device
|
||||||
|
IQS_StreamInfo_TypeDef info;
|
||||||
|
int ret = IQS_Configuration(&openDev, &profile, &profile, &info);
|
||||||
|
if (ret < 0) {
|
||||||
|
flog::error("Failed to apply tuning config: {}", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-trigger the stream
|
||||||
|
ret = IQS_BusTriggerStart(&openDev);
|
||||||
|
if (ret < 0) {
|
||||||
|
flog::error("Could not start stream: {}", ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void worker() {
|
void worker() {
|
||||||
@ -368,8 +466,20 @@ private:
|
|||||||
|
|
||||||
OptionList<std::string, int> devices;
|
OptionList<std::string, int> devices;
|
||||||
OptionList<int, double> samplerates;
|
OptionList<int, double> samplerates;
|
||||||
|
OptionList<std::string, RxPort_TypeDef> rxPorts;
|
||||||
|
OptionList<std::string, GainStrategy_TypeDef> gainStategies;
|
||||||
|
OptionList<std::string, PreamplifierState_TypeDef> preampModes;
|
||||||
|
OptionList<std::string, LOOptimization_TypeDef> loModes;
|
||||||
int devId = 0;
|
int devId = 0;
|
||||||
int srId = 0;
|
int srId = 0;
|
||||||
|
int refLvl = -30;
|
||||||
|
int minRef = -100;
|
||||||
|
int maxRef = 7;
|
||||||
|
int portId = 0;
|
||||||
|
int gainStratId = 0;
|
||||||
|
int preampModeId = 0;
|
||||||
|
int loModeId = 0;
|
||||||
|
bool ifAgc = false;
|
||||||
std::string selectedSerial;
|
std::string selectedSerial;
|
||||||
int selectedDevIndex;
|
int selectedDevIndex;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user