kopia lustrzana https://github.com/cariboulabs/cariboulite
Merge branch 'main' of https://github.com/cariboulabs/cariboulite
commit
5af8e900e7
|
@ -7,7 +7,7 @@ templates:
|
|||
imports:
|
||||
from gnuradio import caribouLite
|
||||
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:
|
||||
- id: channel
|
||||
|
@ -40,10 +40,17 @@ parameters:
|
|||
dtype: float
|
||||
default: 900000000.0
|
||||
|
||||
- id: provide_meta
|
||||
label: output meta data
|
||||
dtype: enum
|
||||
options: ['True', 'False']
|
||||
hide: part
|
||||
default: 'False'
|
||||
|
||||
cpp_templates:
|
||||
includes: ['#include <gnuradio/caribouLite/caribouLiteSource.h>']
|
||||
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']
|
||||
link: ['gnuradio::gnuradio-caribouLite']
|
||||
translations:
|
||||
|
@ -57,4 +64,9 @@ outputs:
|
|||
domain: stream
|
||||
dtype: complex
|
||||
|
||||
- label: meta
|
||||
domain: stream
|
||||
dtype: byte
|
||||
hide: ${False if str(provide_meta)=='True' else True}
|
||||
|
||||
file_format: 1
|
||||
|
|
|
@ -32,7 +32,13 @@ namespace gr {
|
|||
* class. caribouLite::caribouLiteSource::make is the public interface for
|
||||
* 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
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
namespace gr {
|
||||
namespace caribouLite {
|
||||
using output_type = gr_complex;
|
||||
|
||||
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
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
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::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();
|
||||
|
||||
|
@ -50,10 +68,11 @@ namespace gr {
|
|||
_rx_bw = rx_bw;
|
||||
_sample_rate = sample_rate;
|
||||
_frequency = freq;
|
||||
_provide_meta = provide_meta;
|
||||
|
||||
CaribouLite &cl = CaribouLite::GetInstance(false);
|
||||
_cl = &cl;
|
||||
_radio = cl.GetRadioChannel(_channel);
|
||||
|
||||
_mtu_size = _radio->GetNativeMtuSample();
|
||||
|
||||
// setup parameters
|
||||
|
@ -79,9 +98,14 @@ namespace gr {
|
|||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
auto out = static_cast<output_type*>(output_items[0]);
|
||||
int ret = _radio->ReadSamples(out, static_cast<size_t>(noutput_items));
|
||||
if (ret <= 0) return 0;
|
||||
auto out_samples = static_cast<gr_complex*>(output_items[0]);
|
||||
auto out_meta = _provide_meta == true ? static_cast<uint8_t*>(output_items[1]) : (uint8_t*) NULL ;
|
||||
int ret = _radio->ReadSamples(out_samples, static_cast<size_t>(noutput_items), out_meta);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,20 @@ namespace gr
|
|||
float _sample_rate;
|
||||
float _frequency;
|
||||
size_t _mtu_size;
|
||||
|
||||
bool _provide_meta;
|
||||
|
||||
cariboulite_sample_meta* _metadata;
|
||||
CaribouLite* _cl;
|
||||
CaribouLiteRadio *_radio;
|
||||
|
||||
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();
|
||||
|
||||
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
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
|||
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
||||
/* BINDTOOL_HEADER_FILE(caribouLiteSource.h) */
|
||||
/* BINDTOOL_HEADER_FILE_HASH(9ce2846f2939a8b8e624a4612154ad52) */
|
||||
/* BINDTOOL_HEADER_FILE_HASH(2af106876738c9927aadb177d064272d) */
|
||||
/***********************************************************************************/
|
||||
|
||||
#include <pybind11/complex.h>
|
||||
|
@ -30,30 +30,26 @@ namespace py = pybind11;
|
|||
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,
|
||||
std::shared_ptr<caribouLiteSource>>(m, "caribouLiteSource", D(caribouLiteSource))
|
||||
py::class_<caribouLiteSource,
|
||||
gr::sync_block,
|
||||
gr::block,
|
||||
gr::basic_block,
|
||||
std::shared_ptr<caribouLiteSource>>(
|
||||
m, "caribouLiteSource", D(caribouLiteSource))
|
||||
|
||||
.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
|
||||
*
|
||||
|
@ -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);
|
||||
|
||||
// Synchronous Reading and Writing
|
||||
int ReadSamples(std::complex<float>* samples, size_t num_to_read);
|
||||
int ReadSamples(std::complex<short>* 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, uint8_t* meta = NULL);
|
||||
int WriteSamples(std::complex<float>* 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 <string.h>
|
||||
|
||||
//=================================================================
|
||||
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);
|
||||
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);
|
||||
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)
|
||||
{
|
||||
|
@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
if (meta)
|
||||
{
|
||||
memcpy(meta, _read_metadata, (size_t)ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue