kopia lustrzana https://github.com/cariboulabs/cariboulite
Merge commit 'b777fb276c9b2cdfe43b1260945753b1602f42d2'
commit
ded5339fe6
|
@ -7,7 +7,7 @@ templates:
|
||||||
imports:
|
imports:
|
||||||
from gnuradio import caribouLite
|
from gnuradio import caribouLite
|
||||||
make:
|
make:
|
||||||
caribouLite.caribouLiteSource(${channel}, ${enable_agc}, ${rx_gain}, ${rx_bw}, ${sample_rate}, ${freq})
|
caribouLite.caribouLiteSource(${channel}, ${enable_agc}, ${rx_gain}, ${rx_bw}, ${sample_rate}, ${freq}, ${provide_meta})
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- id: channel
|
- id: channel
|
||||||
|
@ -40,10 +40,17 @@ parameters:
|
||||||
dtype: float
|
dtype: float
|
||||||
default: 900000000.0
|
default: 900000000.0
|
||||||
|
|
||||||
|
- id: provide_meta
|
||||||
|
label: output meta data
|
||||||
|
dtype: enum
|
||||||
|
options: ['True', 'False']
|
||||||
|
hide: part
|
||||||
|
default: 'False'
|
||||||
|
|
||||||
cpp_templates:
|
cpp_templates:
|
||||||
includes: ['#include <gnuradio/caribouLite/caribouLiteSource.h>']
|
includes: ['#include <gnuradio/caribouLite/caribouLiteSource.h>']
|
||||||
declarations: 'caribouLite::caribouLiteSource::sptr ${id};'
|
declarations: 'caribouLite::caribouLiteSource::sptr ${id};'
|
||||||
make: 'this->${id} = caribouLite::caribouLiteSource::make(${channel}, ${enable_agc}, ${rx_gain}, ${rx_bw}, ${sample_rate}, ${freq});'
|
make: 'this->${id} = caribouLite::caribouLiteSource::make(${channel}, ${enable_agc}, ${rx_gain}, ${rx_bw}, ${sample_rate}, ${freq}, ${provide_meta});'
|
||||||
packages: ['gnuradio-caribouLite']
|
packages: ['gnuradio-caribouLite']
|
||||||
link: ['gnuradio::gnuradio-caribouLite']
|
link: ['gnuradio::gnuradio-caribouLite']
|
||||||
translations:
|
translations:
|
||||||
|
@ -57,4 +64,9 @@ outputs:
|
||||||
domain: stream
|
domain: stream
|
||||||
dtype: complex
|
dtype: complex
|
||||||
|
|
||||||
|
- label: meta
|
||||||
|
domain: stream
|
||||||
|
dtype: byte
|
||||||
|
hide: ${False if str(provide_meta)=='True' else True}
|
||||||
|
|
||||||
file_format: 1
|
file_format: 1
|
||||||
|
|
|
@ -32,7 +32,13 @@ namespace gr {
|
||||||
* class. caribouLite::caribouLiteSource::make is the public interface for
|
* class. caribouLite::caribouLiteSource::make is the public interface for
|
||||||
* creating new instances.
|
* creating new instances.
|
||||||
*/
|
*/
|
||||||
static sptr make(int channel=0, bool enable_agc=false, float rx_gain=40, float rx_bw=2500000, float sample_rate=4000000, float freq=900000000);
|
static sptr make(int channel=0,
|
||||||
|
bool enable_agc=false,
|
||||||
|
float rx_gain=40,
|
||||||
|
float rx_bw=2500000,
|
||||||
|
float sample_rate=4000000,
|
||||||
|
float freq=900000000,
|
||||||
|
bool provide_meta = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace caribouLite
|
} // namespace caribouLite
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
namespace gr {
|
namespace gr {
|
||||||
namespace caribouLite {
|
namespace caribouLite {
|
||||||
using output_type = gr_complex;
|
|
||||||
|
|
||||||
void detectBoard()
|
void detectBoard()
|
||||||
{
|
{
|
||||||
|
@ -29,18 +28,37 @@ namespace gr {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------
|
||||||
caribouLiteSource::sptr caribouLiteSource::make(int channel, bool enable_agc, float rx_gain, float rx_bw, float sample_rate, float freq)
|
caribouLiteSource::sptr caribouLiteSource::make(int channel,
|
||||||
|
bool enable_agc,
|
||||||
|
float rx_gain,
|
||||||
|
float rx_bw,
|
||||||
|
float sample_rate,
|
||||||
|
float freq,
|
||||||
|
bool provide_meta)
|
||||||
{
|
{
|
||||||
return gnuradio::make_block_sptr<caribouLiteSource_impl>(channel, enable_agc, rx_gain, rx_bw, sample_rate, freq);
|
return gnuradio::make_block_sptr<caribouLiteSource_impl>(channel,
|
||||||
|
enable_agc,
|
||||||
|
rx_gain,
|
||||||
|
rx_bw,
|
||||||
|
sample_rate,
|
||||||
|
freq,
|
||||||
|
provide_meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public constructor
|
// public constructor
|
||||||
//-------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------
|
||||||
caribouLiteSource_impl::caribouLiteSource_impl(int channel, bool enable_agc, float rx_gain, float rx_bw, float sample_rate, float freq)
|
caribouLiteSource_impl::caribouLiteSource_impl(int channel,
|
||||||
|
bool enable_agc,
|
||||||
|
float rx_gain,
|
||||||
|
float rx_bw,
|
||||||
|
float sample_rate,
|
||||||
|
float freq,
|
||||||
|
bool provide_meta)
|
||||||
: gr::sync_block("caribouLiteSource",
|
: gr::sync_block("caribouLiteSource",
|
||||||
gr::io_signature::make(0, 0, 0),
|
gr::io_signature::make(0, 0, 0),
|
||||||
gr::io_signature::make(1 /* min outputs */, 1 /*max outputs */, sizeof(output_type)))
|
gr::io_signature::make(1, 2, {sizeof(gr_complex), sizeof(uint8_t)})
|
||||||
|
)
|
||||||
{
|
{
|
||||||
detectBoard();
|
detectBoard();
|
||||||
|
|
||||||
|
@ -50,10 +68,11 @@ namespace gr {
|
||||||
_rx_bw = rx_bw;
|
_rx_bw = rx_bw;
|
||||||
_sample_rate = sample_rate;
|
_sample_rate = sample_rate;
|
||||||
_frequency = freq;
|
_frequency = freq;
|
||||||
|
_provide_meta = provide_meta;
|
||||||
|
|
||||||
CaribouLite &cl = CaribouLite::GetInstance(false);
|
CaribouLite &cl = CaribouLite::GetInstance(false);
|
||||||
_cl = &cl;
|
_cl = &cl;
|
||||||
_radio = cl.GetRadioChannel(_channel);
|
_radio = cl.GetRadioChannel(_channel);
|
||||||
|
|
||||||
_mtu_size = _radio->GetNativeMtuSample();
|
_mtu_size = _radio->GetNativeMtuSample();
|
||||||
|
|
||||||
// setup parameters
|
// setup parameters
|
||||||
|
@ -79,9 +98,14 @@ namespace gr {
|
||||||
gr_vector_const_void_star &input_items,
|
gr_vector_const_void_star &input_items,
|
||||||
gr_vector_void_star &output_items)
|
gr_vector_void_star &output_items)
|
||||||
{
|
{
|
||||||
auto out = static_cast<output_type*>(output_items[0]);
|
auto out_samples = static_cast<gr_complex*>(output_items[0]);
|
||||||
int ret = _radio->ReadSamples(out, static_cast<size_t>(noutput_items));
|
auto out_meta = _provide_meta == true ? static_cast<uint8_t*>(output_items[1]) : (uint8_t*) NULL ;
|
||||||
if (ret <= 0) return 0;
|
int ret = _radio->ReadSamples(out_samples, static_cast<size_t>(noutput_items), out_meta);
|
||||||
|
|
||||||
|
if (ret <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,20 @@ namespace gr
|
||||||
float _sample_rate;
|
float _sample_rate;
|
||||||
float _frequency;
|
float _frequency;
|
||||||
size_t _mtu_size;
|
size_t _mtu_size;
|
||||||
|
bool _provide_meta;
|
||||||
|
|
||||||
|
cariboulite_sample_meta* _metadata;
|
||||||
CaribouLite* _cl;
|
CaribouLite* _cl;
|
||||||
CaribouLiteRadio *_radio;
|
CaribouLiteRadio *_radio;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
caribouLiteSource_impl(int channel, bool enable_agc, float rx_gain, float rx_bw, float sample_rate, float freq);
|
caribouLiteSource_impl(int channel,
|
||||||
|
bool enable_agc,
|
||||||
|
float rx_gain,
|
||||||
|
float rx_bw,
|
||||||
|
float sample_rate,
|
||||||
|
float freq,
|
||||||
|
bool provide_meta);
|
||||||
~caribouLiteSource_impl();
|
~caribouLiteSource_impl();
|
||||||
|
|
||||||
int work(
|
int work(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2023 Free Software Foundation, Inc.
|
* Copyright 2024 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GNU Radio
|
* This file is part of GNU Radio
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
||||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
/* BINDTOOL_USE_PYGCCXML(0) */
|
||||||
/* BINDTOOL_HEADER_FILE(caribouLiteSource.h) */
|
/* BINDTOOL_HEADER_FILE(caribouLiteSource.h) */
|
||||||
/* BINDTOOL_HEADER_FILE_HASH(9ce2846f2939a8b8e624a4612154ad52) */
|
/* BINDTOOL_HEADER_FILE_HASH(2af106876738c9927aadb177d064272d) */
|
||||||
/***********************************************************************************/
|
/***********************************************************************************/
|
||||||
|
|
||||||
#include <pybind11/complex.h>
|
#include <pybind11/complex.h>
|
||||||
|
@ -30,30 +30,26 @@ namespace py = pybind11;
|
||||||
void bind_caribouLiteSource(py::module& m)
|
void bind_caribouLiteSource(py::module& m)
|
||||||
{
|
{
|
||||||
|
|
||||||
using caribouLiteSource = gr::caribouLite::caribouLiteSource;
|
using caribouLiteSource = ::gr::caribouLite::caribouLiteSource;
|
||||||
|
|
||||||
|
|
||||||
py::class_<caribouLiteSource, gr::sync_block, gr::block, gr::basic_block,
|
py::class_<caribouLiteSource,
|
||||||
std::shared_ptr<caribouLiteSource>>(m, "caribouLiteSource", D(caribouLiteSource))
|
gr::sync_block,
|
||||||
|
gr::block,
|
||||||
|
gr::basic_block,
|
||||||
|
std::shared_ptr<caribouLiteSource>>(
|
||||||
|
m, "caribouLiteSource", D(caribouLiteSource))
|
||||||
|
|
||||||
.def(py::init(&caribouLiteSource::make),
|
.def(py::init(&caribouLiteSource::make),
|
||||||
D(caribouLiteSource,make)
|
py::arg("channel") = 0,
|
||||||
)
|
py::arg("enable_agc") = false,
|
||||||
|
py::arg("rx_gain") = 40,
|
||||||
|
py::arg("rx_bw") = 2500000,
|
||||||
|
py::arg("sample_rate") = 4000000,
|
||||||
|
py::arg("freq") = 900000000,
|
||||||
|
py::arg("provide_meta") = false,
|
||||||
|
D(caribouLiteSource, make))
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2023 Free Software Foundation, Inc.
|
* Copyright 2024 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GNU Radio
|
* This file is part of GNU Radio
|
||||||
*
|
*
|
||||||
|
@ -15,13 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static const char* __doc_gr_caribouLite_caribouLiteSource = R"doc()doc";
|
||||||
static const char *__doc_gr_caribouLite_caribouLiteSource = R"doc()doc";
|
|
||||||
|
|
||||||
|
|
||||||
static const char *__doc_gr_caribouLite_caribouLiteSource_caribouLiteSource = R"doc()doc";
|
static const char* __doc_gr_caribouLite_caribouLiteSource_caribouLiteSource = R"doc()doc";
|
||||||
|
|
||||||
|
|
||||||
static const char *__doc_gr_caribouLite_caribouLiteSource_make = R"doc()doc";
|
static const char* __doc_gr_caribouLite_caribouLiteSource_make = R"doc()doc";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -183,8 +183,8 @@ public:
|
||||||
bool GetIsTransmittingCw(void);
|
bool GetIsTransmittingCw(void);
|
||||||
|
|
||||||
// Synchronous Reading and Writing
|
// Synchronous Reading and Writing
|
||||||
int ReadSamples(std::complex<float>* samples, size_t num_to_read);
|
int ReadSamples(std::complex<float>* samples, size_t num_to_read, uint8_t* meta = NULL);
|
||||||
int ReadSamples(std::complex<short>* samples, size_t num_to_read);
|
int ReadSamples(std::complex<short>* samples, size_t num_to_read, uint8_t* meta = NULL);
|
||||||
int WriteSamples(std::complex<float>* samples, size_t num_to_write);
|
int WriteSamples(std::complex<float>* samples, size_t num_to_write);
|
||||||
int WriteSamples(std::complex<short>* samples, size_t num_to_write);
|
int WriteSamples(std::complex<short>* samples, size_t num_to_write);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CaribouLite.hpp"
|
#include "CaribouLite.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
//=================================================================
|
//=================================================================
|
||||||
void CaribouLiteRadio::CaribouLiteRxThread(CaribouLiteRadio* radio)
|
void CaribouLiteRadio::CaribouLiteRxThread(CaribouLiteRadio* radio)
|
||||||
|
@ -68,15 +69,15 @@ void CaribouLiteRadio::CaribouLiteRxThread(CaribouLiteRadio* radio)
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
int CaribouLiteRadio::ReadSamples(std::complex<float>* samples, size_t num_to_read)
|
int CaribouLiteRadio::ReadSamples(std::complex<float>* samples, size_t num_to_read, uint8_t* meta)
|
||||||
{
|
{
|
||||||
if (samples == 0)
|
if (samples == NULL)
|
||||||
{
|
{
|
||||||
printf("samples_is_null=%d", _read_samples==NULL);
|
printf("samples_is_null=%d", _read_samples==NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = ReadSamples((std::complex<short>*)NULL, num_to_read);
|
int ret = ReadSamples((std::complex<short>*)NULL, num_to_read, meta);
|
||||||
//printf("ret = %d\n", ret);
|
//printf("ret = %d\n", ret);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +95,7 @@ int CaribouLiteRadio::ReadSamples(std::complex<float>* samples, size_t num_to_re
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
int CaribouLiteRadio::ReadSamples(std::complex<short>* samples, size_t num_to_read)
|
int CaribouLiteRadio::ReadSamples(std::complex<short>* samples, size_t num_to_read, uint8_t* meta)
|
||||||
{
|
{
|
||||||
if (!_rx_is_active || _read_samples == NULL || _read_metadata == NULL || num_to_read == 0)
|
if (!_rx_is_active || _read_samples == NULL || _read_metadata == NULL || num_to_read == 0)
|
||||||
{
|
{
|
||||||
|
@ -119,6 +120,11 @@ int CaribouLiteRadio::ReadSamples(std::complex<short>* samples, size_t num_to_re
|
||||||
samples[i] = {_read_samples[i].i, _read_samples[i].q};
|
samples[i] = {_read_samples[i].i, _read_samples[i].q};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (meta)
|
||||||
|
{
|
||||||
|
memcpy(meta, _read_metadata, (size_t)ret);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue