split all callback functions to a single parameter assembled as a mask + pulldown menus on loopback example

main
Jean-Michel Friedt 2024-06-08 14:56:56 +02:00
parent 8d5dcb7a96
commit 2f49621981
7 changed files with 225 additions and 36 deletions

View File

@ -38,7 +38,7 @@ blocks:
parameters:
comment: ''
entry_signal: editingFinished
gui_hint: ''
gui_hint: 1,0,1,1
label: DST
type: string
value: AB2CDE
@ -46,15 +46,75 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [568, 12.0]
coordinate: [544, 16.0]
rotation: 0
state: true
- name: enc_subtype
id: variable_qtgui_chooser
parameters:
comment: ''
gui_hint: 6,0,1,1
label: Encr. Subtype
label0: Text
label1: Geolocation
label2: Extended callsign data
label3: Reserved
label4: ''
labels: '[]'
num_opts: '4'
option0: '0'
option1: '1'
option2: '2'
option3: '3'
option4: '4'
options: '[0, 1, 2]'
orient: Qt.QVBoxLayout
type: int
value: '0'
widget: combo_box
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [384, 292.0]
rotation: 0
state: enabled
- name: enc_type
id: variable_qtgui_chooser
parameters:
comment: ''
gui_hint: 5,0,1,1
label: Encr. Type
label0: None
label1: Scrambler
label2: AES
label3: Other/Reserved
label4: ''
labels: '[]'
num_opts: '4'
option0: '0'
option1: '1'
option2: '2'
option3: '3'
option4: '4'
options: '[0, 1, 2]'
orient: Qt.QVBoxLayout
type: int
value: '0'
widget: combo_box
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [248, 292.0]
rotation: 0
state: enabled
- name: meta_str
id: variable_qtgui_entry
parameters:
comment: ''
entry_signal: editingFinished
gui_hint: ''
gui_hint: 2,0,1,1
label: META
type: string
value: Hello!
@ -62,9 +122,39 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [288, 12.0]
coordinate: [288, 16.0]
rotation: 0
state: true
- name: mode
id: variable_qtgui_chooser
parameters:
comment: ''
gui_hint: 3,0,1,1
label: Mode
label0: Stream
label1: Packet
label2: Data + Voice
label3: Reserved
label4: ''
labels: '[]'
num_opts: '2'
option0: '1'
option1: '2'
option2: '5'
option3: '0'
option4: '4'
options: '[0, 1, 2]'
orient: Qt.QVBoxLayout
type: int
value: '1'
widget: combo_box
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [16, 292.0]
rotation: 0
state: enabled
- name: samp_rate
id: variable
parameters:
@ -82,7 +172,7 @@ blocks:
parameters:
comment: ''
entry_signal: editingFinished
gui_hint: ''
gui_hint: 0,0,1,1
label: SRC
type: string
value: AB1CDE
@ -90,25 +180,39 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [424, 12.0]
coordinate: [408, 16.0]
rotation: 0
state: true
- name: type_val
id: variable_qtgui_entry
id: variable_qtgui_chooser
parameters:
comment: ''
entry_signal: editingFinished
gui_hint: ''
label: TYPE
gui_hint: 4,0,1,1
label: Type
label0: Data
label1: Voice
label2: Data + Voice
label3: Reserved
label4: ''
labels: '[]'
num_opts: '4'
option0: '1'
option1: '2'
option2: '3'
option3: '0'
option4: '4'
options: '[0, 1, 2]'
orient: Qt.QVBoxLayout
type: int
value: '5'
value: '2'
widget: combo_box
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [712, 12.0]
coordinate: [120, 292.0]
rotation: 0
state: true
state: enabled
- name: blocks_file_sink_0
id: blocks_file_sink
parameters:
@ -195,12 +299,12 @@ blocks:
comment: ''
debug: 'False'
dst_id: dst_str
encr_subtype: '0'
encr_type: '0'
encr_subtype: enc_subtype
encr_type: enc_type
maxoutbuf: '0'
meta: meta_str
minoutbuf: '0'
mode: '1'
mode: mode
src_id: src_str
type: type_val
states:
@ -216,7 +320,7 @@ blocks:
affinity: ''
alias: ''
comment: ''
debug_ctrl: 'True'
debug_ctrl: 'False'
debug_data: 'False'
maxoutbuf: '0'
minoutbuf: '0'

