1
0
Fork 0
mirror of https://github.com/hb9fxq/gr-digitalhf synced 2024-12-22 23:19:59 +00:00

update of decoders (intermediate)

This commit is contained in:
cmayer 2019-03-28 17:23:15 +01:00
parent 09527e2383
commit 127449e592
13 changed files with 746 additions and 120 deletions

View file

@ -633,7 +633,7 @@
</param> </param>
<param> <param>
<key>file</key> <key>file</key>
<value>/Users/chm/Software/signal-analysis/20181104T143753Z_5680800_SM2KOT_iq.wav</value> <value>/Users/chm/Software/signal-analysis/20181114T104644Z_9188800_KPH_iq.wav</value>
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>

View file

@ -164,7 +164,7 @@
</param> </param>
<param> <param>
<key>value</key> <key>value</key>
<value>0.005</value> <value>0.0035</value>
</param> </param>
<param> <param>
<key>_enabled</key> <key>_enabled</key>
@ -324,7 +324,7 @@
</param> </param>
<param> <param>
<key>value</key> <key>value</key>
<value>12001</value> <value>12000</value>
</param> </param>
</block> </block>
<block> <block>
@ -382,7 +382,7 @@
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(448, 133)</value> <value>(768, 133)</value>
</param> </param>
<param> <param>
<key>_rotation</key> <key>_rotation</key>
@ -511,6 +511,57 @@
<value>1</value> <value>1</value>
</param> </param>
</block> </block>
<block>
<key>blocks_file_sink</key>
<param>
<key>append</key>
<value>False</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>1</value>
</param>
<param>
<key>file</key>
<value>/Users/chm/Software/gr-digitalhf/examples/symb.bin</value>
</param>
<param>
<key>_coordinate</key>
<value>(544, 528)</value>
</param>
<param>
<key>_rotation</key>
<value>180</value>
</param>
<param>
<key>id</key>
<value>blocks_file_sink_0_0</value>
</param>
<param>
<key>type</key>
<value>complex</value>
</param>
<param>
<key>unbuffered</key>
<value>True</value>
</param>
<param>
<key>vlen</key>
<value>1</value>
</param>
</block>
<block> <block>
<key>blocks_float_to_complex</key> <key>blocks_float_to_complex</key>
<param> <param>
@ -676,7 +727,7 @@
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(661, 154)</value> <value>(480, 154)</value>
</param> </param>
<param> <param>
<key>_rotation</key> <key>_rotation</key>
@ -731,7 +782,7 @@
</param> </param>
<param> <param>
<key>file</key> <key>file</key>
<value>/Users/chm/Software/signal-analysis/gnuradio/20181026T063629Z_7815000_SM2GCT_iq.wav</value> <value>/Users/chm/Software/gr-kiwisdr/examples/20190326T120049Z_2670000_GB3WE_iq.wav</value>
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
@ -865,7 +916,7 @@
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(554, 538)</value> <value>(544, 624)</value>
</param> </param>
<param> <param>
<key>gui_hint</key> <key>gui_hint</key>
@ -1492,7 +1543,7 @@
</param> </param>
<param> <param>
<key>size</key> <key>size</key>
<value>1024</value> <value>1024/4</value>
</param> </param>
<param> <param>
<key>srate</key> <key>srate</key>
@ -1863,7 +1914,7 @@
</param> </param>
<param> <param>
<key>srate</key> <key>srate</key>
<value>samp_rate/sps/3</value> <value>samp_rate/sps</value>
</param> </param>
<param> <param>
<key>stemplot</key> <key>stemplot</key>
@ -1950,11 +2001,11 @@
</param> </param>
<param> <param>
<key>fftsize</key> <key>fftsize</key>
<value>1024*4</value> <value>1024</value>
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(1066, 101)</value> <value>(1045, 80)</value>
</param> </param>
<param> <param>
<key>gui_hint</key> <key>gui_hint</key>
@ -2134,7 +2185,7 @@
</param> </param>
<param> <param>
<key>update_time</key> <key>update_time</key>
<value>0.10</value> <value>0.01</value>
</param> </param>
<param> <param>
<key>wintype</key> <key>wintype</key>
@ -2143,7 +2194,13 @@
</block> </block>
<connection> <connection>
<source_block_id>analog_agc2_xx_0</source_block_id> <source_block_id>analog_agc2_xx_0</source_block_id>
<sink_block_id>blocks_throttle_0</sink_block_id> <sink_block_id>digitalhf_physical_layer_driver_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>analog_agc2_xx_0</source_block_id>
<sink_block_id>qtgui_waterfall_sink_x_0</sink_block_id>
<source_key>0</source_key> <source_key>0</source_key>
<sink_key>0</sink_key> <sink_key>0</sink_key>
</connection> </connection>
@ -2155,7 +2212,7 @@
</connection> </connection>
<connection> <connection>
<source_block_id>blocks_float_to_complex_0</source_block_id> <source_block_id>blocks_float_to_complex_0</source_block_id>
<sink_block_id>analog_agc2_xx_0</sink_block_id> <sink_block_id>blocks_throttle_0</sink_block_id>
<source_key>0</source_key> <source_key>0</source_key>
<sink_key>0</sink_key> <sink_key>0</sink_key>
</connection> </connection>
@ -2173,13 +2230,7 @@
</connection> </connection>
<connection> <connection>
<source_block_id>blocks_throttle_0</source_block_id> <source_block_id>blocks_throttle_0</source_block_id>
<sink_block_id>digitalhf_physical_layer_driver_0</sink_block_id> <sink_block_id>analog_agc2_xx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blocks_throttle_0</source_block_id>
<sink_block_id>qtgui_waterfall_sink_x_0</sink_block_id>
<source_key>0</source_key> <source_key>0</source_key>
<sink_key>0</sink_key> <sink_key>0</sink_key>
</connection> </connection>
@ -2201,6 +2252,12 @@
<source_key>1</source_key> <source_key>1</source_key>
<sink_key>0</sink_key> <sink_key>0</sink_key>
</connection> </connection>
<connection>
<source_block_id>digitalhf_physical_layer_driver_0</source_block_id>
<sink_block_id>blocks_file_sink_0_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection> <connection>
<source_block_id>digitalhf_physical_layer_driver_0</source_block_id> <source_block_id>digitalhf_physical_layer_driver_0</source_block_id>
<sink_block_id>qtgui_const_sink_x_0</sink_block_id> <sink_block_id>qtgui_const_sink_x_0</sink_block_id>

View file

@ -93,6 +93,77 @@
<value>(0,0)</value> <value>(0,0)</value>
</param> </param>
</block> </block>
<block>
<key>variable_cc_decoder_def</key>
<param>
<key>padding</key>
<value>False</value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>k</key>
<value>7</value>
</param>
<param>
<key>dim1</key>
<value>1</value>
</param>
<param>
<key>dim2</key>
<value>1</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>state_end</key>
<value>-1</value>
</param>
<param>
<key>framebits</key>
<value>30*8</value>
</param>
<param>
<key>_coordinate</key>
<value>(32, 341)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>CCSDS_27</value>
</param>
<param>
<key>value</key>
<value>"ok"</value>
</param>
<param>
<key>ndim</key>
<value>0</value>
</param>
<param>
<key>polys</key>
<value>[109,79]</value>
</param>
<param>
<key>rate</key>
<value>2</value>
</param>
<param>
<key>state_start</key>
<value>0</value>
</param>
<param>
<key>mode</key>
<value>fec.CC_STREAMING</value>
</param>
</block>
<block> <block>
<key>variable_qtgui_range</key> <key>variable_qtgui_range</key>
<param> <param>
@ -263,7 +334,7 @@
</param> </param>
<param> <param>
<key>value</key> <key>value</key>
<value>0.005</value> <value>0.0035</value>
</param> </param>
<param> <param>
<key>_enabled</key> <key>_enabled</key>
@ -396,7 +467,7 @@
</param> </param>
<param> <param>
<key>value</key> <key>value</key>
<value>4</value> <value>3</value>
</param> </param>
</block> </block>
<block> <block>
@ -453,6 +524,49 @@
<value>5</value> <value>5</value>
</param> </param>
</block> </block>
<block>
<key>variable_dummy_decoder_def</key>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>dim1</key>
<value>1</value>
</param>
<param>
<key>dim2</key>
<value>1</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>framebits</key>
<value>2048</value>
</param>
<param>
<key>_coordinate</key>
<value>(106, 634)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>variable_dummy_decoder_def_0</value>
</param>
<param>
<key>value</key>
<value>"ok"</value>
</param>
<param>
<key>ndim</key>
<value>0</value>
</param>
</block>
<block> <block>
<key>analog_agc2_xx</key> <key>analog_agc2_xx</key>
<param> <param>
@ -473,7 +587,7 @@
</param> </param>
<param> <param>
<key>decay_rate</key> <key>decay_rate</key>
<value>1e-2</value> <value>1e-1</value>
</param> </param>
<param> <param>
<key>_enabled</key> <key>_enabled</key>
@ -559,6 +673,108 @@
<value>1</value> <value>1</value>
</param> </param>
</block> </block>
<block>
<key>blocks_file_sink</key>
<param>
<key>append</key>
<value>False</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>file</key>
<value>/Users/chm/Software/gr-digitalhf/examples/bits.bin</value>
</param>
<param>
<key>_coordinate</key>
<value>(1109, 581)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>blocks_file_sink_0</value>
</param>
<param>
<key>type</key>
<value>byte</value>
</param>
<param>
<key>unbuffered</key>
<value>False</value>
</param>
<param>
<key>vlen</key>
<value>1</value>
</param>
</block>
<block>
<key>blocks_file_sink</key>
<param>
<key>append</key>
<value>False</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>file</key>
<value>/Users/chm/Software/gr-digitalhf/examples/soft_dec_test.bin</value>
</param>
<param>
<key>_coordinate</key>
<value>(864, 506)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>blocks_file_sink_0_0</value>
</param>
<param>
<key>type</key>
<value>float</value>
</param>
<param>
<key>unbuffered</key>
<value>False</value>
</param>
<param>
<key>vlen</key>
<value>1</value>
</param>
</block>
<block> <block>
<key>blocks_float_to_complex</key> <key>blocks_float_to_complex</key>
<param> <param>
@ -602,6 +818,53 @@
<value>1</value> <value>1</value>
</param> </param>
</block> </block>
<block>
<key>blocks_pdu_to_tagged_stream</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(576, 592)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>blocks_pdu_to_tagged_stream_0</value>
</param>
<param>
<key>type</key>
<value>float</value>
</param>
<param>
<key>tag</key>
<value>packet_len</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
</block>
<block> <block>
<key>blocks_tag_debug</key> <key>blocks_tag_debug</key>
<param> <param>
@ -626,7 +889,7 @@
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(1184, 464)</value> <value>(1152, 677)</value>
</param> </param>
<param> <param>
<key>_rotation</key> <key>_rotation</key>
@ -638,7 +901,7 @@
</param> </param>
<param> <param>
<key>type</key> <key>type</key>
<value>complex</value> <value>byte</value>
</param> </param>
<param> <param>
<key>filter</key> <key>filter</key>
@ -657,6 +920,53 @@
<value>1</value> <value>1</value>
</param> </param>
</block> </block>
<block>
<key>blocks_tagged_stream_to_pdu</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(490, 730)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>blocks_tagged_stream_to_pdu_0</value>
</param>
<param>
<key>type</key>
<value>byte</value>
</param>
<param>
<key>tag</key>
<value>packet_len</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
</block>
<block> <block>
<key>blocks_throttle</key> <key>blocks_throttle</key>
<param> <param>
@ -732,7 +1042,7 @@
</param> </param>
<param> <param>
<key>file</key> <key>file</key>
<value>/Users/chm/Software/signal-analysis/gnuradio/20181027T095433Z_6407800_SM2GCT_iq.wav</value> <value>/Users/chm/Software/gr-digitalhf/examples/on5kq.ddns.net_2019-03-20T12_49_38Z_2381.40_iq.wav</value>
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
@ -760,7 +1070,7 @@
</param> </param>
<param> <param>
<key>repeat</key> <key>repeat</key>
<value>True</value> <value>False</value>
</param> </param>
</block> </block>
<block> <block>
@ -838,6 +1148,104 @@
<value>samp_rate</value> <value>samp_rate</value>
</param> </param>
</block> </block>
<block>
<key>fec_decode_ccsds_27_fb</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(853, 805)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>fec_decode_ccsds_27_fb_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
</block>
<block>
<key>fec_extended_decoder</key>
<param>
<key>ann</key>
<value>None</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>decoder_list</key>
<value>CCSDS_27</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(853, 618)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>fec_extended_decoder_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>puncpat</key>
<value>'11'</value>
</param>
<param>
<key>threadtype</key>
<value>capillary</value>
</param>
<param>
<key>value</key>
<value>fec_extended_decoder</value>
</param>
</block>
<block> <block>
<key>qtgui_const_sink_x</key> <key>qtgui_const_sink_x</key>
<param> <param>
@ -1588,7 +1996,7 @@
</param> </param>
<param> <param>
<key>_coordinate</key> <key>_coordinate</key>
<value>(320, 293)</value> <value>(320, 272)</value>
</param> </param>
<param> <param>
<key>gui_hint</key> <key>gui_hint</key>
@ -1884,7 +2292,7 @@
</param> </param>
<param> <param>
<key>tr_mode</key> <key>tr_mode</key>
<value>qtgui.TRIG_MODE_AUTO</value> <value>qtgui.TRIG_MODE_TAG</value>
</param> </param>
<param> <param>
<key>tr_slope</key> <key>tr_slope</key>
@ -1892,11 +2300,11 @@
</param> </param>
<param> <param>
<key>tr_tag</key> <key>tr_tag</key>
<value>"soft_dec"</value> <value>"packet_len"</value>
</param> </param>
<param> <param>
<key>type</key> <key>type</key>
<value>msg_float</value> <value>float</value>
</param> </param>
<param> <param>
<key>update_time</key> <key>update_time</key>
@ -2160,6 +2568,30 @@
<source_key>0</source_key> <source_key>0</source_key>
<sink_key>0</sink_key> <sink_key>0</sink_key>
</connection> </connection>
<connection>
<source_block_id>blocks_pdu_to_tagged_stream_0</source_block_id>
<sink_block_id>blocks_file_sink_0_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blocks_pdu_to_tagged_stream_0</source_block_id>
<sink_block_id>fec_decode_ccsds_27_fb_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blocks_pdu_to_tagged_stream_0</source_block_id>
<sink_block_id>fec_extended_decoder_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blocks_pdu_to_tagged_stream_0</source_block_id>
<sink_block_id>qtgui_time_sink_x_1</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection> <connection>
<source_block_id>blocks_throttle_0</source_block_id> <source_block_id>blocks_throttle_0</source_block_id>
<sink_block_id>digitalhf_physical_layer_driver_0</sink_block_id> <sink_block_id>digitalhf_physical_layer_driver_0</sink_block_id>
@ -2198,8 +2630,32 @@
</connection> </connection>
<connection> <connection>
<source_block_id>digitalhf_physical_layer_driver_0</source_block_id> <source_block_id>digitalhf_physical_layer_driver_0</source_block_id>
<sink_block_id>qtgui_time_sink_x_1</sink_block_id> <sink_block_id>blocks_pdu_to_tagged_stream_0</sink_block_id>
<source_key>soft_dec</source_key> <source_key>soft_dec</source_key>
<sink_key>in</sink_key> <sink_key>pdus</sink_key>
</connection>
<connection>
<source_block_id>fec_decode_ccsds_27_fb_0</source_block_id>
<sink_block_id>blocks_file_sink_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>fec_decode_ccsds_27_fb_0</source_block_id>
<sink_block_id>blocks_tag_debug_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>fec_extended_decoder_0</source_block_id>
<sink_block_id>blocks_file_sink_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>fec_extended_decoder_0</source_block_id>
<sink_block_id>blocks_tag_debug_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection> </connection>
</flow_graph> </flow_graph>

