mirror of
https://github.com/30hours/blah2.git
synced 2024-11-08 12:25:42 +00:00
commit
7ecdb17423
2 changed files with 22 additions and 20 deletions
|
@ -11,7 +11,7 @@ Kraken::Kraken(std::string _type, uint32_t _fc, uint32_t _fs,
|
||||||
: Source(_type, _fc, _fs, _path, _saveIq)
|
: Source(_type, _fc, _fs, _path, _saveIq)
|
||||||
{
|
{
|
||||||
// convert gain to tenths of dB
|
// convert gain to tenths of dB
|
||||||
for (int i = 0; i <= _gain.size(); i++)
|
for (int i = 0; i < _gain.size(); i++)
|
||||||
{
|
{
|
||||||
gain.push_back(static_cast<int>(_gain[i]*10));
|
gain.push_back(static_cast<int>(_gain[i]*10));
|
||||||
channelIndex.push_back(i);
|
channelIndex.push_back(i);
|
||||||
|
@ -33,7 +33,7 @@ Kraken::Kraken(std::string _type, uint32_t _fc, uint32_t _fs,
|
||||||
check_status(status, "Failed to close device for available gains.");
|
check_status(status, "Failed to close device for available gains.");
|
||||||
|
|
||||||
// update gains to next value if invalid
|
// update gains to next value if invalid
|
||||||
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);
|
||||||
auto it = std::lower_bound(validGains.begin(),
|
auto it = std::lower_bound(validGains.begin(),
|
||||||
|
@ -54,10 +54,10 @@ void Kraken::start()
|
||||||
for (size_t i = 0; i < channelIndex.size(); i++)
|
for (size_t i = 0; i < channelIndex.size(); i++)
|
||||||
{
|
{
|
||||||
std::cout << "[Kraken] Setting up channel " << i << "." << std::endl;
|
std::cout << "[Kraken] Setting up channel " << i << "." << std::endl;
|
||||||
rtlsdr_dev_t* dev;
|
|
||||||
status = rtlsdr_open(&dev, i);
|
status = rtlsdr_open(&devs[i], i);
|
||||||
check_status(status, "Failed to open device.");
|
check_status(status, "Failed to open device.");
|
||||||
devs.push_back(dev);
|
|
||||||
status = rtlsdr_set_center_freq(devs[i], fc);
|
status = rtlsdr_set_center_freq(devs[i], fc);
|
||||||
check_status(status, "Failed to set center frequency.");
|
check_status(status, "Failed to set center frequency.");
|
||||||
status = rtlsdr_set_sample_rate(devs[i], fs);
|
status = rtlsdr_set_sample_rate(devs[i], fs);
|
||||||
|
@ -86,11 +86,8 @@ void Kraken::stop()
|
||||||
void Kraken::process(IqData *buffer1, IqData *buffer2)
|
void Kraken::process(IqData *buffer1, IqData *buffer2)
|
||||||
{
|
{
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
for (size_t i = 0; i < channelIndex.size(); i++)
|
threads.emplace_back(rtlsdr_read_async, devs[0], callback, buffer1, 0, 16 * 16384);
|
||||||
{
|
threads.emplace_back(rtlsdr_read_async, devs[1], callback, buffer2, 0, 16 * 16384);
|
||||||
threads.emplace_back(rtlsdr_read_async, devs[i], callback, &channelIndex, 0, 16 * 16384);
|
|
||||||
}
|
|
||||||
|
|
||||||
// join threads
|
// join threads
|
||||||
for (auto& thread : threads) {
|
for (auto& thread : threads) {
|
||||||
thread.join();
|
thread.join();
|
||||||
|
@ -99,13 +96,19 @@ void Kraken::process(IqData *buffer1, IqData *buffer2)
|
||||||
|
|
||||||
void Kraken::callback(unsigned char *buf, uint32_t len, void *ctx)
|
void Kraken::callback(unsigned char *buf, uint32_t len, void *ctx)
|
||||||
{
|
{
|
||||||
int deviceIndex = *reinterpret_cast<int*>(ctx);
|
IqData* buffer_blah2 = (IqData*)ctx;
|
||||||
// buffers[i]->lock();
|
int8_t* buffer_kraken = (int8_t*)buf;
|
||||||
// for (size_t j = 0; j < n_read; j++)
|
|
||||||
// {
|
buffer_blah2->lock();
|
||||||
// buffers[i]->push_back({buffer[j].real(), buffer[j].imag()});
|
|
||||||
// }
|
for (size_t i = 0; i < len; i += 2) {
|
||||||
// buffers[i]->unlock();
|
double iqi = static_cast<double>(buffer_kraken[i]);
|
||||||
|
double iqq = static_cast<double>(buffer_kraken[i + 1]);
|
||||||
|
|
||||||
|
buffer_blah2->push_back({iqi, iqq});
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_blah2->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kraken::replay(IqData *buffer1, IqData *buffer2, std::string _file, bool _loop)
|
void Kraken::replay(IqData *buffer1, IqData *buffer2, std::string _file, bool _loop)
|
||||||
|
@ -120,4 +123,3 @@ void Kraken::check_status(int status, std::string message)
|
||||||
throw std::runtime_error("[Kraken] " + message);
|
throw std::runtime_error("[Kraken] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/// The original steve-m/librtlsdr does not include this method.
|
/// The original steve-m/librtlsdr does not include this method.
|
||||||
/// This is included in librtlsdr/librtlsdr or krakenrf/librtlsdr.
|
/// This is included in librtlsdr/librtlsdr or krakenrf/librtlsdr.
|
||||||
/// Also works using 2 RTL-SDRs which have been clock synchronised.
|
/// Also works using 2 RTL-SDRs which have been clock synchronised.
|
||||||
/// @author 30hours, Michael Brock
|
/// @author 30hours, Michael Brock, sdn-ninja
|
||||||
/// @todo Add support for multiple surveillance channels.
|
/// @todo Add support for multiple surveillance channels.
|
||||||
/// @todo Replay support.
|
/// @todo Replay support.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Kraken : public Source
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// @brief Individual RTL-SDR devices.
|
/// @brief Individual RTL-SDR devices.
|
||||||
std::vector<rtlsdr_dev_t*> devs;
|
rtlsdr_dev_t* devs[5];
|
||||||
|
|
||||||
/// @brief Device indices for Kraken.
|
/// @brief Device indices for Kraken.
|
||||||
std::vector<int> channelIndex;
|
std::vector<int> channelIndex;
|
||||||
|
|
Loading…
Reference in a new issue