Fix gains and valid SDR error

This commit is contained in:
30hours 2024-05-12 13:44:54 +00:00
parent 3b670a740f
commit a72a89a468
4 changed files with 21 additions and 16 deletions

View file

@ -12,7 +12,7 @@ capture:
replay: replay:
state: false state: false
loop: true loop: true
file: '/opt/blah2/replay/file.hackrf' file: '/opt/blah2/replay/file.kraken'
process: process:
data: data:

View file

@ -8,7 +8,7 @@
#include <httplib.h> #include <httplib.h>
// constants // constants
const std::vector<std::string> Capture::VALID_TYPE = {"RspDuo", "Usrp", "HackRF", "Kraken"}; const std::string Capture::VALID_TYPE[4] = {"RspDuo", "Usrp", "HackRF", "Kraken"};
// constructor // constructor
Capture::Capture(std::string _type, uint32_t _fs, uint32_t _fc, std::string _path) Capture::Capture(std::string _type, uint32_t _fs, uint32_t _fc, std::string _path)
@ -127,17 +127,17 @@ std::unique_ptr<Source> Capture::factory_source(const std::string& type, c4::yml
serial, gainLna, gainVga, ampEnable); serial, gainLna, gainVga, ampEnable);
} }
// Kraken // Kraken
// else if (type == VALID_TYPE[3]) else if (type == VALID_TYPE[3])
// { {
// std::vector<double> gain; std::vector<double> gain;
// float _gain; float _gain;
// for (auto child : config["gain"].children()) for (auto child : config["gain"].children())
// { {
// c4::atof(child.val(), &_gain); c4::atof(child.val(), &_gain);
// gain.push_back(static_cast<double>(_gain)); gain.push_back(static_cast<double>(_gain));
// } }
// return std::make_unique<Kraken>(type, fc, fs, path, &saveIq, gain); return std::make_unique<Kraken>(type, fc, fs, path, &saveIq, gain);
// } }
// handle unknown type // handle unknown type
std::cerr << "Error: Source type does not exist." << std::endl; std::cerr << "Error: Source type does not exist." << std::endl;
return nullptr; return nullptr;

View file

@ -20,7 +20,7 @@ class Capture
{ {
private: private:
/// @brief The valid capture devices. /// @brief The valid capture devices.
static const std::vector<std::string> VALID_TYPE; static const std::string VALID_TYPE[4];
/// @brief The capture device type. /// @brief The capture device type.
std::string type; std::string type;

View file

@ -32,8 +32,13 @@ Kraken::Kraken(std::string _type, uint32_t _fc, uint32_t _fs,
for (int i = 0; i <= _gain.size(); i++) for (int i = 0; i <= _gain.size(); i++)
{ {
int adjustedGain = static_cast<int>(_gain[i] * 10); int adjustedGain = static_cast<int>(_gain[i] * 10);
gain.push_back(std::lower_bound(validGains.begin(), auto it = std::lower_bound(validGains.begin(),
validGains.end(), adjustedGain)); validGains.end(), adjustedGain);
if (it != validGains.end()) {
gain.push_back(*it);
} else {
gain.push_back(validGains.back());
}
std::cout << "[Kraken] Gain update on channel " << i << " from " << std::cout << "[Kraken] Gain update on channel " << i << " from " <<
adjustedGain << " to " << gain[i] << "." << std::endl; adjustedGain << " to " << gain[i] << "." << std::endl;
} }