View file

@ -36,7 +36,7 @@ if(NOT digitalhf_sources)
endif(NOT digitalhf_sources) endif(NOT digitalhf_sources)
add_library(gnuradio-digitalhf SHARED ${digitalhf_sources}) add_library(gnuradio-digitalhf SHARED ${digitalhf_sources})
target_link_libraries(gnuradio-digitalhf ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries(gnuradio-digitalhf ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${LOG4CPP_LIBRARIES})
set_target_properties(gnuradio-digitalhf PROPERTIES DEFINE_SYMBOL "gnuradio_digitalhf_EXPORTS") set_target_properties(gnuradio-digitalhf PROPERTIES DEFINE_SYMBOL "gnuradio_digitalhf_EXPORTS")
if(APPLE) if(APPLE)
@ -71,6 +71,7 @@ target_link_libraries(
${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${CPPUNIT_LIBRARIES} ${CPPUNIT_LIBRARIES}
${LOG4CPP_LIBRARIES}
gnuradio-digitalhf gnuradio-digitalhf
) )
GR_ADD_TEST(test_digitalhf test-digitalhf) GR_ADD_TEST(test_digitalhf test-digitalhf)

View file

@ -84,8 +84,8 @@ adaptive_dfe_impl::adaptive_dfe_impl(int sps, // samples per symbol
, _symbol_counter(0) , _symbol_counter(0)
, _save_soft_decisions(false) , _save_soft_decisions(false)
, _vec_soft_decisions() , _vec_soft_decisions()
, _msg_ports{{"soft_dec", pmt::mp("soft_dec")}, , _msg_ports{{"soft_dec", pmt::intern("soft_dec")},
{"frame_info", pmt::mp("frame_info")}} {"frame_info", pmt::intern("frame_info")}}
, _msg_metadata(pmt::make_dict()) , _msg_metadata(pmt::make_dict())
, _state(WAIT_FOR_PREAMBLE) , _state(WAIT_FOR_PREAMBLE)
{ {
@ -96,7 +96,7 @@ adaptive_dfe_impl::adaptive_dfe_impl(int sps, // samples per symbol
message_port_register_out(_msg_ports["soft_dec"]); message_port_register_out(_msg_ports["soft_dec"]);
pmt::pmt_t constellations_port = pmt::mp("constellations"); pmt::pmt_t constellations_port = pmt::intern("constellations");
message_port_register_in(constellations_port); message_port_register_in(constellations_port);
set_msg_handler(constellations_port, boost::bind(&adaptive_dfe_impl::update_constellations, this, _1)); set_msg_handler(constellations_port, boost::bind(&adaptive_dfe_impl::update_constellations, this, _1));
@ -128,6 +128,7 @@ adaptive_dfe_impl::general_work(int noutput_items,
gr_vector_void_star &output_items) gr_vector_void_star &output_items)
{ {
gr::thread::scoped_lock lock(d_setlock); gr::thread::scoped_lock lock(d_setlock);
//GR_LOG_DEBUG(d_logger, str(boost::format("work: %d") % noutput_items));
gr_complex const* in = (gr_complex const *)input_items[0]; gr_complex const* in = (gr_complex const *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0]; gr_complex *out = (gr_complex *)output_items[0];
@ -142,7 +143,7 @@ adaptive_dfe_impl::general_work(int noutput_items,
switch (_state) { switch (_state) {
case WAIT_FOR_PREAMBLE: { case WAIT_FOR_PREAMBLE: {
std::vector<tag_t> v; std::vector<tag_t> v;
get_tags_in_window(v, 0, history()-1, ninput, pmt::mp("preamble_start")); get_tags_in_window(v, 0, history()-1, ninput, pmt::intern("preamble_start"));
if (v.empty()) { if (v.empty()) {
consume(0, ninput - history()+1); consume(0, ninput - history()+1);
} else { } else {
@ -164,9 +165,10 @@ adaptive_dfe_impl::general_work(int noutput_items,
break; break;
} // WAIT_FOR_PREAMBLE } // WAIT_FOR_PREAMBLE
case WAIT_FOR_FRAME_INFO: { case WAIT_FOR_FRAME_INFO: {
//GR_LOG_DEBUG(d_logger, "WAIT_FOR_FRAME_INFO");
//update_frame_info(delete_head_blocking(_msg_ports["frame_info"])); //update_frame_info(delete_head_blocking(_msg_ports["frame_info"]));
break; break;
} // WAIT_FOR_MESSAGE } // WAIT_FOR_FRAME_INFO
case DO_FILTER: { case DO_FILTER: {
// std::cout << "========= offset (DO_FILTER) nitems_read(0)= " << nitems_read(0) << " ==========" << std::endl; // std::cout << "========= offset (DO_FILTER) nitems_read(0)= " << nitems_read(0) << " ==========" << std::endl;
int ninput_processed = 0; int ninput_processed = 0;
@ -315,7 +317,10 @@ void adaptive_dfe_impl::publish_frame_info()
{ {
pmt::pmt_t data = pmt::make_dict(); pmt::pmt_t data = pmt::make_dict();
GR_LOG_DEBUG(d_logger, str(boost::format("publish_frame_info %d == %d") % _descrambled_symbols.size() % _symbols.size())); GR_LOG_DEBUG(d_logger, str(boost::format("publish_frame_info %d == %d") % _descrambled_symbols.size() % _symbols.size()));
data = pmt::dict_add(data, pmt::mp("symbols"), pmt::init_c32vector(_descrambled_symbols.size(), &_descrambled_symbols.front())); data = pmt::dict_add(data, pmt::intern("symbols"), pmt::init_c32vector(_descrambled_symbols.size(), &_descrambled_symbols.front()));
// for (int i=0; i<_vec_soft_decisions.size(); ++i)
// _vec_soft_decisions[i] = std::max(-1.0f, std::min(1.0f, _vec_soft_decisions[i]));
data = pmt::dict_add(data, pmt::intern("soft_dec"), pmt::init_f32vector(_vec_soft_decisions.size(), &_vec_soft_decisions.front()));
message_port_pub(_msg_ports["frame_info"], data); message_port_pub(_msg_ports["frame_info"], data);
_descrambled_symbols.clear(); _descrambled_symbols.clear();
} }
@ -325,7 +330,7 @@ void adaptive_dfe_impl::publish_soft_dec()
if (_vec_soft_decisions.empty()) if (_vec_soft_decisions.empty())
return; return;
message_port_pub(_msg_ports["soft_dec"], message_port_pub(_msg_ports["soft_dec"],
pmt::cons(pmt::dict_add(_msg_metadata, pmt::mp("packet_len"), pmt::mp(_vec_soft_decisions.size())), pmt::cons(pmt::dict_add(_msg_metadata, pmt::intern("packet_len"), pmt::mp(_vec_soft_decisions.size())),
pmt::init_f32vector(_vec_soft_decisions.size(), _vec_soft_decisions))); pmt::init_f32vector(_vec_soft_decisions.size(), _vec_soft_decisions)));
_vec_soft_decisions.clear(); _vec_soft_decisions.clear();
} }
@ -341,11 +346,11 @@ void adaptive_dfe_impl::update_constellations(pmt::pmt_t data) {
for (int i=0; i<n; ++i) { for (int i=0; i<n; ++i) {
pmt::pmt_t c = pmt::vector_ref(data, i); pmt::pmt_t c = pmt::vector_ref(data, i);
int const idx = pmt::to_long(pmt::dict_ref(c, pmt::mp("idx"), pmt::from_long(-1))); int const idx = pmt::to_long(pmt::dict_ref(c, pmt::intern("idx"), pmt::from_long(-1)));
assert(idx>=0 && idx < n); assert(idx>=0 && idx < n);
_constellations[idx] = gr::digital::constellation_calcdist::make _constellations[idx] = gr::digital::constellation_calcdist::make
(pmt::c32vector_elements(pmt::dict_ref(c, pmt::mp("points"), pmt::PMT_NIL)), (pmt::c32vector_elements(pmt::dict_ref(c, pmt::intern("points"), pmt::PMT_NIL)),
pmt::s32vector_elements(pmt::dict_ref(c, pmt::mp("symbols"), pmt::PMT_NIL)), pmt::s32vector_elements(pmt::dict_ref(c, pmt::intern("symbols"), pmt::PMT_NIL)),
rotational_symmetry, dimensionality); rotational_symmetry, dimensionality);
_npwr[i].reset(_npwr_max_time_constant); _npwr[i].reset(_npwr_max_time_constant);
} }
@ -354,11 +359,11 @@ void adaptive_dfe_impl::update_constellations(pmt::pmt_t data) {
void adaptive_dfe_impl::update_frame_info(pmt::pmt_t data) void adaptive_dfe_impl::update_frame_info(pmt::pmt_t data)
{ {
//GR_LOG_DEBUG(d_logger,str(boost::format("adaptive_dfe_impl::update_frame_info() %s") % data)); //GR_LOG_DEBUG(d_logger,str(boost::format("adaptive_dfe_impl::update_frame_info() %s") % data));
_symbols = pmt::c32vector_elements(pmt::dict_ref(data, pmt::mp("symb"), pmt::PMT_NIL)); _symbols = pmt::c32vector_elements(pmt::dict_ref(data, pmt::intern("symb"), pmt::PMT_NIL));
_scramble = pmt::c32vector_elements(pmt::dict_ref(data, pmt::mp("scramble"), pmt::PMT_NIL)); _scramble = pmt::c32vector_elements(pmt::dict_ref(data, pmt::intern("scramble"), pmt::PMT_NIL));
_constellation_index = pmt::to_long(pmt::dict_ref(data, pmt::mp("constellation_idx"), pmt::PMT_NIL)); _constellation_index = pmt::to_long(pmt::dict_ref(data, pmt::intern("constellation_idx"), pmt::PMT_NIL));
_save_soft_decisions = pmt::to_bool(pmt::dict_ref(data, pmt::mp("save_soft_dec"), pmt::PMT_F)); _save_soft_decisions = pmt::to_bool(pmt::dict_ref(data, pmt::intern("save_soft_dec"), pmt::PMT_F));
bool const do_continue = pmt::to_bool(pmt::dict_ref(data, pmt::mp("do_continue"), pmt::PMT_F)); bool const do_continue = pmt::to_bool(pmt::dict_ref(data, pmt::intern("do_continue"), pmt::PMT_F));
assert(_symbols.size() == _scramble.size()); assert(_symbols.size() == _scramble.size());
_descrambled_symbols.resize(_symbols.size()); _descrambled_symbols.resize(_symbols.size());
_vec_soft_decisions.clear(); _vec_soft_decisions.clear();

View file

@ -51,44 +51,48 @@ doppler_correction_cc_impl::doppler_correction_cc_impl(unsigned int preamble_len
, _rotator() , _rotator()
, _state(WAIT_FOR_PHASE_EST_TAG) , _state(WAIT_FOR_PHASE_EST_TAG)
, _msg_metadata(pmt::make_dict()) , _msg_metadata(pmt::make_dict())
, _port_name(pmt::mp("doppler")) , _port_name(pmt::intern("doppler"))
, _phase_est(0) , _phase_est(0)
{ {
GR_LOG_DECLARE_LOGPTR(d_logger); GR_LOG_DECLARE_LOGPTR(d_logger);
GR_LOG_ASSIGN_LOGPTR(d_logger, "doppler_correction_cc"); GR_LOG_ASSIGN_LOGPTR(d_logger, "doppler_correction_cc");
message_port_register_out(_port_name); message_port_register_out(_port_name);
message_port_register_in (_port_name); message_port_register_in (_port_name);
// set_msg_handler(_port_name, boost::bind(&doppler_correction_cc_impl::handle_message, this, _1)); set_msg_handler(_port_name, boost::bind(&doppler_correction_cc_impl::handle_message, this, _1));
set_tag_propagation_policy(TPP_DONT); set_tag_propagation_policy(TPP_DONT);
set_output_multiple(2*_preamble_length); // without this the CPU usage goes up to 100%
} }
doppler_correction_cc_impl::~doppler_correction_cc_impl() doppler_correction_cc_impl::~doppler_correction_cc_impl()
{ {
} }
void
doppler_correction_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
{
ninput_items_required[0] = noutput_items + _preamble_length;
}
void void
doppler_correction_cc_impl::handle_message(pmt::pmt_t msg) doppler_correction_cc_impl::handle_message(pmt::pmt_t msg)
{ {
bool const success = pmt::to_bool(pmt::dict_ref(msg, pmt::mp("success"), pmt::get_PMT_F())); gr::thread::scoped_lock lock(d_setlock);
bool const success = pmt::to_bool(pmt::dict_ref(msg, pmt::intern("success"), pmt::get_PMT_F()));
if (!success) { if (!success) {
// GR_LOG_DEBUG(d_logger, "next state > CONSUME_AND_SKIP success=false"); // GR_LOG_DEBUG(d_logger, "next state > CONSUME_AND_SKIP success=false");
if (_state == WAIT_FOR_MSG)
_state = CONSUME_AND_SKIP; _state = CONSUME_AND_SKIP;
return; return;
} }
float const doppler = pmt::to_float(pmt::dict_ref(msg, pmt::mp("doppler"), pmt::from_float(0))); float const doppler = pmt::to_float(pmt::dict_ref(msg, pmt::intern("doppler"), pmt::from_float(0)));
_rotator.set_phase(gr_expj(-_phase_est + 0.5*doppler*_preamble_length_cc));
_rotator.set_phase_incr(gr_expj(-doppler)); _rotator.set_phase_incr(gr_expj(-doppler));
// GR_LOG_DEBUG(d_logger, str(boost::format("next state > CONSUME_AND_INSERT_PREAMBLE_TAG phase_est=%f doppler=%f") if (_state == WAIT_FOR_MSG) {
// % (_phase_est - 0.5*doppler*_preamble_length_cc) _rotator.set_phase(gr_expj(-_phase_est + 0.5*doppler*_preamble_length_cc));
// % doppler));
_state = CONSUME_AND_INSERT_PREAMBLE_TAG; _state = CONSUME_AND_INSERT_PREAMBLE_TAG;
GR_LOG_DEBUG(d_logger, str(boost::format("next state > CONSUME_AND_INSERT_PREAMBLE_TAG phase_est=%f doppler=%f")
% (_phase_est - 0.5*doppler*_preamble_length_cc)
% doppler));
}
}
void
doppler_correction_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
{
ninput_items_required[0] = _preamble_length + 1;
// GR_LOG_DEBUG(d_logger, str(boost::format("forecast: %d %d %d") % noutput_items % ninput_items_required[0] % _preamble_length));
} }
int int
@ -96,18 +100,18 @@ doppler_correction_cc_impl::work(int noutput_items,
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items) gr_vector_void_star &output_items)
{ {
gr::thread::scoped_lock lock(d_setlock);
gr_complex const* in = (gr_complex const*)input_items[0]; gr_complex const* in = (gr_complex const*)input_items[0];
gr_complex *out = (gr_complex *) output_items[0]; gr_complex *out = (gr_complex *) output_items[0];
// GR_LOG_DEBUG(d_logger, str(boost::format("work: %d %d") % noutput_items % _preamble_length));
// assert(noutput_items >= _preamble_length); if (noutput_items < _preamble_length)
noutput_items -= _preamble_length;
if (noutput_items < 0)
return 0; return 0;
noutput_items -= _preamble_length;
int nout = 0; int nout = 0;
switch (_state) { switch (_state) {
case WAIT_FOR_PHASE_EST_TAG: { case WAIT_FOR_PHASE_EST_TAG: {
std::vector<tag_t> v; std::vector<tag_t> v;
get_tags_in_window(v, 0, 0, noutput_items, pmt::mp("phase_est")); get_tags_in_window(v, 0, 0, noutput_items, pmt::intern("phase_est"));
if (v.empty()) { if (v.empty()) {
nout = noutput_items; nout = noutput_items;
} else { } else {
@ -115,7 +119,7 @@ doppler_correction_cc_impl::work(int noutput_items,
uint64_t const offset = tag.offset - nitems_read(0); uint64_t const offset = tag.offset - nitems_read(0);
nout = offset; nout = offset;
_phase_est = pmt::to_double(tag.value); _phase_est = pmt::to_double(tag.value);
_msg_metadata = pmt::dict_add(_msg_metadata, pmt::mp("packet_len"), pmt::from_long(_preamble_length)); _msg_metadata = pmt::dict_add(_msg_metadata, pmt::intern("packet_len"), pmt::from_long(_preamble_length));
message_port_pub(_port_name, message_port_pub(_port_name,
pmt::cons(_msg_metadata, pmt::cons(_msg_metadata,
pmt::init_c32vector(_preamble_length, in+nout))); pmt::init_c32vector(_preamble_length, in+nout)));
@ -126,11 +130,11 @@ doppler_correction_cc_impl::work(int noutput_items,
} // WAIT_FOR_PHASE_EST_TAG } // WAIT_FOR_PHASE_EST_TAG
case WAIT_FOR_MSG: { case WAIT_FOR_MSG: {
// GR_LOG_DEBUG(d_logger, "WAIT_FOR_MSG"); // GR_LOG_DEBUG(d_logger, "WAIT_FOR_MSG");
handle_message(delete_head_blocking(_port_name)); // handle_message(delete_head_nowait(_port_name));
break; break;
} // WAIT_FOR_MSG } // WAIT_FOR_MSG
case CONSUME_AND_INSERT_PREAMBLE_TAG: { case CONSUME_AND_INSERT_PREAMBLE_TAG: {
add_item_tag(0, nitems_read(0), pmt::mp("preamble_start"), pmt::from_long(0)); add_item_tag(0, nitems_read(0), pmt::intern("preamble_start"), pmt::from_long(0));
nout = _preamble_length; nout = _preamble_length;
// GR_LOG_DEBUG(d_logger, str(boost::format("next state > WAIT_FOR_PHASE_EST_TAG %lld") % nitems_read(0))); // GR_LOG_DEBUG(d_logger, str(boost::format("next state > WAIT_FOR_PHASE_EST_TAG %lld") % nitems_read(0)));
_state = WAIT_FOR_PHASE_EST_TAG; _state = WAIT_FOR_PHASE_EST_TAG;

View file

@ -54,6 +54,7 @@ public:
int work(int noutput_items, int work(int noutput_items,
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items); gr_vector_void_star &output_items);
protected: protected:
void handle_message(pmt::pmt_t msg); void handle_message(pmt::pmt_t msg);

View file

@ -31,6 +31,6 @@ except ImportError:
pass pass
# import any pure python here # import any pure python here
from physical_layer_driver import physical_layer_driver from .physical_layer_driver import physical_layer_driver
from msg_proxy import msg_proxy from .msg_proxy import msg_proxy
# #

View file

@ -44,6 +44,9 @@ class msg_proxy(gr.basic_block):
self.message_port_register_out(self._port_frame_info) self.message_port_register_out(self._port_frame_info)
self.set_msg_handler(self._port_frame_info, self.msg_handler_frame) self.set_msg_handler(self._port_frame_info, self.msg_handler_frame)
self._port_soft_dec = pmt.intern("soft_dec")
self.message_port_register_out(self._port_soft_dec)
def msg_handler_doppler(self, msg_in): def msg_handler_doppler(self, msg_in):
## print('-------------------- msg_handler_doppler --------------------') ## print('-------------------- msg_handler_doppler --------------------')
iq_samples = pmt.to_python(pmt.cdr(msg_in)) iq_samples = pmt.to_python(pmt.cdr(msg_in))
@ -58,7 +61,18 @@ class msg_proxy(gr.basic_block):
## print('-------------------- msg_handler_frame --------------------') ## print('-------------------- msg_handler_frame --------------------')
## print(msg_in) ## print(msg_in)
symbols = pmt.to_python(pmt.dict_ref(msg_in, pmt.intern('symbols'), pmt.PMT_NIL)) symbols = pmt.to_python(pmt.dict_ref(msg_in, pmt.intern('symbols'), pmt.PMT_NIL))
soft_dec = pmt.to_python(pmt.dict_ref(msg_in, pmt.intern('soft_dec'), pmt.PMT_NIL))
symb,constellation_idx,do_continue,save_soft_dec = self._obj.get_next_frame(symbols) symb,constellation_idx,do_continue,save_soft_dec = self._obj.get_next_frame(symbols)
if do_continue and len(soft_dec) != 0:
d = self._obj.decode_soft_dec(soft_dec)
msg_out = pmt.make_dict()
msg_out = pmt.dict_add(msg_out, pmt.intern('packet_len'), pmt.to_pmt(len(d)))
d = np.array(d, dtype=np.float32)
d[abs(d)==np.Inf] = 0
vv = pmt.to_pmt(d)
msg = pmt.cons(msg_out, vv)
self.message_port_pub(self._port_soft_dec, msg)
## TODO: publish the bits if success
##print('symb=', symb, symb['symb'], symb['scramble']) ##print('symb=', symb, symb['symb'], symb['scramble'])
msg_out = pmt.make_dict() msg_out = pmt.make_dict()
msg_out = pmt.dict_add(msg_out, pmt.intern('symb'), pmt.to_pmt(symb['symb'])) msg_out = pmt.dict_add(msg_out, pmt.intern('symb'), pmt.to_pmt(symb['symb']))

View file

@ -2,17 +2,17 @@
from __future__ import print_function from __future__ import print_function
import numpy as np import numpy as np
from common import * import common
## ---- Walsh-4 codes ----------------------------------------------------------- ## ---- Walsh-4 codes -----------------------------------------------------------
WALSH = np.array([[0,0,0,0, 0,0,0,0], WALSH = np.array([[0,0,0,0, 0,0,0,0], # 0 - 000
[0,1,0,1, 0,1,0,1], [0,1,0,1, 0,1,0,1], # 1 - 001
[0,0,1,1, 0,0,1,1], [0,0,1,1, 0,0,1,1], # 2 - 010
[0,1,1,0, 0,1,1,0], [0,1,1,0, 0,1,1,0], # 3 - 011
[0,0,0,0, 1,1,1,1], [0,0,0,0, 1,1,1,1], # 4 - 100
[0,1,0,1, 1,0,1,0], [0,1,0,1, 1,0,1,0], # 5 - 010
[0,0,1,1, 1,1,0,0], [0,0,1,1, 1,1,0,0], # 6 - 011
[0,1,1,0, 1,0,0,1]], [0,1,1,0, 1,0,0,1]], # 7 - 111
dtype=np.uint8) dtype=np.uint8)
FROM_WALSH = -np.ones(256, dtype=np.int8) FROM_WALSH = -np.ones(256, dtype=np.int8)
@ -31,12 +31,12 @@ TRIBIT_SCRAMBLE = np.array(
## ---- preamble symbols --------------------------------------------------------- ## ---- preamble symbols ---------------------------------------------------------
D1=D2=C1=C2=C3=0 ## not known D1=D2=C1=C2=C3=0 ## not known
PRE_SYMBOLS = n_psk(2, np.concatenate( PRE_SYMBOLS = common.n_psk(2, np.concatenate(
[TRIBIT[i][:] for i in [0,1,3,0,1,3,1,2,0,D1,D2,C1,C2,C3,0]])) [TRIBIT[i][:] for i in [0,1,3,0,1,3,1,2,0,D1,D2,C1,C2,C3,0]]))
PRE_SYMBOLS[9*32:14*32] = 0 PRE_SYMBOLS[9*32:14*32] = 0
## ---- preamble scramble symbols ------------------------------------------------ ## ---- preamble scramble symbols ------------------------------------------------
PRE_SCRAMBLE = n_psk(8, np.concatenate([TRIBIT_SCRAMBLE for _ in range(15)])) PRE_SCRAMBLE = common.n_psk(8, np.concatenate([TRIBIT_SCRAMBLE for _ in range(15)]))
## ---- data scrambler ----------------------------------------------------------- ## ---- data scrambler -----------------------------------------------------------
class ScrambleData(object): class ScrambleData(object):
@ -64,9 +64,9 @@ class ScrambleData(object):
return self._state return self._state
## ---- constellatios ----------------------------------------------------------- ## ---- constellatios -----------------------------------------------------------
BPSK=np.array(zip(np.exp(2j*np.pi*np.arange(2)/2), [0,1]), CONST_DTYPE) BPSK=np.array(zip(np.exp(2j*np.pi*np.arange(2)/2), [0,1]), common.CONST_DTYPE)
QPSK=np.array(zip(np.exp(2j*np.pi*np.arange(4)/4), [0,1,3,2]), CONST_DTYPE) QPSK=np.array(zip(np.exp(2j*np.pi*np.arange(4)/4), [0,1,3,2]), common.CONST_DTYPE)
PSK8=np.array(zip(np.exp(2j*np.pi*np.arange(8)/8), [0,1,3,2,7,6,4,5]), CONST_DTYPE) PSK8=np.array(zip(np.exp(2j*np.pi*np.arange(8)/8), [0,1,3,2,7,6,4,5]), common.CONST_DTYPE)
## ---- constellation indices --------------------------------------------------- ## ---- constellation indices ---------------------------------------------------
MODE_BPSK=0 MODE_BPSK=0
@ -96,6 +96,41 @@ MODE[5][4] = {'bit_rate': 150, 'ci':MODE_BPSK, 'interleaver':['L', 40,144], 'unk
MODE[7][5] = {'bit_rate': 75, 'ci':MODE_QPSK, 'interleaver':['S', 10, 9], 'unknown':-1,'known': 0, 'nsymb':32, 'coding_rate':1./2} MODE[7][5] = {'bit_rate': 75, 'ci':MODE_QPSK, 'interleaver':['S', 10, 9], 'unknown':-1,'known': 0, 'nsymb':32, 'coding_rate':1./2}
MODE[5][4] = {'bit_rate': 75, 'ci':MODE_QPSK, 'interleaver':['L', 20, 36], 'unknown':-1,'known': 0, 'nsymb':32, 'coding_rate':1./2} MODE[5][4] = {'bit_rate': 75, 'ci':MODE_QPSK, 'interleaver':['L', 20, 36], 'unknown':-1,'known': 0, 'nsymb':32, 'coding_rate':1./2}
## ---- deinterleaver -----------------------------------------------------------
class Deinterleaver(object):
"""deinterleave"""
def __init__(self, rows, cols):
self._a = np.zeros((rows, cols), dtype=np.float32)
self._i = 0
self._j = 0
self._di = 9 if rows==40 else 7
self._dj = -17 if rows==40 else -7
self._buffer = np.zeros(0, dtype=np.float32)
print('deinterleaver: ', rows, cols, self._di, self._dj)
def fetch(self, a):
pass
def load(self, a):
self._buffer = np.append(self._buffer, a)
print('interleaver load', self._a.shape, a.shape, self._buffer.shape)
if self._buffer.shape[0] < self._a.shape[0]:
return np.zeros(0, dtype=np.float32)
print('interleaver load buffer:', len(self._buffer),self._i,self._j)
i = np.arange(self._a.shape[0])
j = (self._j + self._dj*np.arange(self._a.shape[0])) % self._a.shape[1]
self._a[i,j] = self._buffer[0:self._a.shape[0]]
self._buffer = np.delete(self._buffer, i)
self._j += 1
print('interleaver load buffer:', len(self._buffer),self._i,self._j)
if self._j == self._a.shape[1]:
self._j = 0
print('==================== interleaver is full! ====================')
return np.concatenate([self._a[(self._di*i)%self._a.shape[0],j] for j in range(self._a.shape[1])])
else:
return np.zeros(0, dtype=np.float32)
## ---- physcal layer class ----------------------------------------------------- ## ---- physcal layer class -----------------------------------------------------
class PhysicalLayer(object): class PhysicalLayer(object):
"""Physical layer description for MIL-STD-188-110 Appendix A""" """Physical layer description for MIL-STD-188-110 Appendix A"""
@ -145,7 +180,7 @@ class PhysicalLayer(object):
def get_next_data_frame(self, success): def get_next_data_frame(self, success):
if self._frame_counter == self._num_frames_per_block: if self._frame_counter == self._num_frames_per_block:
self._frame_counter = 0 self._frame_counter = 0
scramble_for_frame = n_psk(8, np.array([self._scr_data.next() scramble_for_frame = common.n_psk(8, np.array([self._scr_data.next()
for _ in range(self._frame_len)])) for _ in range(self._frame_len)]))
a = np.array(zip(scramble_for_frame, a = np.array(zip(scramble_for_frame,
scramble_for_frame), scramble_for_frame),
@ -155,8 +190,8 @@ class PhysicalLayer(object):
a['symb'][0:n_unknown] = 0 a['symb'][0:n_unknown] = 0
if self._frame_counter >= self._num_frames_per_block-2: if self._frame_counter >= self._num_frames_per_block-2:
idx_d1d2 = self._frame_counter - self._num_frames_per_block + 2; idx_d1d2 = self._frame_counter - self._num_frames_per_block + 2;
a['symb'][n_unknown :n_unknown+ 8] *= n_psk(2, WALSH[self._d1d2[idx_d1d2]][:]) a['symb'][n_unknown :n_unknown+ 8] *= common.n_psk(2, WALSH[self._d1d2[idx_d1d2]][:])
a['symb'][n_unknown+8:n_unknown+16] *= n_psk(2, WALSH[self._d1d2[idx_d1d2]][:]) a['symb'][n_unknown+8:n_unknown+16] *= common.n_psk(2, WALSH[self._d1d2[idx_d1d2]][:])
if not success: if not success:
self._frame_counter = -1 self._frame_counter = -1
self._pre_counter = -1 self._pre_counter = -1
@ -183,7 +218,7 @@ class PhysicalLayer(object):
pks = [np.correlate(iq_samples[imax+i*32*sps+idx], pks = [np.correlate(iq_samples[imax+i*32*sps+idx],
zp[ i*32*sps+idx])[0] zp[ i*32*sps+idx])[0]
for i in range(9)] for i in range(9)]
doppler = freq_est(pks)/(32*sps) doppler = common.freq_est(pks)/(32*sps)
print('success=', success, 'doppler=', doppler, print('success=', success, 'doppler=', doppler,
np.abs(np.array(pks)), np.abs(np.array(pks)),
np.angle(np.array(pks))) np.angle(np.array(pks)))
@ -202,11 +237,22 @@ class PhysicalLayer(object):
self._block_len = 11520 if self._mode['interleaver'][0] == 'L' else 1440 self._block_len = 11520 if self._mode['interleaver'][0] == 'L' else 1440
self._frame_len = self._mode['known'] + self._mode['unknown'] self._frame_len = self._mode['known'] + self._mode['unknown']
self._num_frames_per_block = self._block_len/self._frame_len; self._num_frames_per_block = self._block_len/self._frame_len;
self._deinterleaver = Deinterleaver(self._mode['interleaver'][1], self._mode['interleaver'][2])
print(self._d1d2, self._mode, self._frame_len)
return True return True
def set_mode(self, _): def set_mode(self, _):
pass pass
def decode_soft_dec(self, soft_dec):
print('decode_soft_dec', len(soft_dec), soft_dec.dtype)
r = self._deinterleaver.load(soft_dec)
print('decode_soft_dec r=', r.shape)
if r.shape[0] != 0:
for i in range(r.shape[0]//4):
print('BB:', r[4*i]<0, r[4*i+2]<0, '|', r[4*i+1]<0, r[4*i+3]<0)
return soft_dec ## TODO
@staticmethod @staticmethod
def get_preamble(): def get_preamble():
"""preamble symbols + scrambler""" """preamble symbols + scrambler"""

View file

@ -156,14 +156,14 @@ class PhysicalLayer(object):
self._frame_counter += 1 self._frame_counter += 1
return [self._preamble,MODE_BPSK,success,False] return [self._preamble,MODE_BPSK,success,False]
frame_counter_mod = self._frame_counter%72 frame_counter_mod72 = self._frame_counter%72
if frame_counter_mod == 0: ## --- re-inserted preamble if frame_counter_mod72 == 0: ## --- re-inserted preamble
self._frame_counter += 1 self._frame_counter += 1
success = self.get_preamble_quality(symbols) success = self.get_preamble_quality(symbols)
return [self.make_reinserted_preamble(self._preamble_offset,success),MODE_QPSK,success,False] return [self.make_reinserted_preamble(self._preamble_offset,success),MODE_QPSK,success,False]
if frame_counter_mod >= 1: ## ---- data frames if frame_counter_mod72 >= 1: ## ---- data frames
got_reinserted_preamble = frame_counter_mod == 1 got_reinserted_preamble = frame_counter_mod72 == 1
self._frame_counter += 1 self._frame_counter += 1
if got_reinserted_preamble: if got_reinserted_preamble:
success = self.decode_reinserted_preamble(symbols) success = self.decode_reinserted_preamble(symbols)
@ -176,21 +176,29 @@ class PhysicalLayer(object):
success,doppler = True,0 success,doppler = True,0
if len(iq_samples) != 0: if len(iq_samples) != 0:
sps = self._sps sps = self._sps
idx = np.arange(23*sps) m = 23*sps
idx = np.arange(m)
idx2 = np.arange(m+23*sps)
_,zp = self.get_preamble_z() _,zp = self.get_preamble_z()
cc = np.correlate(iq_samples, zp[idx]) n = len(zp)
cc = np.correlate(iq_samples, zp)
imax = np.argmax(np.abs(cc[0:23*sps])) imax = np.argmax(np.abs(cc[0:23*sps]))
pks = [np.correlate(iq_samples[imax+i*23*sps+idx], print('imax=', imax, len(iq_samples))
zp[i*23*sps+idx])[0] pks = [np.correlate(iq_samples[imax+i*m+idx],
for i in range(8)] zp[i*m+idx])[0]
success = np.mean(np.abs(pks)) > 2*np.mean(np.abs(cc[imax+11*sps+range(-sps,sps)])) for i in range(n//m)]
print('test:',imax, np.mean(np.abs(pks)), np.mean(np.abs(cc[imax+11*sps+range(-sps,sps)]))) val = [np.mean(np.abs(np.correlate(iq_samples[imax+i*m+idx2],
zp[i*m+idx])[11*sps+np.arange(-2*sps,2*sps)]))
for i in range((n//m)-1)]
tests = np.abs(pks[0:-1])/val
success = np.median(tests) > 2.0
print('test:', np.abs(pks), tests)
if success: if success:
print('doppler apks', np.abs(pks)) print('doppler apks', np.abs(pks))
print('doppler ppks', np.angle(pks), print('doppler ppks', np.angle(pks),
np.diff(np.unwrap(np.angle(pks)))/23, np.diff(np.unwrap(np.angle(pks)))/m,
np.mean(np.diff(np.unwrap(np.angle(pks)))/23)) np.mean(np.diff(np.unwrap(np.angle(pks)))/m))
doppler = freq_est(pks)/(23*sps); doppler = freq_est(pks)/m;
print('success=', success, 'doppler=', doppler) print('success=', success, 'doppler=', doppler)
return success,doppler return success,doppler
@ -238,12 +246,12 @@ class PhysicalLayer(object):
('scramble', np.complex64)]) ('scramble', np.complex64)])
a['symb'][-72:-72+3*13] = 0 ## D0,D1,D2 a['symb'][-72:-72+3*13] = 0 ## D0,D1,D2
if not success: if not success:
sefl._frame_counter = -1 self._frame_counter = -1
return a return a
def make_data_frame(self, success): def make_data_frame(self, success):
self._preamble_offset = -72 ## all following reinserted preambles start at index -72 self._preamble_offset = -72 ## all following reinserted preambles start at index -72
a=np.zeros(256+31, dtype=[('symb', np.complex64), a = np.zeros(256+31, dtype=[('symb', np.complex64),
('scramble', np.complex64)]) ('scramble', np.complex64)])
a['scramble'][:256] = self._data_scramble a['scramble'][:256] = self._data_scramble
n = (self._frame_counter-2)%72 n = (self._frame_counter-2)%72
@ -258,6 +266,9 @@ class PhysicalLayer(object):
self._frame_counter = -1 self._frame_counter = -1
return a return a
def decode_soft_dec(self, soft_dec):
return soft_dec
@staticmethod @staticmethod
def get_preamble(): def get_preamble():
"""preamble symbols + scrambler""" """preamble symbols + scrambler"""

View file

@ -2,6 +2,22 @@
import numpy as np import numpy as np
class Deinterleaver(object):
"S4285 deinterleaver"
def __init__(self, incr):
## incr = 12 -> L
## incr = 1 -> S
self._buf = [np.zeros(incr*(31-i) + 1) for i in range(32)]
def push(self, a):
assert(len(a) == 32)
for i in range(32):
self._buf[i][0] = a[i]
self._buf[i] = np.roll(self._buf[i],1)
def fetch(self):
return np.array([self._buf[(9*i)%32][0] for i in range(32)])
class PhysicalLayer(object): class PhysicalLayer(object):
"""Physical layer description for STANAG 4285""" """Physical layer description for STANAG 4285"""
@ -20,6 +36,7 @@ class PhysicalLayer(object):
self.make_psk(8, [1,0,2,3,6,7,5,4])] self.make_psk(8, [1,0,2,3,6,7,5,4])]
self._preamble = self.get_preamble() self._preamble = self.get_preamble()
self._data = self.get_data() self._data = self.get_data()
self._deinterleaver = Deinterleaver(12) ## for now BPSK L fixed
def set_mode(self, mode): def set_mode(self, mode):
"""set phase modultation type""" """set phase modultation type"""
@ -88,6 +105,15 @@ class PhysicalLayer(object):
a = PhysicalLayer.get_preamble() a = PhysicalLayer.get_preamble()
return 2,np.array([z for z in a['symb'][0:31] for _ in range(self._sps)]) return 2,np.array([z for z in a['symb'][0:31] for _ in range(self._sps)])
def decode_soft_dec(self, soft_dec):
assert(len(soft_dec) == 128)
print('decode_soft_dec: ', len(soft_dec))
res = []
for i in range(0,128,32):
self._deinterleaver.push(soft_dec[i:i+32])
res.extend(self._deinterleaver.fetch().tolist())
return res
@staticmethod @staticmethod
def get_preamble(): def get_preamble():
"""preamble symbols + scrambler(=1)""" """preamble symbols + scrambler(=1)"""

View file

@ -54,7 +54,11 @@ class physical_layer_driver(gr.hier_block2):
preamble_offset,preamble_samples = self._physical_layer_driver_description.get_preamble_z() preamble_offset,preamble_samples = self._physical_layer_driver_description.get_preamble_z()
preamble_length = sps*len(self._physical_layer_driver_description.get_preamble()) preamble_length = sps*len(self._physical_layer_driver_description.get_preamble())
self._rrc_filter = filter.fir_filter_ccc(1, (self._rrc_taps)) self._rrc_filter = filter.fir_filter_ccc(1, (self._rrc_taps))
self._corr_est = digital.corr_est_cc((preamble_samples.tolist()), sps, preamble_offset, 0.5) self._corr_est = digital.corr_est_cc(symbols = (preamble_samples.tolist()),
sps = sps,
mark_delay = preamble_offset,
threshold = 0.5,
threshold_method = 1)
self._doppler_correction = digitalhf.doppler_correction_cc(preamble_length, len(preamble_samples)) self._doppler_correction = digitalhf.doppler_correction_cc(preamble_length, len(preamble_samples))
self._adaptive_filter = digitalhf.adaptive_dfe(sps, nB, nF, nW, mu, alpha) self._adaptive_filter = digitalhf.adaptive_dfe(sps, nB, nF, nW, mu, alpha)
self._msg_proxy = digitalhf.msg_proxy(self._physical_layer_driver_description) self._msg_proxy = digitalhf.msg_proxy(self._physical_layer_driver_description)
@ -80,6 +84,7 @@ class physical_layer_driver(gr.hier_block2):
self.message_port_register_hier_out('soft_dec') self.message_port_register_hier_out('soft_dec')
self.msg_connect((self._adaptive_filter, 'soft_dec'), (self, 'soft_dec')) self.msg_connect((self._adaptive_filter, 'soft_dec'), (self, 'soft_dec'))
self.msg_connect((self._msg_proxy, 'soft_dec'), (self, 'soft_dec'))
def set_mu(self, mu): def set_mu(self, mu):
self._adaptive_filter.set_mu(mu) self._adaptive_filter.set_mu(mu)