View File

@ -60,7 +60,11 @@ templates:
- set_meta(${meta})
- set_src_id(${src_id})
- set_dst_id(${dst_id})
- set_mode(${mode})
- set_type(${type})
- set_encr_type(${encr_type})
- set_encr_subtype(${encr_subtype})
- set_can(${can})
- set_debug(${debug})
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.

View File

@ -37,7 +37,12 @@ public:
virtual void set_src_id(std::string src_id)=0;
virtual void set_dst_id(std::string dst_id)=0;
virtual void set_debug(bool debug)=0;
virtual void set_type(int mode,int type,int encr_type,int encr_subtype,int can)=0;
virtual void set_alltype(int mode,int type,int encr_type,int encr_subtype,int can)=0;
virtual void set_mode(int mode)=0;
virtual void set_type(int type)=0;
virtual void set_encr_type(int encr_type)=0;
virtual void set_encr_subtype(int encr_subtype)=0;
virtual void set_can(int can)=0;
};
} // namespace m17

View File

@ -51,11 +51,11 @@ struct LSF lsf;
: gr::block("m17_coder",
gr::io_signature::make(1, 1, sizeof(char)),
gr::io_signature::make(1, 1, sizeof(float)))
, _meta(meta), _debug(debug)
{ set_meta(meta);
, _mode(mode),_type(type),_encr_type(encr_type),_encr_subtype(encr_subtype), _can(can),_meta(meta), _debug(debug)
{ set_alltype(mode, type, encr_type, encr_subtype, can);
set_meta(meta); // depends on ^^^ encr_subtype
set_src_id(src_id);
set_dst_id(dst_id);
set_type(mode, type, encr_type, encr_subtype, can);
set_debug(debug);
set_output_multiple(192);
uint16_t ccrc=LSF_CRC(&lsf);
@ -95,23 +95,68 @@ void m17_coder_impl::set_dst_id(std::string dst_id)
void m17_coder_impl::set_meta(std::string meta)
{int length;
printf("new meta: %s\n",meta.c_str());fflush(stdout);
_meta.assign(meta);
if (meta.length()<14) length=meta.length(); else length=14;
for (int i=0;i<length;i++) {lsf.meta[i]=_meta[i];}
const char *c;
printf("new meta: ");
if (_encr_subtype==1) // meta is \0-terminated string
{printf("%s\n",meta.c_str());
if (meta.length()<14) length=meta.length(); else length=14;
for (int i=0;i<length;i++) {lsf.meta[i]=meta[i];}
}
else
{c=meta.data();
if (sizeof(c)<14) length=sizeof(c); else length=14;
printf("%d bytes: ",length);
for (int i=0;i<length;i++)
{printf("%02X ",c[i]);
lsf.meta[i]=c[i];
}
printf("\n");
}
fflush(stdout);
uint16_t ccrc=LSF_CRC(&lsf);
lsf.crc[0]=ccrc>>8;
lsf.crc[1]=ccrc&0xFF;
}
void m17_coder_impl::set_type(int mode,int type,int encr_type,int encr_subtype,int can)
{_type = mode | (type<<1) | (encr_type<<3) | (encr_subtype<<5) | (can<<7);
lsf.type[0]=_type>>8; // MSB
lsf.type[1]=_type&0xff; // LSB
void m17_coder_impl::set_mode(int mode)
{_mode=mode;
printf("new mode: %02x -> ",_mode);
set_alltype(_mode,_type,_encr_type,_encr_subtype,_can);
}
void m17_coder_impl::set_type(int type)
{_type=type;
printf("new type: %02x -> ",_type);
set_alltype(_mode,_type,_encr_type,_encr_subtype,_can);
}
void m17_coder_impl::set_encr_type(int encr_type)
{_encr_type=encr_type;
printf("new encr type: %02x -> ",_encr_type);
set_alltype(_mode,_type,_encr_type,_encr_subtype,_can);
}
void m17_coder_impl::set_encr_subtype(int encr_subtype)
{_encr_subtype=encr_subtype;
printf("new encr subtype: %02x -> ",_encr_subtype);
set_alltype(_mode,_type,_encr_type,_encr_subtype,_can);
}
void m17_coder_impl::set_can(int can)
{_can=can;
printf("new CAN: %02x -> ",_can);
set_alltype(_mode,_type,_encr_type,_encr_subtype,_can);
}
void m17_coder_impl::set_alltype(int mode,int type,int encr_type,int encr_subtype,int can)
{short tmptype;
tmptype = mode | (type<<1) | (encr_type<<3) | (encr_subtype<<5) | (can<<7);
lsf.type[0]=tmptype>>8; // MSB
lsf.type[1]=tmptype&0xff; // LSB
uint16_t ccrc=LSF_CRC(&lsf);
lsf.crc[0]=ccrc>>8;
lsf.crc[1]=ccrc&0xFF;
printf("new type: %02X%02X\n",lsf.type[0],lsf.type[1]);fflush(stdout);
printf("mask: %02X%02X\n",lsf.type[0],lsf.type[1]);fflush(stdout);
}
/*

View File

@ -16,9 +16,10 @@ namespace m17 {
class m17_coder_impl : public m17_coder
{
private:
std::string _meta;
unsigned char _src_id[10],_dst_id[10]; // 9 character callsign
short _type;
int _mode,_type,_encr_type,_encr_subtype,_can;
std::string _meta;
int _got_lsf=0;
uint16_t _fn=0; //16-bit Frame Number (for the stream mode)
bool _debug=0;
@ -28,7 +29,12 @@ public:
void set_src_id(std::string src_id);
void set_dst_id(std::string dst_id);
void set_meta(std::string meta);
void set_type(int mode,int type,int encr_type,int encr_subtype,int can);
void set_alltype(int mode,int type,int encr_type,int encr_subtype,int can);
void set_mode(int mode);
void set_type(int type);
void set_encr_type(int encr_type);
void set_encr_subtype(int encr_subtype);
void set_can(int can);
void set_debug(bool debug);
m17_coder_impl(std::string src_id,std::string dst_id,int mode,int type,int encr_type,int encr_subtype,int can,std::string meta, bool debug);
~m17_coder_impl();

View File

@ -30,4 +30,14 @@ static const char *__doc_gr_m17_m17_coder_set_dst_id = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_debug = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_alltype = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_mode = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_type = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_encr_type = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_encr_subtype = R"doc()doc";
static const char *__doc_gr_m17_m17_coder_set_can = R"doc()doc";

View File

@ -16,7 +16,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(m17_coder.h) */
/* BINDTOOL_HEADER_FILE_HASH(4ca705105687afff1b51b1b6aa3ff5d8) */
/* BINDTOOL_HEADER_FILE_HASH(22e075cc500dfd1668a98fbf968906fc) */
/***********************************************************************************/
#include <pybind11/complex.h>
@ -53,9 +53,24 @@ void bind_m17_coder(py::module &m) {
.def("set_debug", &m17_coder::set_debug, py::arg("debug"),
D(m17_coder, set_debug))
.def("set_type", &m17_coder::set_type, py::arg("mode"), py::arg("type"),
py::arg("encr_type"), py::arg("encr_subtype"), py::arg("can"),
.def("set_alltype", &m17_coder::set_alltype, py::arg("mode"),
py::arg("type"), py::arg("encr_type"), py::arg("encr_subtype"),
py::arg("can"), D(m17_coder, set_alltype))
.def("set_mode", &m17_coder::set_mode, py::arg("mode"),
D(m17_coder, set_mode))
.def("set_type", &m17_coder::set_type, py::arg("type"),
D(m17_coder, set_type))
.def("set_encr_type", &m17_coder::set_encr_type, py::arg("encr_type"),
D(m17_coder, set_encr_type))
.def("set_encr_subtype", &m17_coder::set_encr_subtype,
py::arg("encr_subtype"), D(m17_coder, set_encr_subtype))
.def("set_can", &m17_coder::set_can, py::arg("can"),
D(m17_coder, set_can))
;
}