add debug flag to decoder and coder function of GNU Radio 3.10

main
Jean-Michel Friedt 2023-02-21 19:03:23 +01:00
parent 7a23317f75
commit cf99c8674c
8 changed files with 56 additions and 21 deletions

View File

@ -23,18 +23,24 @@ parameters:
label: Meta
dtype: string
default: 'helloworld'
- id: debug
label: Debug
dtype: bool
default: 'False'
options: ['True', 'False']
asserts:
- ${type<256}
templates:
imports: from gnuradio import m17
make: m17.m17_coder(${src_id},${dst_id},${type},${meta},${samp_rate})
make: m17.m17_coder(${src_id},${dst_id},${type},${meta},${samp_rate},${debug})
callbacks:
- set_meta(${meta})
- set_samp_rate(${samp_rate})
- set_src_id(${src_id})
- set_dst_id(${dst_id})
- set_type(${type})
- set_debug(${debug})
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
# Keys include:

View File

@ -2,9 +2,18 @@ id: m17_m17_decoder
label: m17_decoder
category: '[m17]'
parameters:
- id: debug
label: Debug
dtype: bool
default: 'False'
options: ['True', 'False']
templates:
imports: from gnuradio import m17
make: m17.m17_decoder()
make: m17.m17_decoder(${debug})
callbacks:
- set_debug(${debug})
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
# Keys include:

View File

@ -32,11 +32,12 @@ public:
* class. m17::m17_coder::make is the public interface for
* creating new instances.
*/
static sptr make(std::string src_id,std::string dst_id,short type,std::string meta,float samp_rate);
static sptr make(std::string src_id,std::string dst_id,short type,std::string meta,float samp_rate,bool debug);
virtual void set_meta(std::string meta)=0;
virtual void set_src_id(std::string src_id)=0;
virtual void set_dst_id(std::string dst_id)=0;
virtual void set_samp_rate(float samp_rate)=0;
virtual void set_debug(bool debug)=0;
};
} // namespace m17

View File

@ -32,7 +32,8 @@ public:
* class. m17::m17_decoder::make is the public interface for
* creating new instances.
*/
static sptr make();
static sptr make(bool debug);
virtual void set_debug(bool debug)=0;
};
} // namespace m17

View File

