kopia lustrzana https://github.com/cariboulabs/cariboulite
removed new/delete and made backwards compatible
rodzic
d4cd0f4032
commit
cda5be1b0e
|
@ -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}, ${provide_sync})
|
caribouLite.caribouLiteSource(${channel}, ${enable_agc}, ${rx_gain}, ${rx_bw}, ${sample_rate}, ${freq}, ${provide_meta})
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- id: channel
|
- id: channel
|
||||||
|
@ -40,7 +40,7 @@ parameters:
|
||||||
dtype: float
|
dtype: float
|
||||||
default: 900000000.0
|
default: 900000000.0
|
||||||
|
|
||||||
- id: provide_sync
|
- id: provide_meta
|
||||||
dtype: enum
|
dtype: enum
|
||||||
options: ['True', 'False']
|
options: ['True', 'False']
|
||||||
hide: part
|
hide: part
|
||||||
|
@ -49,7 +49,7 @@ parameters:
|
||||||
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}, ${provide_sync});'
|
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:
|
||||||
|
@ -66,6 +66,6 @@ outputs:
|
||||||
- label: sync
|
- label: sync
|
||||||
domain: stream
|
domain: stream
|
||||||
dtype: byte
|
dtype: byte
|
||||||
hide: ${False if str(provide_sync)=='True' else True}
|
hide: ${False if str(provide_meta)=='True' else True}
|
||||||
|
|
||||||
file_format: 1
|
file_format: 1
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace gr {
|
||||||
float rx_bw=2500000,
|
float rx_bw=2500000,
|
||||||
float sample_rate=4000000,
|
float sample_rate=4000000,
|
||||||
float freq=900000000,
|
float freq=900000000,
|
||||||
bool provide_sync = false);
|
bool provide_meta = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace caribouLite
|
} // namespace caribouLite
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace gr {
|
||||||
float rx_bw,
|
float rx_bw,
|
||||||
float sample_rate,
|
float sample_rate,
|
||||||
float freq,
|
float freq,
|
||||||
bool provide_sync)
|
bool provide_meta)
|
||||||
{
|
{
|
||||||
return gnuradio::make_block_sptr<caribouLiteSource_impl>(channel,
|
return gnuradio::make_block_sptr<caribouLiteSource_impl>(channel,
|
||||||
enable_agc,
|
enable_agc,
|
||||||
|
@ -42,7 +42,7 @@ namespace gr {
|
||||||
rx_bw,
|
rx_bw,
|
||||||
sample_rate,
|
sample_rate,
|
||||||
freq,
|
freq,
|
||||||
provide_sync);
|
provide_meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ namespace gr {
|
||||||
float rx_bw,
|
float rx_bw,
|
||||||
float sample_rate,
|
float sample_rate,
|
||||||
float freq,
|
float freq,
|
||||||
bool provide_sync)
|
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(gr_complex)))
|
gr::io_signature::make(1 /* min outputs */, 2 /*max outputs */, sizeof(gr_complex)))
|
||||||
{
|
{
|
||||||
detectBoard();
|
detectBoard();
|
||||||
|
|
||||||
|
@ -67,12 +67,12 @@ namespace gr {
|
||||||
_rx_bw = rx_bw;
|
_rx_bw = rx_bw;
|
||||||
_sample_rate = sample_rate;
|
_sample_rate = sample_rate;
|
||||||
_frequency = freq;
|
_frequency = freq;
|
||||||
_mtu_size = _radio->GetNativeMtuSample();
|
_provide_meta = provide_meta;
|
||||||
_provide_sync = provide_sync;
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
// setup parameters
|
// setup parameters
|
||||||
_radio->SetRxGain(rx_gain);
|
_radio->SetRxGain(rx_gain);
|
||||||
|
@ -98,23 +98,12 @@ namespace gr {
|
||||||
gr_vector_void_star &output_items)
|
gr_vector_void_star &output_items)
|
||||||
{
|
{
|
||||||
auto out_samples = static_cast<gr_complex*>(output_items[0]);
|
auto out_samples = static_cast<gr_complex*>(output_items[0]);
|
||||||
auto out_sync = static_cast<uint8_t*>(output_items[1]);
|
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);
|
||||||
|
|
||||||
_metadata = new cariboulite_sample_meta[noutput_items];
|
if (ret <= 0)
|
||||||
int ret = _radio->ReadSamples(out_samples, _metadata, static_cast<size_t>(noutput_items));
|
{
|
||||||
|
|
||||||
if (ret <= 0) { //fail
|
|
||||||
delete[] _metadata;
|
|
||||||
return 0;
|
return 0;
|
||||||
} else { //success
|
|
||||||
if (_provide_sync)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ret; i++)
|
|
||||||
{
|
|
||||||
out_sync[i] = _metadata[i].sync;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete[] _metadata;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace gr
|
||||||
float _sample_rate;
|
float _sample_rate;
|
||||||
float _frequency;
|
float _frequency;
|
||||||
size_t _mtu_size;
|
size_t _mtu_size;
|
||||||
bool _provide_sync;
|
bool _provide_meta;
|
||||||
|
|
||||||
cariboulite_sample_meta* _metadata;
|
cariboulite_sample_meta* _metadata;
|
||||||
CaribouLite* _cl;
|
CaribouLite* _cl;
|
||||||
|
@ -40,7 +40,7 @@ namespace gr
|
||||||
float rx_bw,
|
float rx_bw,
|
||||||
float sample_rate,
|
float sample_rate,
|
||||||
float freq,
|
float freq,
|
||||||
bool provide_sync);
|
bool provide_meta);
|
||||||
~caribouLiteSource_impl();
|
~caribouLiteSource_impl();
|
||||||
|
|
||||||
int work(
|
int work(
|
||||||
|
|
|
@ -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(9aa68c862233e30766b0524aaf530760) */
|
/* BINDTOOL_HEADER_FILE_HASH(2af106876738c9927aadb177d064272d) */
|
||||||
/***********************************************************************************/
|
/***********************************************************************************/
|
||||||
|
|
||||||
#include <pybind11/complex.h>
|
#include <pybind11/complex.h>
|
||||||
|
@ -47,7 +47,7 @@ void bind_caribouLiteSource(py::module& m)
|
||||||
py::arg("rx_bw") = 2500000,
|
py::arg("rx_bw") = 2500000,
|
||||||
py::arg("sample_rate") = 4000000,
|
py::arg("sample_rate") = 4000000,
|
||||||
py::arg("freq") = 900000000,
|
py::arg("freq") = 900000000,
|
||||||
py::arg("provide_sync") = false,
|
py::arg("provide_meta") = false,
|
||||||
D(caribouLiteSource, make))
|
D(caribouLiteSource, make))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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, cariboulite_sample_meta* meta, 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, cariboulite_sample_meta* meta, 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);
|
||||||
|
|
||||||
|
|
|
@ -69,15 +69,15 @@ void CaribouLiteRadio::CaribouLiteRxThread(CaribouLiteRadio* radio)
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
int CaribouLiteRadio::ReadSamples(std::complex<float>* samples, cariboulite_sample_meta* meta, 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, meta, 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)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ int CaribouLiteRadio::ReadSamples(std::complex<float>* samples, cariboulite_samp
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
int CaribouLiteRadio::ReadSamples(std::complex<short>* samples, cariboulite_sample_meta* meta, 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)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ int CaribouLiteRadio::ReadSamples(std::complex<short>* samples, cariboulite_samp
|
||||||
|
|
||||||
if (meta)
|
if (meta)
|
||||||
{
|
{
|
||||||
memcpy(meta, _read_metadata, sizeof(cariboulite_sample_meta) * (size_t)ret);
|
memcpy(meta, _read_metadata, (size_t)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Ładowanie…
Reference in New Issue