Add getters/setters in preamble/slicer, bring them out to radio.py via pubsub.
This commit is contained in:
@@ -42,14 +42,8 @@ air_modes_preamble::air_modes_preamble(int channel_rate, float threshold_db) :
|
||||
gr_make_io_signature2 (2, 2, sizeof(float), sizeof(float)), //stream 0 is received data, stream 1 is moving average for reference
|
||||
gr_make_io_signature (1, 1, sizeof(float))) //the output packets
|
||||
{
|
||||
d_chip_rate = 2000000; //2Mchips per second
|
||||
d_samples_per_chip = channel_rate / d_chip_rate; //must be integer number of samples per chip to work
|
||||
d_samples_per_symbol = d_samples_per_chip * 2;
|
||||
d_check_width = 120 * d_samples_per_symbol; //only search to this far from the end of the stream buffer
|
||||
d_threshold_db = threshold_db;
|
||||
d_threshold = powf(10., threshold_db/20.); //the level that the sample must be above the moving average in order to qualify as a pulse
|
||||
d_secs_per_sample = 1.0 / channel_rate;
|
||||
set_output_multiple(1+d_check_width*2);
|
||||
set_rate(channel_rate);
|
||||
set_threshold(threshold_db);
|
||||
|
||||
std::stringstream str;
|
||||
str << name() << unique_id();
|
||||
@@ -58,6 +52,27 @@ air_modes_preamble::air_modes_preamble(int channel_rate, float threshold_db) :
|
||||
set_history(d_samples_per_symbol);
|
||||
}
|
||||
|
||||
void air_modes_preamble::set_rate(int channel_rate)
|
||||
{
|
||||
d_chip_rate = 2000000; //2Mchips per second
|
||||
d_samples_per_chip = channel_rate / d_chip_rate; //must be integer number of samples per chip to work
|
||||
d_samples_per_symbol = d_samples_per_chip * 2;
|
||||
d_secs_per_sample = 1.0 / channel_rate;
|
||||
d_check_width = 240 * d_samples_per_symbol; //only search to this far from the end of the stream buffer
|
||||
set_output_multiple(1+d_check_width);
|
||||
}
|
||||
|
||||
void air_modes_preamble::set_threshold(float threshold_db)
|
||||
{
|
||||
d_threshold_db = threshold_db;
|
||||
d_threshold = powf(10., threshold_db/20.); //the level that the sample must be above the moving average in order to qualify as a pulse
|
||||
}
|
||||
|
||||
float air_modes_preamble::get_threshold(void)
|
||||
{
|
||||
return d_threshold_db;
|
||||
}
|
||||
|
||||
static void integrate_and_dump(float *out, const float *in, int chips, int samps_per_chip) {
|
||||
for(int i=0; i<chips; i++) {
|
||||
float acc = 0;
|
||||
@@ -169,7 +184,7 @@ int air_modes_preamble::general_work(int noutput_items,
|
||||
if(!valid_preamble) continue;
|
||||
|
||||
//be sure we've got enough room in the input buffer to copy out a whole packet
|
||||
if(ninputs-i < 240*d_samples_per_chip) {
|
||||
if(ninputs-i < d_check_width) {
|
||||
consume_each(std::max(i-1,0));
|
||||
if(0) std::cout << "Preamble consumed " << std::max(i-1,0) << ", returned 0 (no room)" << std::endl;
|
||||
return 0;
|
||||
|
||||
@@ -51,14 +51,17 @@ air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) :
|
||||
gr_make_io_signature (1, 1, sizeof(float)), //stream 0 is received data, stream 1 is binary preamble detector output
|
||||
gr_make_io_signature (0, 0, 0) )
|
||||
{
|
||||
//initialize private data here
|
||||
set_rate(channel_rate);
|
||||
d_queue = queue;
|
||||
}
|
||||
|
||||
void air_modes_slicer::set_rate(int channel_rate)
|
||||
{
|
||||
d_chip_rate = 2000000; //2Mchips per second
|
||||
d_samples_per_chip = 2;//FIXME this is constant now channel_rate / d_chip_rate;
|
||||
d_samples_per_symbol = d_samples_per_chip * 2;
|
||||
d_check_width = 120 * d_samples_per_symbol; //how far you will have to look ahead
|
||||
d_queue = queue;
|
||||
|
||||
set_output_multiple(d_check_width*2); //how do you specify buffer size for sinks?
|
||||
d_check_width = 240 * d_samples_per_symbol; //how far you will have to look ahead
|
||||
set_output_multiple(d_check_width); //how do you specify buffer size for sinks?
|
||||
}
|
||||
|
||||
//this slicer is courtesy of Lincoln Labs. supposedly it is more resistant to mode A/C FRUIT.
|
||||
|
||||
Reference in New Issue
Block a user