@ -261,31 +261,31 @@ uint16_t LSF_CRC(struct LSF *in)
}
m17_coder::sptr
m17_coder::make(std::string src_id,std::string dst_id,short type,std::string meta, float samp_rate)
m17_coder::make(std::string src_id,std::string dst_id,short type,std::string meta, float samp_rate,bool debug)
{
return gnuradio::get_initial_sptr
(new m17_coder_impl(src_id,dst_id,type,meta,samp_rate));
(new m17_coder_impl(src_id,dst_id,type,meta,samp_rate,debug));
}
/*
* The private constructor
*/
m17_coder_impl::m17_coder_impl(std::string src_id,std::string dst_id,short type,std::string meta, float samp_rate)
m17_coder_impl::m17_coder_impl(std::string src_id,std::string dst_id,short type,std::string meta, float samp_rate, bool debug)
: gr::block("m17_coder",
gr::io_signature::make(1, 1, sizeof(char)),
gr::io_signature::make(1, 1, sizeof(float)))
,_meta(meta), _samp_rate(samp_rate)
,_meta(meta), _samp_rate(samp_rate), _debug(debug)
{ set_meta(meta);
set_src_id(src_id);
set_dst_id(dst_id);
set_samp_rate(samp_rate);
set_type(type);
set_debug(debug);
uint16_t ccrc=LSF_CRC(&lsf);
lsf.crc[0]=ccrc>>8;
lsf.crc[1]=ccrc&0xFF;
_got_lsf=0; //have we filled the LSF struct yet?
_fn=0; //16-bit Frame Number (for the stream mode)
}
void m17_coder_impl::set_samp_rate(float samp_rate)
@ -293,6 +293,11 @@ void m17_coder_impl::set_samp_rate(float samp_rate)
printf("New sampling rate: %f\n",_samp_rate);
}
void m17_coder_impl::set_debug(bool debug)
{_debug=debug;
if (_debug==true) printf("true\n"); else printf("Debug false\n");
}
void m17_coder_impl::set_src_id(std::string src_id)
{for (int i=0;i<6;i++) {_src_id[i]=0;}
sscanf(src_id.c_str(), "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu", &_src_id[0], &_src_id[1], &_src_id[2], &_src_id[3],&_src_id[4],&_src_id[5]);

View File

@ -22,6 +22,7 @@ private:
short _type;
int _got_lsf=0;
uint16_t _fn=0; //16-bit Frame Number (for the stream mode)
bool _debug=0;
public:
@ -30,7 +31,8 @@ public:
void set_samp_rate(float samp_rate);
void set_meta(std::string meta);
void set_type(short type);
m17_coder_impl(std::string src_id,std::string dst_id,short type,std::string meta,float samp_rate);
void set_debug(bool debug);
m17_coder_impl(std::string src_id,std::string dst_id,short type,std::string meta,float samp_rate,bool debug);
~m17_coder_impl();
// Where all the action really happens

View File

@ -101,21 +101,22 @@ void decode_callsign(uint8_t *outp, const uint8_t *inp)
}
m17_decoder::sptr
m17_decoder::make()
m17_decoder::make(bool debug)
{
return gnuradio::get_initial_sptr
(new m17_decoder_impl());
(new m17_decoder_impl(debug));
}
/*
* The private constructor
*/
m17_decoder_impl::m17_decoder_impl()
m17_decoder_impl::m17_decoder_impl(bool debug)
: gr::block("m17_decoder",
gr::io_signature::make(1, 1, sizeof(float)),
gr::io_signature::make(1, 1, sizeof(char)))
{}
gr::io_signature::make(1, 1, sizeof(char))),
_debug(debug)
{set_debug(debug);}
/*
* Our virtual destructor.
@ -124,6 +125,11 @@ void decode_callsign(uint8_t *outp, const uint8_t *inp)
{
}
void m17_decoder_impl::set_debug(bool debug)
{_debug=debug;
if (_debug==true) printf("true\n"); else printf("Debug false\n");
}
void
m17_decoder_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
@ -281,6 +287,7 @@ uint8_t pushed; //counter for pushed symbols
decode_callsign(d_dst, &lsf[0]);
decode_callsign(d_src, &lsf[6]);
if (_debug==true) {
//DST
printf("DST: %-9s ", d_dst);
@ -321,7 +328,7 @@ uint8_t pushed; //counter for pushed symbols
else
printf(" LSF_CRC_OK ");
printf("\n");
}
lich_chunks_rcvd=0; //reset all flags
}
@ -334,6 +341,7 @@ uint8_t pushed; //counter for pushed symbols
//decode
uint32_t e=decodePunctured(frame_data, enc_data, P_2, 272, 12);
if (_debug==true) {
//dump data - first byte is empty
printf("FN: %02X%02X PLD: ", frame_data[1], frame_data[2]);
for(uint8_t i=3; i<19; i++)
@ -345,14 +353,15 @@ uint8_t pushed; //counter for pushed symbols
#else
printf("\n");
#endif
}
//send codec2 stream to stdout
//write(STDOUT_FILENO, &frame_data[3], 16);
}
else //lsf
{
if (_debug==true) {
printf("LSF\n");
}
//decode
uint32_t e=decodePunctured(lsf, d_soft_bit, P_1, 2*SYM_PER_PLD, 61);
@ -367,6 +376,7 @@ uint8_t pushed; //counter for pushed symbols
decode_callsign(d_dst, &lsf[0]);
decode_callsign(d_src, &lsf[6]);
if (_debug==true) {
//DST
printf("DST: %-9s ", d_dst);
@ -406,13 +416,13 @@ uint8_t pushed; //counter for pushed symbols
printf("LSF_CRC_ERR");
else
printf("LSF_CRC_OK ");
//Viterbi decoder errors
#ifdef SHOW_VITERBI_ERRS
printf(" e=%1.1f\n", (float)e/0xFFFF);
#else
printf("\n");
#endif
}
}
//job done

View File

@ -16,11 +16,12 @@ namespace m17 {
class m17_decoder_impl : public m17_decoder
{
private:
// Nothing to declare in this block.
bool _debug=false;
public:
m17_decoder_impl();
m17_decoder_impl(bool debug);
~m17_decoder_impl();
void set_debug(bool debug);
// Where all the action really happens
void forecast(int noutput_items, gr_vector_int& ninput_items_required);