From a10640c60c524a158eacfdaf6a98440236415430 Mon Sep 17 00:00:00 2001 From: Wojciech Kaczmarski Date: Mon, 18 Aug 2025 14:20:03 +0200 Subject: [PATCH] decoder: added message output src, dst, type, meta --- .gitignore | 1 + examples/m17_loopback_noisy.grc | 24 ++++++++++++++++++++---- grc/m17_m17_decoder.block.yml | 5 +++++ lib/m17_decoder_impl.cc | 23 ++++++++++++++++++++--- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ee61bf2..4a034c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.pyo build*/ examples/*.py +.vscode/* diff --git a/examples/m17_loopback_noisy.grc b/examples/m17_loopback_noisy.grc index 79e84e1..75942a9 100644 --- a/examples/m17_loopback_noisy.grc +++ b/examples/m17_loopback_noisy.grc @@ -178,9 +178,24 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [960, 228.0] + coordinate: [960, 212.0] rotation: 0 state: disabled +- name: blocks_message_debug_0 + id: blocks_message_debug + parameters: + affinity: '' + alias: '' + comment: '' + en_uvec: 'True' + log_level: info + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [960, 304.0] + rotation: 0 + state: enabled - name: blocks_null_sink_0 id: blocks_null_sink parameters: @@ -195,7 +210,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [960, 192.0] + coordinate: [960, 168.0] rotation: 0 state: enabled - name: blocks_throttle2_0 @@ -294,8 +309,8 @@ blocks: alias: '' callsign: 'True' comment: '' - debug_ctrl: 'True' - debug_data: 'True' + debug_ctrl: 'False' + debug_data: 'False' encr_type: '0' key: '' maxoutbuf: '0' @@ -417,6 +432,7 @@ connections: - [m17_m17_coder_0, '0', blocks_add_xx_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, fields, blocks_message_debug_0, print] metadata: file_format: 1 diff --git a/grc/m17_m17_decoder.block.yml b/grc/m17_m17_decoder.block.yml index 4b16f8f..4fe941b 100644 --- a/grc/m17_m17_decoder.block.yml +++ b/grc/m17_m17_decoder.block.yml @@ -79,6 +79,11 @@ outputs: dtype: byte vlen: 1 optional: 0 +- label: fields + domain: message + id: fields + type: message + optional: true documentation: |- The decoder block accepts two boolean debugging flags defining which messages are displayed in the console when messages are received, and a threshold parameter. The threshold defines a value below which the incoming message is detected. It is based on the Euclidean distance (L^2 norm) between the received symbol stream and protocol-defined syncronization patterns. Ideally, the distance would reach 0.0 for an ideal match. A default threshold value of 2.0 is selected. diff --git a/lib/m17_decoder_impl.cc b/lib/m17_decoder_impl.cc index 2d106cd..d4dd9f4 100644 --- a/lib/m17_decoder_impl.cc +++ b/lib/m17_decoder_impl.cc @@ -67,6 +67,8 @@ namespace gr set_key(key); set_encr_type(encr_type); _expected_next_fn = 0; + + message_port_register_out(pmt::mp("fields")); } /* @@ -216,7 +218,7 @@ namespace gr m17_decoder_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) { - ninput_items_required[0] = 1; // noutput_items; + ninput_items_required[0] = 1; // do work only if there is at least one symbol available } // this is generating a correct seed value based on the fn value, @@ -541,10 +543,25 @@ namespace gr // debug - dump LICH if (lich_chunks_rcvd == 0x3F) // all 6 chunks received? { + // handle message output + pmt::pmt_t msg; + decode_callsign_bytes(d_dst, _lsf.dst); + decode_callsign_bytes(d_src, _lsf.src); + + pmt::pmt_t dict = pmt::make_dict(); + dict = pmt::dict_add(dict, pmt::mp("src"), pmt::intern((char *)d_src)); + dict = pmt::dict_add(dict, pmt::mp("dst"), pmt::intern((char *)d_dst)); + + msg = pmt::init_u8vector(2, _lsf.type); + dict = pmt::dict_add(dict, pmt::mp("type"), msg); + msg = pmt::init_u8vector(14, _lsf.meta); + dict = pmt::dict_add(dict, pmt::mp("meta"), msg); + + message_port_pub(pmt::mp("fields"), dict); + + // debug data display if (_callsign == true) { - decode_callsign_bytes(d_dst, _lsf.dst); - decode_callsign_bytes(d_src, _lsf.src); if (_debug_ctrl == true) { printf("DST: %-9s ", d_dst); // DST