diff --git a/apps/flowgraphs/ax25_transceiver_qt.grc b/apps/flowgraphs/ax25_transceiver_qt.grc new file mode 100644 index 0000000..1fcc6f8 --- /dev/null +++ b/apps/flowgraphs/ax25_transceiver_qt.grc @@ -0,0 +1,4364 @@ + + + + Fri Jul 1 17:53:00 2016 + + options + + author + + + + window_size + 1768,1080 + + + category + Custom + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + fsk9600_ax25_transceiver_qt + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + thread_safe_setters + + + + title + + + + + variable + + comment + FSK baud rate + + + _enabled + True + + + _coordinate + (544, 5) + + + _rotation + 0 + + + id + baud_rate + + + value + 9600 + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1296, 1) + + + gui_hint + + + + _rotation + 0 + + + id + bb_gain_rx + + + label + BB Gain RX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 40 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1304, 137) + + + gui_hint + + + + _rotation + 0 + + + id + bb_gain_tx + + + label + BB Gain TX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 40 + + + rangeType + float + + + widget + counter_slider + + + + variable + + comment + Decimation factor +for the RX after the +SDR received samples + + + _enabled + True + + + _coordinate + (664, 109) + + + _rotation + 0 + + + id + decimation_rx + + + value + 40 + + + + variable + + comment + The FSK frequency deviation + + + _enabled + True + + + _coordinate + (368, 5) + + + _rotation + 0 + + + id + deviation + + + value + 3.9973e3 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 325) + + + _rotation + 0 + + + id + gaussian_taps + + + value + filter.firdes.gaussian(1.0, samples_per_symbol_tx, 1.0, 4*samples_per_symbol_tx) + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1192, 1) + + + gui_hint + + + + _rotation + 0 + + + id + if_gain_rx + + + label + IF Gain RX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 40 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1192, 137) + + + gui_hint + + + + _rotation + 0 + + + id + if_gain_tx + + + label + IF Gain TX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 40 + + + rangeType + float + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (8, 453) + + + _rotation + 0 + + + id + interp_taps + + + value + numpy.convolve(numpy.array(gaussian_taps), numpy.array(sq_wave)) + + + + variable + + comment + To avoid the SDR carrier at the DC +we shift the LO a little further + + + _enabled + 1 + + + _coordinate + (784, 5) + + + _rotation + 0 + + + id + lo_offset + + + value + 100e3 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 253) + + + _rotation + 0 + + + id + modulation_index + + + value + deviation / (baud_rate / 2.0) + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1080, 1) + + + gui_hint + + + + _rotation + 0 + + + id + rf_gain_rx + + + label + RF Gain RX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 40 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (1080, 137) + + + gui_hint + + + + _rotation + 0 + + + id + rf_gain_tx + + + label + RF Gain TX + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.5 + + + stop + 70 + + + rangeType + float + + + widget + counter_slider + + + + variable + + comment + The RX center frequency + of the system + + + _enabled + True + + + _coordinate + (808, 109) + + + _rotation + 0 + + + id + rx_frequency + + + value + 435.8e6 + + + + variable + + comment + SDR device +TX sampling rate + + + _enabled + True + + + _coordinate + (528, 109) + + + _rotation + 0 + + + id + samp_rate_rx + + + value + 1e6 + + + + variable + + comment + SDR device +TX sampling rate + + + _enabled + True + + + _coordinate + (248, 5) + + + _rotation + 0 + + + id + samp_rate_tx + + + value + 2e6 + + + + variable + + comment + Samples per FSK symbol. +Should be changed only for better +spectrum mask, or if the resampling +is too great and becomes a bottlneck. + + + _enabled + True + + + _coordinate + (8, 109) + + + _rotation + 0 + + + id + samples_per_symbol_tx + + + value + 4*8 + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (8, 389) + + + _rotation + 0 + + + id + sq_wave + + + value + (1.0, ) * samples_per_symbol_tx + + + + variable_low_pass_filter_taps + + beta + 6.76 + + + comment + + + + cutoff_freq + 20000 + + + _enabled + 1 + + + _coordinate + (16, 762) + + + _rotation + 0 + + + gain + 1.0 + + + id + taps + + + samp_rate + samp_rate_rx + + + width + 60000 + + + win + firdes.WIN_HAMMING + + + + variable + + comment + The TX center frequency + of the system + + + _enabled + True + + + _coordinate + (648, 5) + + + _rotation + 0 + + + id + tx_frequency + + + value + 435.8e6 + + + + analog_frequency_modulator_fc + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1208, 308) + + + _rotation + 0 + + + id + analog_frequency_modulator_fc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + sensitivity + (math.pi*modulation_index) / samples_per_symbol_tx + + + + analog_quadrature_demod_cf + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (528, 644) + + + _rotation + 0 + + + gain + ((samp_rate_rx/decimation_rx) / baud_rate)/(math.pi*modulation_index) + + + id + analog_quadrature_demod_cf_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + analog_sig_source_x + + amp + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + freq + lo_offset + + + _coordinate + (1056, 368) + + + _rotation + 180 + + + id + analog_sig_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + offset + 0 + + + type + complex + + + samp_rate + samp_rate_tx + + + waveform + analog.GR_COS_WAVE + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (808, 308) + + + _rotation + 0 + + + id + blocks_char_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_multiply_xx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (896, 448) + + + _rotation + 180 + + + id + blocks_multiply_xx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + digital_binary_slicer_fb + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1024, 648) + + + _rotation + 0 + + + id + digital_binary_slicer_fb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_clock_recovery_mm_xx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (776, 616) + + + _rotation + 0 + + + gain_mu + 0.175 + + + gain_omega + 0.25*0.175*0.175 + + + id + digital_clock_recovery_mm_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + mu + 0.5 + + + omega_relative_limit + 0.005 + + + omega + (samp_rate_rx/decimation_rx)/baud_rate + + + type + float + + + + digital_map_bb + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (688, 308) + + + _rotation + 0 + + + id + digital_map_bb_0 + + + map + [1, -1] + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + freq_xlating_fir_filter_xxx + + alias + + + + center_freq + lo_offset + + + comment + + + + affinity + + + + decim + decimation_rx + + + _enabled + 1 + + + _coordinate + (304, 623) + + + _rotation + 0 + + + id + freq_xlating_fir_filter_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate_rx + + + taps + taps + + + type + ccc + + + + import + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (1472, 60) + + + _rotation + 0 + + + id + import_0 + + + import + import numpy + + + + import + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (1480, 4) + + + _rotation + 0 + + + id + import_0_0 + + + import + import math + + + + import + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (1480, 108) + + + _rotation + 0 + + + id + import_0_1 + + + import + from gnuradio import filter + + + + interp_fir_filter_xxx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (984, 301) + + + _rotation + 0 + + + id + interp_fir_filter_xxx_0 + + + interp + samples_per_symbol_tx + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_delay + 0 + + + taps + interp_taps + + + type + fff + + + + osmosdr_sink + + alias + + + + ant0 + + + + bb_gain0 + bb_gain_tx + + + bw0 + samp_rate_tx + + + corr0 + 0 + + + freq0 + tx_frequency - lo_offset + + + if_gain0 + if_gain_tx + + + gain0 + rf_gain_tx + + + ant10 + + + + bb_gain10 + 20 + + + bw10 + 0 + + + corr10 + 0 + + + freq10 + 100e6 + + + if_gain10 + 20 + + + gain10 + 10 + + + ant11 + + + + bb_gain11 + 20 + + + bw11 + 0 + + + corr11 + 0 + + + freq11 + 100e6 + + + if_gain11 + 20 + + + gain11 + 10 + + + ant12 + + + + bb_gain12 + 20 + + + bw12 + 0 + + + corr12 + 0 + + + freq12 + 100e6 + + + if_gain12 + 20 + + + gain12 + 10 + + + ant13 + + + + bb_gain13 + 20 + + + bw13 + 0 + + + corr13 + 0 + + + freq13 + 100e6 + + + if_gain13 + 20 + + + gain13 + 10 + + + ant14 + + + + bb_gain14 + 20 + + + bw14 + 0 + + + corr14 + 0 + + + freq14 + 100e6 + + + if_gain14 + 20 + + + gain14 + 10 + + + ant15 + + + + bb_gain15 + 20 + + + bw15 + 0 + + + corr15 + 0 + + + freq15 + 100e6 + + + if_gain15 + 20 + + + gain15 + 10 + + + ant16 + + + + bb_gain16 + 20 + + + bw16 + 0 + + + corr16 + 0 + + + freq16 + 100e6 + + + if_gain16 + 20 + + + gain16 + 10 + + + ant17 + + + + bb_gain17 + 20 + + + bw17 + 0 + + + corr17 + 0 + + + freq17 + 100e6 + + + if_gain17 + 20 + + + gain17 + 10 + + + ant18 + + + + bb_gain18 + 20 + + + bw18 + 0 + + + corr18 + 0 + + + freq18 + 100e6 + + + if_gain18 + 20 + + + gain18 + 10 + + + ant19 + + + + bb_gain19 + 20 + + + bw19 + 0 + + + corr19 + 0 + + + freq19 + 100e6 + + + if_gain19 + 20 + + + gain19 + 10 + + + ant1 + + + + bb_gain1 + 20 + + + bw1 + 0 + + + corr1 + 0 + + + freq1 + 100e6 + + + if_gain1 + 20 + + + gain1 + 10 + + + ant20 + + + + bb_gain20 + 20 + + + bw20 + 0 + + + corr20 + 0 + + + freq20 + 100e6 + + + if_gain20 + 20 + + + gain20 + 10 + + + ant21 + + + + bb_gain21 + 20 + + + bw21 + 0 + + + corr21 + 0 + + + freq21 + 100e6 + + + if_gain21 + 20 + + + gain21 + 10 + + + ant22 + + + + bb_gain22 + 20 + + + bw22 + 0 + + + corr22 + 0 + + + freq22 + 100e6 + + + if_gain22 + 20 + + + gain22 + 10 + + + ant23 + + + + bb_gain23 + 20 + + + bw23 + 0 + + + corr23 + 0 + + + freq23 + 100e6 + + + if_gain23 + 20 + + + gain23 + 10 + + + ant24 + + + + bb_gain24 + 20 + + + bw24 + 0 + + + corr24 + 0 + + + freq24 + 100e6 + + + if_gain24 + 20 + + + gain24 + 10 + + + ant25 + + + + bb_gain25 + 20 + + + bw25 + 0 + + + corr25 + 0 + + + freq25 + 100e6 + + + if_gain25 + 20 + + + gain25 + 10 + + + ant26 + + + + bb_gain26 + 20 + + + bw26 + 0 + + + corr26 + 0 + + + freq26 + 100e6 + + + if_gain26 + 20 + + + gain26 + 10 + + + ant27 + + + + bb_gain27 + 20 + + + bw27 + 0 + + + corr27 + 0 + + + freq27 + 100e6 + + + if_gain27 + 20 + + + gain27 + 10 + + + ant28 + + + + bb_gain28 + 20 + + + bw28 + 0 + + + corr28 + 0 + + + freq28 + 100e6 + + + if_gain28 + 20 + + + gain28 + 10 + + + ant29 + + + + bb_gain29 + 20 + + + bw29 + 0 + + + corr29 + 0 + + + freq29 + 100e6 + + + if_gain29 + 20 + + + gain29 + 10 + + + ant2 + + + + bb_gain2 + 20 + + + bw2 + 0 + + + corr2 + 0 + + + freq2 + 100e6 + + + if_gain2 + 20 + + + gain2 + 10 + + + ant30 + + + + bb_gain30 + 20 + + + bw30 + 0 + + + corr30 + 0 + + + freq30 + 100e6 + + + if_gain30 + 20 + + + gain30 + 10 + + + ant31 + + + + bb_gain31 + 20 + + + bw31 + 0 + + + corr31 + 0 + + + freq31 + 100e6 + + + if_gain31 + 20 + + + gain31 + 10 + + + ant3 + + + + bb_gain3 + 20 + + + bw3 + 0 + + + corr3 + 0 + + + freq3 + 100e6 + + + if_gain3 + 20 + + + gain3 + 10 + + + ant4 + + + + bb_gain4 + 20 + + + bw4 + 0 + + + corr4 + 0 + + + freq4 + 100e6 + + + if_gain4 + 20 + + + gain4 + 10 + + + ant5 + + + + bb_gain5 + 20 + + + bw5 + 0 + + + corr5 + 0 + + + freq5 + 100e6 + + + if_gain5 + 20 + + + gain5 + 10 + + + ant6 + + + + bb_gain6 + 20 + + + bw6 + 0 + + + corr6 + 0 + + + freq6 + 100e6 + + + if_gain6 + 20 + + + gain6 + 10 + + + ant7 + + + + bb_gain7 + 20 + + + bw7 + 0 + + + corr7 + 0 + + + freq7 + 100e6 + + + if_gain7 + 20 + + + gain7 + 10 + + + ant8 + + + + bb_gain8 + 20 + + + bw8 + 0 + + + corr8 + 0 + + + freq8 + 100e6 + + + if_gain8 + 20 + + + gain8 + 10 + + + ant9 + + + + bb_gain9 + 20 + + + bw9 + 0 + + + corr9 + 0 + + + freq9 + 100e6 + + + if_gain9 + 20 + + + gain9 + 10 + + + comment + + + + affinity + + + + args + + + + _enabled + 1 + + + _coordinate + (504, 418) + + + _rotation + 180 + + + id + osmosdr_sink_0 + + + type + fc32 + + + clock_source0 + + + + time_source0 + + + + clock_source1 + + + + time_source1 + + + + clock_source2 + + + + time_source2 + + + + clock_source3 + + + + time_source3 + + + + clock_source4 + + + + time_source4 + + + + clock_source5 + + + + time_source5 + + + + clock_source6 + + + + time_source6 + + + + clock_source7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + sample_rate + samp_rate_tx + + + sync + + + + + osmosdr_source + + alias + + + + ant0 + + + + bb_gain0 + bb_gain_rx + + + bw0 + samp_rate_rx + + + dc_offset_mode0 + 0 + + + corr0 + 0 + + + freq0 + rx_frequency - lo_offset + + + gain_mode0 + False + + + if_gain0 + if_gain_rx + + + iq_balance_mode0 + 0 + + + gain0 + rf_gain_rx + + + ant10 + + + + bb_gain10 + 20 + + + bw10 + 0 + + + dc_offset_mode10 + 0 + + + corr10 + 0 + + + freq10 + 100e6 + + + gain_mode10 + False + + + if_gain10 + 20 + + + iq_balance_mode10 + 0 + + + gain10 + 10 + + + ant11 + + + + bb_gain11 + 20 + + + bw11 + 0 + + + dc_offset_mode11 + 0 + + + corr11 + 0 + + + freq11 + 100e6 + + + gain_mode11 + False + + + if_gain11 + 20 + + + iq_balance_mode11 + 0 + + + gain11 + 10 + + + ant12 + + + + bb_gain12 + 20 + + + bw12 + 0 + + + dc_offset_mode12 + 0 + + + corr12 + 0 + + + freq12 + 100e6 + + + gain_mode12 + False + + + if_gain12 + 20 + + + iq_balance_mode12 + 0 + + + gain12 + 10 + + + ant13 + + + + bb_gain13 + 20 + + + bw13 + 0 + + + dc_offset_mode13 + 0 + + + corr13 + 0 + + + freq13 + 100e6 + + + gain_mode13 + False + + + if_gain13 + 20 + + + iq_balance_mode13 + 0 + + + gain13 + 10 + + + ant14 + + + + bb_gain14 + 20 + + + bw14 + 0 + + + dc_offset_mode14 + 0 + + + corr14 + 0 + + + freq14 + 100e6 + + + gain_mode14 + False + + + if_gain14 + 20 + + + iq_balance_mode14 + 0 + + + gain14 + 10 + + + ant15 + + + + bb_gain15 + 20 + + + bw15 + 0 + + + dc_offset_mode15 + 0 + + + corr15 + 0 + + + freq15 + 100e6 + + + gain_mode15 + False + + + if_gain15 + 20 + + + iq_balance_mode15 + 0 + + + gain15 + 10 + + + ant16 + + + + bb_gain16 + 20 + + + bw16 + 0 + + + dc_offset_mode16 + 0 + + + corr16 + 0 + + + freq16 + 100e6 + + + gain_mode16 + False + + + if_gain16 + 20 + + + iq_balance_mode16 + 0 + + + gain16 + 10 + + + ant17 + + + + bb_gain17 + 20 + + + bw17 + 0 + + + dc_offset_mode17 + 0 + + + corr17 + 0 + + + freq17 + 100e6 + + + gain_mode17 + False + + + if_gain17 + 20 + + + iq_balance_mode17 + 0 + + + gain17 + 10 + + + ant18 + + + + bb_gain18 + 20 + + + bw18 + 0 + + + dc_offset_mode18 + 0 + + + corr18 + 0 + + + freq18 + 100e6 + + + gain_mode18 + False + + + if_gain18 + 20 + + + iq_balance_mode18 + 0 + + + gain18 + 10 + + + ant19 + + + + bb_gain19 + 20 + + + bw19 + 0 + + + dc_offset_mode19 + 0 + + + corr19 + 0 + + + freq19 + 100e6 + + + gain_mode19 + False + + + if_gain19 + 20 + + + iq_balance_mode19 + 0 + + + gain19 + 10 + + + ant1 + + + + bb_gain1 + 20 + + + bw1 + 0 + + + dc_offset_mode1 + 0 + + + corr1 + 0 + + + freq1 + 100e6 + + + gain_mode1 + False + + + if_gain1 + 20 + + + iq_balance_mode1 + 0 + + + gain1 + 10 + + + ant20 + + + + bb_gain20 + 20 + + + bw20 + 0 + + + dc_offset_mode20 + 0 + + + corr20 + 0 + + + freq20 + 100e6 + + + gain_mode20 + False + + + if_gain20 + 20 + + + iq_balance_mode20 + 0 + + + gain20 + 10 + + + ant21 + + + + bb_gain21 + 20 + + + bw21 + 0 + + + dc_offset_mode21 + 0 + + + corr21 + 0 + + + freq21 + 100e6 + + + gain_mode21 + False + + + if_gain21 + 20 + + + iq_balance_mode21 + 0 + + + gain21 + 10 + + + ant22 + + + + bb_gain22 + 20 + + + bw22 + 0 + + + dc_offset_mode22 + 0 + + + corr22 + 0 + + + freq22 + 100e6 + + + gain_mode22 + False + + + if_gain22 + 20 + + + iq_balance_mode22 + 0 + + + gain22 + 10 + + + ant23 + + + + bb_gain23 + 20 + + + bw23 + 0 + + + dc_offset_mode23 + 0 + + + corr23 + 0 + + + freq23 + 100e6 + + + gain_mode23 + False + + + if_gain23 + 20 + + + iq_balance_mode23 + 0 + + + gain23 + 10 + + + ant24 + + + + bb_gain24 + 20 + + + bw24 + 0 + + + dc_offset_mode24 + 0 + + + corr24 + 0 + + + freq24 + 100e6 + + + gain_mode24 + False + + + if_gain24 + 20 + + + iq_balance_mode24 + 0 + + + gain24 + 10 + + + ant25 + + + + bb_gain25 + 20 + + + bw25 + 0 + + + dc_offset_mode25 + 0 + + + corr25 + 0 + + + freq25 + 100e6 + + + gain_mode25 + False + + + if_gain25 + 20 + + + iq_balance_mode25 + 0 + + + gain25 + 10 + + + ant26 + + + + bb_gain26 + 20 + + + bw26 + 0 + + + dc_offset_mode26 + 0 + + + corr26 + 0 + + + freq26 + 100e6 + + + gain_mode26 + False + + + if_gain26 + 20 + + + iq_balance_mode26 + 0 + + + gain26 + 10 + + + ant27 + + + + bb_gain27 + 20 + + + bw27 + 0 + + + dc_offset_mode27 + 0 + + + corr27 + 0 + + + freq27 + 100e6 + + + gain_mode27 + False + + + if_gain27 + 20 + + + iq_balance_mode27 + 0 + + + gain27 + 10 + + + ant28 + + + + bb_gain28 + 20 + + + bw28 + 0 + + + dc_offset_mode28 + 0 + + + corr28 + 0 + + + freq28 + 100e6 + + + gain_mode28 + False + + + if_gain28 + 20 + + + iq_balance_mode28 + 0 + + + gain28 + 10 + + + ant29 + + + + bb_gain29 + 20 + + + bw29 + 0 + + + dc_offset_mode29 + 0 + + + corr29 + 0 + + + freq29 + 100e6 + + + gain_mode29 + False + + + if_gain29 + 20 + + + iq_balance_mode29 + 0 + + + gain29 + 10 + + + ant2 + + + + bb_gain2 + 20 + + + bw2 + 0 + + + dc_offset_mode2 + 0 + + + corr2 + 0 + + + freq2 + 100e6 + + + gain_mode2 + False + + + if_gain2 + 20 + + + iq_balance_mode2 + 0 + + + gain2 + 10 + + + ant30 + + + + bb_gain30 + 20 + + + bw30 + 0 + + + dc_offset_mode30 + 0 + + + corr30 + 0 + + + freq30 + 100e6 + + + gain_mode30 + False + + + if_gain30 + 20 + + + iq_balance_mode30 + 0 + + + gain30 + 10 + + + ant31 + + + + bb_gain31 + 20 + + + bw31 + 0 + + + dc_offset_mode31 + 0 + + + corr31 + 0 + + + freq31 + 100e6 + + + gain_mode31 + False + + + if_gain31 + 20 + + + iq_balance_mode31 + 0 + + + gain31 + 10 + + + ant3 + + + + bb_gain3 + 20 + + + bw3 + 0 + + + dc_offset_mode3 + 0 + + + corr3 + 0 + + + freq3 + 100e6 + + + gain_mode3 + False + + + if_gain3 + 20 + + + iq_balance_mode3 + 0 + + + gain3 + 10 + + + ant4 + + + + bb_gain4 + 20 + + + bw4 + 0 + + + dc_offset_mode4 + 0 + + + corr4 + 0 + + + freq4 + 100e6 + + + gain_mode4 + False + + + if_gain4 + 20 + + + iq_balance_mode4 + 0 + + + gain4 + 10 + + + ant5 + + + + bb_gain5 + 20 + + + bw5 + 0 + + + dc_offset_mode5 + 0 + + + corr5 + 0 + + + freq5 + 100e6 + + + gain_mode5 + False + + + if_gain5 + 20 + + + iq_balance_mode5 + 0 + + + gain5 + 10 + + + ant6 + + + + bb_gain6 + 20 + + + bw6 + 0 + + + dc_offset_mode6 + 0 + + + corr6 + 0 + + + freq6 + 100e6 + + + gain_mode6 + False + + + if_gain6 + 20 + + + iq_balance_mode6 + 0 + + + gain6 + 10 + + + ant7 + + + + bb_gain7 + 20 + + + bw7 + 0 + + + dc_offset_mode7 + 0 + + + corr7 + 0 + + + freq7 + 100e6 + + + gain_mode7 + False + + + if_gain7 + 20 + + + iq_balance_mode7 + 0 + + + gain7 + 10 + + + ant8 + + + + bb_gain8 + 20 + + + bw8 + 0 + + + dc_offset_mode8 + 0 + + + corr8 + 0 + + + freq8 + 100e6 + + + gain_mode8 + False + + + if_gain8 + 20 + + + iq_balance_mode8 + 0 + + + gain8 + 10 + + + ant9 + + + + bb_gain9 + 20 + + + bw9 + 0 + + + dc_offset_mode9 + 0 + + + corr9 + 0 + + + freq9 + 100e6 + + + gain_mode9 + False + + + if_gain9 + 20 + + + iq_balance_mode9 + 0 + + + gain9 + 10 + + + comment + + + + affinity + + + + args + + + + _enabled + 1 + + + _coordinate + (32, 572) + + + _rotation + 0 + + + id + osmosdr_source_0 + + + maxoutbuf + 0 + + + clock_source0 + + + + time_source0 + + + + clock_source1 + + + + time_source1 + + + + clock_source2 + + + + time_source2 + + + + clock_source3 + + + + time_source3 + + + + clock_source4 + + + + time_source4 + + + + clock_source5 + + + + time_source5 + + + + clock_source6 + + + + time_source6 + + + + clock_source7 + + + + time_source7 + + + + minoutbuf + 0 + + + nchan + 1 + + + num_mboards + 1 + + + type + fc32 + + + sample_rate + samp_rate_rx + + + sync + + + + + pfb_arb_resampler_xxx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1224, 455) + + + _rotation + 180 + + + id + pfb_arb_resampler_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nfilts + 32 + + + rrate + samp_rate_tx / (baud_rate * samples_per_symbol_tx) + + + samp_delay + 0 + + + atten + 60 + + + taps + firdes.low_pass_2(32, 32, 0.8, 0.1, 60) + + + type + ccf + + + + satnogs_ax25_decoder_bm + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + descrambling + True + + + _coordinate + (1272, 760) + + + _rotation + 180 + + + id + satnogs_ax25_decoder_bm_0 + + + maxoutbuf + 0 + + + max_frame_len + 256 + + + minoutbuf + 0 + + + promisc + False + + + addr + 'GND' + + + ssid + 0 + + + + satnogs_ax25_encoder_mb + + alias + + + + comment + + + + affinity + + + + dest_addr + UPSAT + + + dest_ssid + 0 + + + _enabled + True + + + scramble + True + + + _coordinate + (480, 266) + + + _rotation + 0 + + + id + satnogs_ax25_encoder_mb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + postamble_len + 16 + + + preamble_len + 16 + + + src_addr + GND + + + src_ssid + 0 + + + + satnogs_debug_msg_source + + alias + + + + comment + + + + affinity + + + + delay + 1 + + + _enabled + 1 + + + _coordinate + (232, 190) + + + _rotation + 0 + + + id + satnogs_debug_msg_source_0 + + + maxoutbuf + 0 + + + msg + 'HELLO UPSAT FROM EARTH' * 2 + + + minoutbuf + 0 + + + repeat + True + + + + satnogs_multi_format_msg_sink + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (928, 860) + + + _rotation + 180 + + + id + satnogs_multi_format_msg_sink_0_0 + + + format + 0 + + + + satnogs_udp_msg_sink + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (928, 766) + + + _rotation + 180 + + + id + satnogs_udp_msg_sink_0_0 + + + addr + "127.0.0.1" + + + mtu + 1500 + + + port + 16886 + + + + satnogs_udp_msg_source + + alias + + + + comment + The transmitter can also receive payloads +from a UDP source. Use netcat or something +similar to produce dynamic payloads. + + + affinity + + + + _enabled + 1 + + + _coordinate + (240, 294) + + + _rotation + 0 + + + id + satnogs_udp_msg_source_0 + + + addr + "127.0.0.1" + + + mtu + 1500 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + port + 16886 + + + + analog_frequency_modulator_fc_0 + pfb_arb_resampler_xxx_0 + 0 + 0 + + + analog_quadrature_demod_cf_0_0 + digital_clock_recovery_mm_xx_0 + 0 + 0 + + + analog_sig_source_x_0 + blocks_multiply_xx_0 + 0 + 1 + + + blocks_char_to_float_0 + interp_fir_filter_xxx_0 + 0 + 0 + + + blocks_multiply_xx_0 + osmosdr_sink_0 + 0 + 0 + + + digital_binary_slicer_fb_0 + satnogs_ax25_decoder_bm_0 + 0 + 0 + + + digital_clock_recovery_mm_xx_0 + digital_binary_slicer_fb_0 + 0 + 0 + + + digital_map_bb_0 + blocks_char_to_float_0 + 0 + 0 + + + freq_xlating_fir_filter_xxx_0 + analog_quadrature_demod_cf_0_0 + 0 + 0 + + + interp_fir_filter_xxx_0 + analog_frequency_modulator_fc_0 + 0 + 0 + + + osmosdr_source_0 + freq_xlating_fir_filter_xxx_0 + 0 + 0 + + + pfb_arb_resampler_xxx_0 + blocks_multiply_xx_0 + 0 + 0 + + + satnogs_ax25_decoder_bm_0 + satnogs_multi_format_msg_sink_0_0 + pdu + in + + + satnogs_ax25_decoder_bm_0 + satnogs_udp_msg_sink_0_0 + pdu + in + + + satnogs_ax25_encoder_mb_0 + digital_map_bb_0 + 0 + 0 + + + satnogs_debug_msg_source_0 + satnogs_ax25_encoder_mb_0 + msg + info + + + satnogs_udp_msg_source_0 + satnogs_ax25_encoder_mb_0 + msg + info + + diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 92fc81a..0b5878d 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -23,7 +23,6 @@ install(FILES satnogs_multi_format_msg_sink.xml satnogs_cw_to_symbol.xml satnogs_sine_matched_filter_ff.xml - satnogs_ax25_decoder_b.xml satnogs_udp_msg_source.xml satnogs_debug_msg_source.xml satnogs_json_to_ecss_src.xml @@ -37,5 +36,6 @@ install(FILES satnogs_upsat_transmitter.xml satnogs_coarse_doppler_correction_cc.xml satnogs_debug_msg_source_raw.xml - satnogs_ax25_encoder_mb.xml DESTINATION share/gnuradio/grc/blocks + satnogs_ax25_encoder_mb.xml + satnogs_ax25_decoder_bm.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/satnogs_ax25_decoder_b.xml b/grc/satnogs_ax25_decoder_bm.xml similarity index 51% rename from grc/satnogs_ax25_decoder_b.xml rename to grc/satnogs_ax25_decoder_bm.xml index 55417d2..f0d0166 100644 --- a/grc/satnogs_ax25_decoder_b.xml +++ b/grc/satnogs_ax25_decoder_bm.xml @@ -1,20 +1,22 @@ AX.25 Decoder - satnogs_ax25_decoder_b + satnogs_ax25_decoder_bm satnogs import satnogs - satnogs.ax25_decoder_b($addr, $ssid, $promisc) + satnogs.ax25_decoder_bm($addr, $ssid, $promisc, $descrambling, $max_frame_len) Receiver Callsign addr + 'GND' string Receiver SSID ssid + 0 int @@ -33,6 +35,27 @@ + + G3RUH descrambling + descrambling + enum + + + + + + Maximum frame length + max_frame_len + 256 + int + + in byte @@ -42,4 +65,11 @@ pdu message + + + failed_pdu + message + 1 + + diff --git a/include/satnogs/CMakeLists.txt b/include/satnogs/CMakeLists.txt index 83554f4..151ef6d 100644 --- a/include/satnogs/CMakeLists.txt +++ b/include/satnogs/CMakeLists.txt @@ -34,7 +34,6 @@ install(FILES cw_to_symbol.h sine_matched_filter_ff.h utils.h - ax25_decoder_b.h udp_msg_source.h debug_msg_source.h json_to_ecss_src.h @@ -49,5 +48,6 @@ install(FILES udp_msg_sink.h coarse_doppler_correction_cc.h debug_msg_source_raw.h - ax25_encoder_mb.h DESTINATION include/satnogs + ax25_encoder_mb.h + ax25_decoder_bm.h DESTINATION include/satnogs ) diff --git a/include/satnogs/ax25_decoder_b.h b/include/satnogs/ax25_decoder_b.h deleted file mode 100644 index a7d8ad8..0000000 --- a/include/satnogs/ax25_decoder_b.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module - * - * Copyright (C) 2016, Libre Space Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INCLUDED_SATNOGS_AX25_DECODER_B_H -#define INCLUDED_SATNOGS_AX25_DECODER_B_H - -#include -#include - -namespace gr { - namespace satnogs { - - /*! - * \brief AX.25 decoding block - * \ingroup satnogs - * - */ - class SATNOGS_API ax25_decoder_b : virtual public gr::sync_block - { - public: - typedef boost::shared_ptr sptr; - - /** - * AX.25 decoder block. - * - * @param addr the Callsign of the receiver - * @param ssid the SSID of the receiver - * @param promisc if set to true, all the successfully decoded frames - * are forwarded. Otherwise, only those that have as destination address - * and SSID specified by the addr and ssid parameters respectively. - */ - static sptr make(std::string addr, uint8_t ssid, bool promisc=true); - }; - - } // namespace satnogs -} // namespace gr - -#endif /* INCLUDED_SATNOGS_AX25_DECODER_B_H */ - diff --git a/include/satnogs/ax25_decoder_bm.h b/include/satnogs/ax25_decoder_bm.h new file mode 100644 index 0000000..89ec414 --- /dev/null +++ b/include/satnogs/ax25_decoder_bm.h @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2016, Libre Space Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDED_SATNOGS_AX25_DECODER_BM_H +#define INCLUDED_SATNOGS_AX25_DECODER_BM_H + +#include +#include + +namespace gr +{ + namespace satnogs + { + + /*! + * \brief AX.25 decoder that supports the legacy hardware radios. + * + * This block takes as input a quadrature demodulated bit stream. + * Each byte should contains only one bit of information at the LSB. + * + * The block will try to find an AX.25 frame. If the frame pass the + * CRC check then a blob PMT message is produced at the message output + * indicated with name 'out'. Otherwise if the frame did not pass the + * CRC check or the size was invalid, a blob PMT message is generated at + * the output port with the name 'fail'. This will help to recover at least + * some bytes from a corrupted message. + * + * The block also supports destination callsign check. Only frames with + * the right destination Callsign will be accepted. This feature can be + * disabled using the promisc parameter. + * + * \ingroup satnogs + * + */ + class SATNOGS_API ax25_decoder_bm : virtual public gr::sync_block + { + public: + typedef boost::shared_ptr sptr; + + /** + * This block takes as input a quadrature demodulated bit stream. + * Each byte should contains only one bit of information at the LSB. + * + * The block will try to find an AX.25 frame. If the frame pass the + * CRC check then a blob PMT message is produced at the message output + * indicated with name 'pdu'. Otherwise if the frame did not pass the + * CRC check or the size was invalid, a blob PMT message is generated at + * the output port with the name 'failed_pdu'. + * This will help to recover at least some bytes from a corrupted message. + * + * The block also supports destination callsign check. Only frames with + * the right destination Callsign will be accepted. This feature can be + * disabled using the promisc parameter. + * @param addr the Callsign of the receiver + * @param ssid the SSID of the receiver + * @param promisc if set to yes, the Callsign check is disabled + * @param descramble if set to yes, the data will be descrambled prior + * decoding using the G3RUH self-synchronizing descrambler. + * @param max_frame_len the maximum allowed frame length + * @return + */ + static sptr + make (const std::string& addr, uint8_t ssid, bool promisc = false, + bool descramble = true, + size_t max_frame_len = 512); + }; + + } // namespace satnogs +} // namespace gr + +#endif /* INCLUDED_SATNOGS_AX25_DECODER_BM_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 64b81f4..ed48f3b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -32,7 +32,6 @@ list(APPEND satnogs_sources multi_format_msg_sink_impl.cc cw_to_symbol_impl.cc sine_matched_filter_ff_impl.cc - ax25_decoder_b_impl.cc udp_msg_source_impl.cc debug_msg_source_impl.cc tcp_rigctl_msg_source_impl.cc @@ -47,7 +46,8 @@ list(APPEND satnogs_sources udp_msg_sink_impl.cc coarse_doppler_correction_cc_impl.cc debug_msg_source_raw_impl.cc - ax25_encoder_mb_impl.cc ) + ax25_encoder_mb_impl.cc + ax25_decoder_bm_impl.cc ) set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE) if(NOT satnogs_sources) diff --git a/lib/ax25_decoder_b_impl.cc b/lib/ax25_decoder_b_impl.cc deleted file mode 100644 index fc2dd0d..0000000 --- a/lib/ax25_decoder_b_impl.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- c++ -*- */ -/* - * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module - * - * Copyright (C) 2016, Libre Space Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "ax25_decoder_b_impl.h" -#include - -namespace gr { - namespace satnogs { - - ax25_decoder_b::sptr - ax25_decoder_b::make(std::string addr, uint8_t ssid, bool promisc) - { - return gnuradio::get_initial_sptr - (new ax25_decoder_b_impl(addr, ssid, promisc)); - } - - /* - * The private constructor - */ - ax25_decoder_b_impl::ax25_decoder_b_impl (std::string addr, uint8_t ssid, - bool promisc) : - gr::sync_block ("ax25_decoder_b", - gr::io_signature::make (1, 1, sizeof(uint8_t)), - gr::io_signature::make (0, 0, 0)), - d_promisc(promisc), - d_state(NO_SYNC), - d_dec_b(0), - d_prev_bit(0), - d_received_bytes(0), - d_decoded_bits(0), - d_cont_1(0), - d_frame_buffer(new uint8_t[AX25_MAX_FRAME_LEN - + AX25_MAX_ADDR_LEN - + AX25_MAX_CTRL_LEN - + sizeof(uint16_t)]) - { - message_port_register_out (pmt::mp ("pdu")); - } - - void - ax25_decoder_b_impl::reset_state () - { - d_state = NO_SYNC; - d_dec_b = 0; - d_decoded_bits = 0; - d_received_bytes = 0; - d_cont_1 = 0; - } - - void - ax25_decoder_b_impl::enter_sync_state () - { - d_state = IN_SYNC; - d_dec_b = 0; - d_decoded_bits = 0; - d_received_bytes = 0; - d_prev_bit = 0; - d_cont_1 = 0; - } - - void - ax25_decoder_b_impl::update_recv_frame (uint8_t byte) - { - uint16_t fcs; - uint16_t recv_fcs = 0x0; - if( d_decoded_bits ) { - return; - } - - if(byte == AX25_SYNC_FLAG) { - /* First check if the size of the frame is valid */ - if(d_received_bytes < AX25_MIN_ADDR_LEN + sizeof(uint16_t)){ - reset_state(); - return; - } - - /* Check if the frame is correct using the FCS field */ - fcs = ax25_fcs (d_frame_buffer, d_received_bytes - sizeof(uint16_t)); - recv_fcs = (((uint16_t) d_frame_buffer[d_received_bytes - 2]) << 8) - | d_frame_buffer[d_received_bytes - 1]; - - if( fcs == recv_fcs ) { - message_port_pub ( - pmt::mp ("pdu"), - pmt::make_blob (d_frame_buffer, - d_received_bytes - sizeof(uint16_t))); - } - else { - LOG_WARN("Wrong FCS: Should be 0%x, computed as 0%x", recv_fcs, fcs); - } - - LOG_WARN("Frame size %lu", d_received_bytes); - reset_state(); - } - else{ - d_frame_buffer[d_received_bytes++] = byte; - - if(d_received_bytes > AX25_MAX_FRAME_LEN){ - LOG_WARN("Maximum frame size reached. Abort decoding this frame"); - reset_state(); - } - } - d_dec_b = 0; - } - - /* - * Our virtual destructor. - */ - ax25_decoder_b_impl::~ax25_decoder_b_impl() - { - delete[] d_frame_buffer; - } - - int - ax25_decoder_b_impl::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - int i; - const uint8_t *in = (const uint8_t *) input_items[0]; - - for (i = 0; i < noutput_items; i++) { - switch (d_state) - { - case NO_SYNC: - d_dec_b = (d_dec_b << 1) | in[i]; - /* - * If the decoder find the sync flag of the AX.25 frame start the - * decoding process - */ - if(d_dec_b == AX25_SYNC_FLAG){ - enter_sync_state(); - } - break; - case IN_SYNC: - if(in[i]){ - if(d_prev_bit) { - d_cont_1++; - } - else { - d_cont_1 = 1; - } - d_dec_b |= 1 << d_decoded_bits; - d_decoded_bits = (d_decoded_bits + 1) % 8; - update_recv_frame(d_dec_b); - d_prev_bit = 1; - } - else{ - /* Check if this a stuffed zero bit */ - if(d_cont_1 < 5) { - d_decoded_bits = (d_decoded_bits + 1) % 8; - update_recv_frame(d_dec_b); - } - d_prev_bit = 0; - d_cont_1 = 0; - } - break; - default: - LOG_ERROR("Invalid decoding state"); - } - } - return noutput_items; - } - - } /* namespace satnogs */ -} /* namespace gr */ - diff --git a/lib/ax25_decoder_bm_impl.cc b/lib/ax25_decoder_bm_impl.cc new file mode 100644 index 0000000..9468333 --- /dev/null +++ b/lib/ax25_decoder_bm_impl.cc @@ -0,0 +1,360 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2016, Libre Space Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "ax25_decoder_bm_impl.h" + +namespace gr +{ + namespace satnogs + { + + ax25_decoder_bm::sptr + ax25_decoder_bm::make (const std::string& addr, uint8_t ssid, bool promisc, + bool descramble, size_t max_frame_len) + { + return gnuradio::get_initial_sptr ( + new ax25_decoder_bm_impl (addr, ssid, promisc, + descramble, max_frame_len)); + } + + /* + * The private constructor + */ + ax25_decoder_bm_impl::ax25_decoder_bm_impl (const std::string& addr, + uint8_t ssid, bool promisc, + bool descramble, + size_t max_frame_len) : + gr::sync_block ("ax25_decoder_bm", + gr::io_signature::make (1, 1, sizeof(uint8_t)), + gr::io_signature::make (0, 0, 0)), + d_promisc (promisc), + d_descramble (descramble), + d_max_frame_len (max_frame_len), + d_state (NO_SYNC), + d_dec_b (0), + d_prev_bit_nrzi(0), + d_received_bytes (0), + d_decoded_bits (0), + d_lfsr(0x21, 0x0, 16), + d_frame_buffer ( + new uint8_t[max_frame_len + AX25_MAX_ADDR_LEN + + AX25_MAX_CTRL_LEN + sizeof(uint16_t)]) + { + /* Valid PDUs output message port */ + message_port_register_out (pmt::mp ("pdu")); + /* + * Valid invalid (wrong CRC, different destination Callsign/SSID, + * wrong frame size)PDUs output message port + */ + message_port_register_out (pmt::mp ("failed_pdu")); + } + + void + ax25_decoder_bm_impl::descramble_and_decode (const uint8_t* in, + size_t nitems) + { + size_t i; + uint8_t descr_bit; + uint8_t dec_bit; + + for(i = 0; i < nitems; i++){ + /* Descramble the input bit */ + descr_bit = d_lfsr.next_bit_descramble(in[i]); + + /* Perform NRZI decoding */ + dec_bit = (~((descr_bit - d_prev_bit_nrzi) % 2)) & 0x1; + d_prev_bit_nrzi = descr_bit; + + switch(d_state){ + case NO_SYNC: + /* In AX.25 the LS bit is sent first */ + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + if(d_dec_b == AX25_SYNC_FLAG){ + enter_sync_state(); + } + break; + case IN_SYNC: + /* In AX.25 the LS bit is sent first */ + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + + /* + * If the received byte was an AX.25 sync flag, there are two + * possibilities. Either it was the end of frame or just a repeat of the + * preamble. + * + * Also in case in error at the preamble, the G3RUH polynomial should + * re-sync after 3 repetitions of the SYNC flag. For this reason we demand + * that the distance between the last SYNC flag is greater than 3 bytes + */ + if (d_dec_b == AX25_SYNC_FLAG) { + if(d_received_bytes < 3) { + enter_sync_state (); + } + else{ + /* Frame end */ + enter_frame_end(); + } + } + else if((d_dec_b & 0xfc) == 0x7c){ + /*This was a stuffed bit */ + d_dec_b <<= 1; + } + else if((d_dec_b & 0xfe) == 0xfe){ + /*This can never happen... Error! */ + if (d_received_bytes > AX25_MIN_ADDR_LEN) { + message_port_pub ( + pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, d_received_bytes)); + } + reset_state(); + } + else{ + d_decoded_bits++; + if(d_decoded_bits == 8){ + d_frame_buffer[d_received_bytes++] = d_dec_b; + d_decoded_bits = 0; + + /*Check if the frame limit was reached */ + if(d_received_bytes >= d_max_frame_len) { + message_port_pub ( + pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, d_max_frame_len)); + reset_state(); + } + } + } + break; + case FRAME_END: + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + if (d_dec_b == AX25_SYNC_FLAG) { + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + d_state = FRAME_END; + } + else{ + d_decoded_bits++; + if(d_decoded_bits == 8){ + d_received_bytes++; + if(d_received_bytes > 0){ + reset_state(); + } + } + } + break; + default: + LOG_ERROR("Invalid decoding state"); + } + } + } + + void + ax25_decoder_bm_impl::decode (const uint8_t* in, size_t nitems) + { + size_t i; + uint8_t dec_bit; + + for (i = 0; i < nitems; i++) { + + /* Perform NRZI decoding */ + dec_bit = (~(((in[i] & 0x1) - d_prev_bit_nrzi) % 2)) & 0x1; + d_prev_bit_nrzi = in[i] & 0x1; + + switch (d_state) + { + case NO_SYNC: + /* In AX.25 the LS bit is sent first */ + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + if (d_dec_b == AX25_SYNC_FLAG) { + enter_sync_state (); + } + break; + case IN_SYNC: + /* In AX.25 the LS bit is sent first */ + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + + /* + * If the received byte was an AX.25 sync flag, there are two + * possibilities. Either it was the end of frame or just a repeat of the + * preamble. + * + * Also in case in error at the preamble, the G3RUH polynomial should + * re-sync after 3 repetitions of the SYNC flag. For this reason we demand + * that the distance between the last SYNC flag is greater than 3 bytes + */ + if (d_dec_b == AX25_SYNC_FLAG) { + if (d_received_bytes < 2) { + enter_sync_state (); + } + else { + /* Frame end */ + enter_frame_end (); + } + } + else if ((d_dec_b & 0xfc) == 0x7c) { + /*This was a stuffed bit */ + d_dec_b <<= 1; + } + else if ((d_dec_b & 0xfe) == 0xfe) { + /*This can never happen... Error! */ + if (d_received_bytes > AX25_MIN_ADDR_LEN) { + message_port_pub ( + pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, d_received_bytes)); + } + reset_state (); + } + else { + d_decoded_bits++; + if (d_decoded_bits == 8) { + d_frame_buffer[d_received_bytes++] = d_dec_b; + d_decoded_bits = 0; + + /*Check if the frame limit was reached */ + if (d_received_bytes >= d_max_frame_len) { + message_port_pub ( + pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, d_max_frame_len)); + reset_state (); + } + } + } + break; + case FRAME_END: + d_dec_b = (d_dec_b >> 1) | (dec_bit << 7); + if (d_dec_b == AX25_SYNC_FLAG) { + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + d_state = FRAME_END; + } + else { + d_decoded_bits++; + if (d_decoded_bits == 8) { + d_received_bytes++; + if (d_received_bytes > 3) { + reset_state (); + } + } + } + break; + default: + LOG_ERROR("Invalid decoding state"); + } + } + } + + /* + * Our virtual destructor. + */ + ax25_decoder_bm_impl::~ax25_decoder_bm_impl () + { + delete [] d_frame_buffer; + } + + void + ax25_decoder_bm_impl::reset_state () + { + d_state = NO_SYNC; + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + d_prev_bit_nrzi = 0; + } + + void + ax25_decoder_bm_impl::enter_sync_state () + { + d_state = IN_SYNC; + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + } + + void + ax25_decoder_bm_impl::enter_frame_end () + { + uint16_t fcs; + uint16_t recv_fcs = 0x0; + + /* First check if the size of the frame is valid */ + if (d_received_bytes < AX25_MIN_ADDR_LEN + sizeof(uint16_t)) { + message_port_pub (pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, d_received_bytes)); + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + d_state = FRAME_END; + return; + } + + /* Check if the frame is correct using the FCS field */ + fcs = ax25_fcs (d_frame_buffer, d_received_bytes - sizeof(uint16_t)); + recv_fcs = (((uint16_t) d_frame_buffer[d_received_bytes - 1]) << 8) + | d_frame_buffer[d_received_bytes - 2]; + + if (fcs == recv_fcs) { + /* + * FIXME: Skip the right amount of header bytes based on the frame type + */ + message_port_pub ( + pmt::mp ("pdu"), + pmt::make_blob (d_frame_buffer + AX25_MIN_ADDR_LEN + 2, + d_received_bytes - AX25_MIN_ADDR_LEN - 2 - sizeof(uint16_t))); + } + else { + message_port_pub ( + pmt::mp ("failed_pdu"), + pmt::make_blob (d_frame_buffer, + d_received_bytes - sizeof(uint16_t))); + } + d_dec_b = 0; + d_decoded_bits = 0; + d_received_bytes = 0; + d_state = FRAME_END; + } + + + int + ax25_decoder_bm_impl::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const uint8_t *in = (const uint8_t *) input_items[0]; + + if(d_descramble){ + descramble_and_decode(in, noutput_items); + } + else{ + decode(in, noutput_items); + } + return noutput_items; + } + + } /* namespace satnogs */ +} /* namespace gr */ + diff --git a/lib/ax25_decoder_b_impl.h b/lib/ax25_decoder_bm_impl.h similarity index 62% rename from lib/ax25_decoder_b_impl.h rename to lib/ax25_decoder_bm_impl.h index 602d6f1..9fa48f6 100644 --- a/lib/ax25_decoder_b_impl.h +++ b/lib/ax25_decoder_bm_impl.h @@ -18,23 +18,23 @@ * along with this program. If not, see . */ -#ifndef INCLUDED_SATNOGS_AX25_DECODER_B_IMPL_H -#define INCLUDED_SATNOGS_AX25_DECODER_B_IMPL_H +#ifndef INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H +#define INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H -#include -#include +#include +#include namespace gr { namespace satnogs { - class ax25_decoder_b_impl : public ax25_decoder_b + class ax25_decoder_bm_impl : public ax25_decoder_bm { private: - typedef enum { - NO_SYNC, - IN_SYNC + typedef enum + { + NO_SYNC, IN_SYNC, FRAME_END } decoding_state_t; /** @@ -42,22 +42,32 @@ namespace gr * forwards all successfully decoded frames */ const bool d_promisc; + const bool d_descramble; + const size_t d_max_frame_len; decoding_state_t d_state; uint8_t d_dec_b; - uint8_t d_prev_bit; + uint8_t d_prev_bit_nrzi; size_t d_received_bytes; size_t d_decoded_bits; - size_t d_cont_1; - + digital::lfsr d_lfsr; uint8_t *d_frame_buffer; - void reset_state(); - void enter_sync_state(); - void update_recv_frame(uint8_t byte); + void + reset_state (); + void + enter_sync_state (); + void + enter_frame_end (); + + void + descramble_and_decode (const uint8_t *in, size_t nitems); + void + decode (const uint8_t *in, size_t nitems); public: - ax25_decoder_b_impl (std::string addr, uint8_t ssid, bool promisc); - ~ax25_decoder_b_impl (); + ax25_decoder_bm_impl (const std::string& addr, uint8_t ssid, bool promisc, + bool descramble, size_t max_frame_len); + ~ax25_decoder_bm_impl (); // Where all the action really happens int @@ -68,5 +78,5 @@ namespace gr } // namespace satnogs } // namespace gr -#endif /* INCLUDED_SATNOGS_AX25_DECODER_B_IMPL_H */ +#endif /* INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H */ diff --git a/lib/ax25_encoder_mb_impl.h b/lib/ax25_encoder_mb_impl.h index 5203422..f1af453 100644 --- a/lib/ax25_encoder_mb_impl.h +++ b/lib/ax25_encoder_mb_impl.h @@ -45,8 +45,10 @@ namespace gr digital::lfsr d_lfsr; boost::mutex d_mutex; - void add_sob(uint64_t item); - void add_eob(uint64_t item); + void + add_sob (uint64_t item); + void + add_eob (uint64_t item); public: ax25_encoder_mb_impl (const std::string& dest_addr, uint8_t dest_ssid, diff --git a/swig/satnogs_swig.i b/swig/satnogs_swig.i index ed49385..ac44530 100644 --- a/swig/satnogs_swig.i +++ b/swig/satnogs_swig.i @@ -16,7 +16,6 @@ #include "satnogs/multi_format_msg_sink.h" #include "satnogs/cw_to_symbol.h" #include "satnogs/sine_matched_filter_ff.h" -#include "satnogs/ax25_decoder_b.h" #include "satnogs/udp_msg_source.h" #include "satnogs/debug_msg_source.h" #include "satnogs/tcp_rigctl_msg_source.h" @@ -30,6 +29,7 @@ #include "satnogs/coarse_doppler_correction_cc.h" #include "satnogs/debug_msg_source_raw.h" #include "satnogs/ax25_encoder_mb.h" +#include "satnogs/ax25_decoder_bm.h" %} @@ -48,8 +48,6 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, cw_to_symbol); %include "satnogs/sine_matched_filter_ff.h" GR_SWIG_BLOCK_MAGIC2(satnogs, sine_matched_filter_ff); -%include "satnogs/ax25_decoder_b.h" -GR_SWIG_BLOCK_MAGIC2(satnogs, ax25_decoder_b); %include "satnogs/udp_msg_source.h" GR_SWIG_BLOCK_MAGIC2(satnogs, udp_msg_source); %include "satnogs/debug_msg_source.h" @@ -75,3 +73,5 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, coarse_doppler_correction_cc); GR_SWIG_BLOCK_MAGIC2(satnogs, debug_msg_source_raw); %include "satnogs/ax25_encoder_mb.h" GR_SWIG_BLOCK_MAGIC2(satnogs, ax25_encoder_mb); +%include "satnogs/ax25_decoder_bm.h" +GR_SWIG_BLOCK_MAGIC2(satnogs, ax25_decoder_bm);