add message passing to kill flowgraph
parent
28ebd2ad59
commit
0b5e5e425f
|
@ -136,7 +136,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [8, 412.0]
|
coordinate: [8, 452.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: enabled
|
state: enabled
|
||||||
- name: samp_rate
|
- name: samp_rate
|
||||||
|
@ -235,7 +235,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [968, 184.0]
|
coordinate: [1056, 184.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: enabled
|
state: enabled
|
||||||
- name: blocks_null_sink_0
|
- name: blocks_null_sink_0
|
||||||
|
@ -273,7 +273,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [568, 192.0]
|
coordinate: [656, 192.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
- name: blocks_vector_source_x_0_2
|
- name: blocks_vector_source_x_0_2
|
||||||
|
@ -294,9 +294,27 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [16, 184.0]
|
coordinate: [8, 168.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
|
- name: end_of_transmission
|
||||||
|
id: variable_qtgui_msg_push_button
|
||||||
|
parameters:
|
||||||
|
comment: ''
|
||||||
|
gui_hint: ''
|
||||||
|
label: End of Transmission
|
||||||
|
msgName: end_of_transmission
|
||||||
|
relBackgroundColor: default
|
||||||
|
relFontColor: default
|
||||||
|
type: string
|
||||||
|
value: end_of_transmission
|
||||||
|
states:
|
||||||
|
bus_sink: false
|
||||||
|
bus_source: false
|
||||||
|
bus_structure: null
|
||||||
|
coordinate: [8, 272.0]
|
||||||
|
rotation: 0
|
||||||
|
state: enabled
|
||||||
- name: m17_m17_coder_0
|
- name: m17_m17_coder_0
|
||||||
id: m17_m17_coder
|
id: m17_m17_coder
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -324,7 +342,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [320, 96.0]
|
coordinate: [408, 96.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
- name: m17_m17_decoder_0
|
- name: m17_m17_decoder_0
|
||||||
|
@ -347,7 +365,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [784, 140.0]
|
coordinate: [872, 140.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
- name: note_0_2
|
- name: note_0_2
|
||||||
|
@ -367,6 +385,7 @@ blocks:
|
||||||
connections:
|
connections:
|
||||||
- [blocks_throttle2_0, '0', m17_m17_decoder_0, '0']
|
- [blocks_throttle2_0, '0', m17_m17_decoder_0, '0']
|
||||||
- [blocks_vector_source_x_0_2, '0', m17_m17_coder_0, '0']
|
- [blocks_vector_source_x_0_2, '0', m17_m17_coder_0, '0']
|
||||||
|
- [end_of_transmission, pressed, m17_m17_coder_0, end_of_transmission]
|
||||||
- [m17_m17_coder_0, '0', blocks_throttle2_0, '0']
|
- [m17_m17_coder_0, '0', blocks_throttle2_0, '0']
|
||||||
- [m17_m17_decoder_0, '0', blocks_file_sink_0, '0']
|
- [m17_m17_decoder_0, '0', blocks_file_sink_0, '0']
|
||||||
- [m17_m17_decoder_0, '0', blocks_null_sink_0, '0']
|
- [m17_m17_decoder_0, '0', blocks_null_sink_0, '0']
|
||||||
|
|
|
@ -117,13 +117,14 @@ blocks:
|
||||||
key: ''
|
key: ''
|
||||||
maxoutbuf: '0'
|
maxoutbuf: '0'
|
||||||
minoutbuf: '0'
|
minoutbuf: '0'
|
||||||
|
seed: ''
|
||||||
signed_str: 'False'
|
signed_str: 'False'
|
||||||
threshold: '2.0'
|
threshold: '2.0'
|
||||||
states:
|
states:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [392, 36.0]
|
coordinate: [392, 28.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: enabled
|
state: enabled
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [776, 184.0]
|
coordinate: [880, 200.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: enabled
|
state: enabled
|
||||||
- name: blocks_throttle2_0
|
- name: blocks_throttle2_0
|
||||||
|
@ -147,7 +147,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [560, 192.0]
|
coordinate: [664, 208.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
- name: blocks_vector_source_x_0_2
|
- name: blocks_vector_source_x_0_2
|
||||||
|
@ -171,6 +171,24 @@ blocks:
|
||||||
coordinate: [8, 184.0]
|
coordinate: [8, 184.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
|
- name: end_of_transmission
|
||||||
|
id: variable_qtgui_msg_push_button
|
||||||
|
parameters:
|
||||||
|
comment: ''
|
||||||
|
gui_hint: ''
|
||||||
|
label: End of Transmission
|
||||||
|
msgName: end_of_transmission
|
||||||
|
relBackgroundColor: default
|
||||||
|
relFontColor: default
|
||||||
|
type: string
|
||||||
|
value: end_of_transmission
|
||||||
|
states:
|
||||||
|
bus_sink: false
|
||||||
|
bus_source: false
|
||||||
|
bus_structure: null
|
||||||
|
coordinate: [8, 288.0]
|
||||||
|
rotation: 0
|
||||||
|
state: enabled
|
||||||
- name: m17_m17_coder_0
|
- name: m17_m17_coder_0
|
||||||
id: m17_m17_coder
|
id: m17_m17_coder
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -182,12 +200,13 @@ blocks:
|
||||||
dst_id: dst_str
|
dst_id: dst_str
|
||||||
encr_subtype: '0'
|
encr_subtype: '0'
|
||||||
encr_type: '0'
|
encr_type: '0'
|
||||||
key: ''
|
key: '''\x00\x00\x65\x41\xb0\x93\xff\x00'''
|
||||||
maxoutbuf: '0'
|
maxoutbuf: '0'
|
||||||
meta: meta_str
|
meta: meta_str
|
||||||
minoutbuf: '0'
|
minoutbuf: '0'
|
||||||
mode: '1'
|
mode: '1'
|
||||||
priv_key: ''
|
priv_key: ''
|
||||||
|
seed: ''
|
||||||
signed_str: 'False'
|
signed_str: 'False'
|
||||||
src_id: src_str
|
src_id: src_str
|
||||||
type: type_val
|
type: type_val
|
||||||
|
@ -195,7 +214,7 @@ blocks:
|
||||||
bus_sink: false
|
bus_sink: false
|
||||||
bus_source: false
|
bus_source: false
|
||||||
bus_structure: null
|
bus_structure: null
|
||||||
coordinate: [312, 108.0]
|
coordinate: [416, 112.0]
|
||||||
rotation: 0
|
rotation: 0
|
||||||
state: true
|
state: true
|
||||||
- name: note_0_2
|
- name: note_0_2
|
||||||
|
@ -215,6 +234,7 @@ blocks:
|
||||||
connections:
|
connections:
|
||||||
- [blocks_throttle2_0, '0', blocks_file_sink_0, '0']
|
- [blocks_throttle2_0, '0', blocks_file_sink_0, '0']
|
||||||
- [blocks_vector_source_x_0_2, '0', m17_m17_coder_0, '0']
|
- [blocks_vector_source_x_0_2, '0', m17_m17_coder_0, '0']
|
||||||
|
- [end_of_transmission, pressed, m17_m17_coder_0, end_of_transmission]
|
||||||
- [m17_m17_coder_0, '0', blocks_throttle2_0, '0']
|
- [m17_m17_coder_0, '0', blocks_throttle2_0, '0']
|
||||||
|
|
||||||
metadata:
|
metadata:
|
||||||
|
|
|
@ -103,6 +103,9 @@ inputs:
|
||||||
dtype: byte
|
dtype: byte
|
||||||
vlen: 1
|
vlen: 1
|
||||||
optional: 0
|
optional: 0
|
||||||
|
- label: end_of_transmission
|
||||||
|
domain: message
|
||||||
|
optional: 0
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
- label: out
|
- label: out
|
||||||
|
|
|
@ -102,6 +102,14 @@ namespace gr
|
||||||
for (uint8_t i = 4; i < 4 + 10; i++)
|
for (uint8_t i = 4; i < 4 + 10; i++)
|
||||||
_iv[i] = 0; //10 random bytes TODO: replace with a rand() or pass through an additional arg
|
_iv[i] = 0; //10 random bytes TODO: replace with a rand() or pass through an additional arg
|
||||||
}
|
}
|
||||||
|
message_port_register_in(pmt::mp("end_of_transmission"));
|
||||||
|
set_msg_handler(pmt::mp("end_of_transmission"), [this](const pmt::pmt_t& msg) { end_of_transmission(msg); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void m17_coder_impl::end_of_transmission(const pmt::pmt_t& msg)
|
||||||
|
{_finished=true;
|
||||||
|
std::cout << "***** End of Transmission ********\n";
|
||||||
|
pmt::print(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void m17_coder_impl::set_encr_type (int encr_type)
|
void m17_coder_impl::set_encr_type (int encr_type)
|
||||||
|
@ -538,15 +546,8 @@ namespace gr
|
||||||
|
|
||||||
uint8_t data[16], next_data[16]; //raw payload, packed bits
|
uint8_t data[16], next_data[16]; //raw payload, packed bits
|
||||||
|
|
||||||
while (countout < (uint32_t) noutput_items)
|
while ((countout < (uint32_t) noutput_items) && (countin + 16 <= noutput_items))
|
||||||
{
|
{
|
||||||
if (countin + 16 <= noutput_items)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
data[i] = in[countin];
|
|
||||||
countin++;
|
|
||||||
}
|
|
||||||
if (!_got_lsf) //stream frames
|
if (!_got_lsf) //stream frames
|
||||||
{
|
{
|
||||||
//send LSF syncword
|
//send LSF syncword
|
||||||
|
@ -614,8 +615,8 @@ namespace gr
|
||||||
|
|
||||||
memset (next_data, 0, sizeof (next_data));
|
memset (next_data, 0, sizeof (next_data));
|
||||||
memcpy (data, next_data, sizeof (data));
|
memcpy (data, next_data, sizeof (data));
|
||||||
if (_fn == 60)
|
// if (_fn == 60)
|
||||||
_finished = true;
|
// _finished = true;
|
||||||
|
|
||||||
//debug sig with random payloads (don't play the audio)
|
//debug sig with random payloads (don't play the audio)
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
for (uint8_t i = 0; i < 16; i++)
|
||||||
|
@ -631,6 +632,14 @@ namespace gr
|
||||||
dummy=fread(&(lsf.meta), 14, 1, stdin);
|
dummy=fread(&(lsf.meta), 14, 1, stdin);
|
||||||
dummy=fread(data, 16, 1, stdin);
|
dummy=fread(data, 16, 1, stdin);
|
||||||
*/
|
*/
|
||||||
|
if (countin + 16 <= noutput_items)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
data[i] = in[countin];
|
||||||
|
countin++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//AES encryption enabled - use 112 bits of IV
|
//AES encryption enabled - use 112 bits of IV
|
||||||
if (_encr_type == ENCR_AES)
|
if (_encr_type == ENCR_AES)
|
||||||
|
@ -645,7 +654,7 @@ namespace gr
|
||||||
_lsf.crc[1] = ccrc & 0xFF;
|
_lsf.crc[1] = ccrc & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_finished == false)
|
// while (_finished == false)
|
||||||
{
|
{
|
||||||
if (!_got_lsf)
|
if (!_got_lsf)
|
||||||
{ //debug
|
{ //debug
|
||||||
|
@ -734,6 +743,14 @@ namespace gr
|
||||||
if(fread(&(next_lsf.meta), 14, 1, stdin)<1) finished=1;
|
if(fread(&(next_lsf.meta), 14, 1, stdin)<1) finished=1;
|
||||||
if(fread(next_data, 16, 1, stdin)<1) _finished=true;
|
if(fread(next_data, 16, 1, stdin)<1) _finished=true;
|
||||||
*/
|
*/
|
||||||
|
if (countin + 16 <= noutput_items)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
next_data[i] = in[countin];
|
||||||
|
countin++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//AES
|
//AES
|
||||||
|
@ -793,7 +810,7 @@ namespace gr
|
||||||
memcpy (data, next_data, 16);
|
memcpy (data, next_data, 16);
|
||||||
}
|
}
|
||||||
else //send last frame(s)
|
else //send last frame(s)
|
||||||
{
|
{ printf("Sending last frame\n");
|
||||||
send_syncword (out, &countout, SYNC_STR);
|
send_syncword (out, &countout, SYNC_STR);
|
||||||
extract_LICH (lich, _lich_cnt, &_lsf);
|
extract_LICH (lich, _lich_cnt, &_lsf);
|
||||||
encode_LICH (lich_encoded, lich);
|
encode_LICH (lich_encoded, lich);
|
||||||
|
@ -858,14 +875,16 @@ namespace gr
|
||||||
//fprintf(stderr, "Stream has ended. Exiting.\n");
|
//fprintf(stderr, "Stream has ended. Exiting.\n");
|
||||||
} // finished == true
|
} // finished == true
|
||||||
} // finished == false
|
} // finished == false
|
||||||
} // in enough data left
|
|
||||||
} // loop on input data
|
} // loop on input data
|
||||||
// Tell runtime system how many input items we consumed on
|
// Tell runtime system how many input items we consumed on
|
||||||
// each input stream.
|
// each input stream.
|
||||||
consume_each (countin);
|
consume_each (countin);
|
||||||
// printf(" noutput_items=%d countin=%d countout=%d\n",noutput_items,countin,countout);
|
// printf(" noutput_items=%d countin=%d countout=%d\n",noutput_items,countin,countout);
|
||||||
// Tell runtime system how many output items we produced.
|
// Tell runtime system how many output items we produced.
|
||||||
|
if (_finished==false)
|
||||||
return countout;
|
return countout;
|
||||||
|
else {printf("Killing flowgraph\n"); return -1;} // https://lists.gnu.org/archive/html/discuss-gnuradio/2016-12/msg00206.html
|
||||||
|
// returning -1 (which is the magical value for "there's nothing coming anymore, you can shut down") would normally end a flow graph
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace m17 */
|
} /* namespace m17 */
|
||||||
|
|
|
@ -91,6 +91,8 @@ namespace gr
|
||||||
void set_can (int can);
|
void set_can (int can);
|
||||||
void set_debug (bool debug);
|
void set_debug (bool debug);
|
||||||
void set_signed (bool signed_str);
|
void set_signed (bool signed_str);
|
||||||
|
void end_of_transmission(const pmt::pmt_t& msg);
|
||||||
|
|
||||||
m17_coder_impl (std::string src_id, std::string dst_id, int mode,
|
m17_coder_impl (std::string src_id, std::string dst_id, int mode,
|
||||||
int data, int encr_type, int encr_subtype, int can,
|
int data, int encr_type, int encr_subtype, int can,
|
||||||
std::string meta, std::string key, std::string priv_key,
|
std::string meta, std::string key, std::string priv_key,
|
||||||
|
|
Loading…
Reference in New Issue