diff options
| author | DogKing <dogking@DESKTOP-35DN20C> | 2025-09-30 19:43:31 +0800 |
|---|---|---|
| committer | DogKing <dogking@DESKTOP-35DN20C> | 2025-09-30 19:43:31 +0800 |
| commit | 661184deeec78d1d8a58bdcc9ed9d7698626e675 (patch) | |
| tree | 2aa87b8a7de9a28ac64888c6994cdcbc2f6e62ac | |
| -rw-r--r-- | adsb.grc | 933 | ||||
| -rwxr-xr-x | adsb_rx.py | 371 | ||||
| -rwxr-xr-x | webserver.py | 46 |
3 files changed, 1350 insertions, 0 deletions
diff --git a/adsb.grc b/adsb.grc new file mode 100644 index 0000000..7f3980f --- /dev/null +++ b/adsb.grc @@ -0,0 +1,933 @@ +options: + parameters: + author: Matt Hostetter + catch_exceptions: 'False' + category: Custom + cmake_opt: '' + comment: '' + copyright: '' + description: '' + gen_cmake: 'On' + gen_linking: dynamic + generate_options: qt_gui + hier_block_src_path: '.:' + id: adsb_rx + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: prompt + sizing_mode: fixed + thread_safe_setters: '' + title: ADS-B Receiver + window_size: 4096,4096 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [8, 12] + rotation: 0 + state: enabled + +blocks: +- name: fc + id: variable + parameters: + comment: '' + value: 1090e6 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [176, 12] + rotation: 0 + state: enabled +- name: fs + id: variable + parameters: + comment: '' + value: 2e6 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [264, 12] + rotation: 0 + state: enabled +- name: gain + id: variable_qtgui_entry + parameters: + comment: '' + gui_hint: 0,0,1,1 + label: Gain (dB) + type: real + value: '60' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [336, 12] + rotation: 0 + state: enabled +- name: threshold + id: variable_qtgui_entry + parameters: + comment: '' + gui_hint: 0,1,1,1 + label: Detection Threshold + type: real + value: '0.010' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [456, 12] + rotation: 0 + state: enabled +- name: adsb_decoder_0 + id: adsb_decoder + parameters: + affinity: '' + alias: '' + comment: '' + error_corr: '"None"' + maxoutbuf: '0' + minoutbuf: '0' + msg_filter: '"Extended Squitter Only"' + print_level: '"Brief"' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [616, 340.0] + rotation: 0 + state: enabled +- name: adsb_demod_0 + id: adsb_demod + parameters: + affinity: '' + alias: '' + comment: '' + fs: fs + maxoutbuf: '0' + minoutbuf: '0' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [408, 360.0] + rotation: 0 + state: enabled +- name: adsb_framer_1 + id: adsb_framer + parameters: + affinity: '' + alias: '' + comment: '' + fs: fs + maxoutbuf: '0' + minoutbuf: '0' + threshold: threshold + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [184, 364.0] + rotation: 0 + state: enabled +- name: analog_const_source_x_0 + id: analog_const_source_x + parameters: + affinity: '' + alias: '' + comment: '' + const: threshold + maxoutbuf: '0' + minoutbuf: '0' + type: float + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [424, 460.0] + rotation: 0 + state: enabled +- name: blocks_complex_to_mag_0 + id: blocks_complex_to_mag + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [568, 240.0] + rotation: 0 + state: true +- name: dc_blocker_xx_0 + id: dc_blocker_xx + parameters: + affinity: '' + alias: '' + comment: '' + length: '32' + long_form: 'True' + maxoutbuf: '0' + minoutbuf: '0' + type: cc + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [256, 228.0] + rotation: 0 + state: true +- name: qtgui_freq_sink_x_0 + id: qtgui_freq_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + average: '1.0' + axislabels: 'True' + bw: fs + color1: '"blue"' + color10: '"dark blue"' + color2: '"red"' + color3: '"green"' + color4: '"black"' + color5: '"cyan"' + color6: '"magenta"' + color7: '"yellow"' + color8: '"dark red"' + color9: '"dark green"' + comment: '' + ctrlpanel: 'False' + fc: '0' + fftsize: '1024' + freqhalf: 'True' + grid: 'False' + gui_hint: '' + label: Relative Gain + label1: '' + label10: '''''' + label2: '''''' + label3: '''''' + label4: '''''' + label5: '''''' + label6: '''''' + label7: '''''' + label8: '''''' + label9: '''''' + legend: 'True' + maxoutbuf: '0' + minoutbuf: '0' + name: '""' + nconnections: '1' + norm_window: 'False' + showports: 'False' + tr_chan: '0' + tr_level: '0.0' + tr_mode: qtgui.TRIG_MODE_FREE + tr_tag: '""' + type: complex + units: dB + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + wintype: window.WIN_BLACKMAN_hARRIS + ymax: '10' + ymin: '-140' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [632, 108.0] + rotation: 0 + state: true +- name: qtgui_time_sink_x_0 + id: qtgui_time_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: blue + color10: dark blue + color2: red + color3: green + color4: black + color5: cyan + color6: magenta + color7: yellow + color8: dark red + color9: dark green + comment: '' + ctrlpanel: 'False' + entags: 'True' + grid: 'True' + gui_hint: 1,0,1,2 + label1: '' + label10: '' + label2: '' + label3: '' + label4: '' + label5: '' + label6: '' + label7: '' + label8: '' + label9: '' + legend: 'False' + marker1: '0' + marker10: '-1' + marker2: '-1' + marker3: '-1' + marker4: '-1' + marker5: '-1' + marker6: '-1' + marker7: '-1' + marker8: '-1' + marker9: '-1' + name: '""' + nconnections: '2' + size: int(fs*150e-6) + srate: int(fs) + stemplot: 'False' + style1: '1' + style10: '1' + style2: '1' + style3: '1' + style4: '1' + style5: '1' + style6: '1' + style7: '1' + style8: '1' + style9: '1' + tr_chan: '0' + tr_delay: '1.25e-6' + tr_level: '0' + tr_mode: qtgui.TRIG_MODE_TAG + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '"burst"' + type: float + update_time: 1.0/100.0 + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + ylabel: Amplitude + ymax: '1' + ymin: '0' + yunit: '""' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [616, 428.0] + rotation: 0 + state: enabled +- name: qtgui_time_sink_x_1 + id: qtgui_time_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: blue + color10: dark blue + color2: red + color3: green + color4: black + color5: cyan + color6: magenta + color7: yellow + color8: dark red + color9: dark green + comment: '' + ctrlpanel: 'False' + entags: 'True' + grid: 'False' + gui_hint: '' + label1: Signal 1 + label10: Signal 10 + label2: Signal 2 + label3: Signal 3 + label4: Signal 4 + label5: Signal 5 + label6: Signal 6 + label7: Signal 7 + label8: Signal 8 + label9: Signal 9 + legend: 'True' + marker1: '-1' + marker10: '-1' + marker2: '-1' + marker3: '-1' + marker4: '-1' + marker5: '-1' + marker6: '-1' + marker7: '-1' + marker8: '-1' + marker9: '-1' + name: '""' + nconnections: '1' + size: '1024' + srate: fs + stemplot: 'False' + style1: '1' + style10: '1' + style2: '1' + style3: '1' + style4: '1' + style5: '1' + style6: '1' + style7: '1' + style8: '1' + style9: '1' + tr_chan: '0' + tr_delay: '0' + tr_level: '0.0' + tr_mode: qtgui.TRIG_MODE_FREE + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '""' + type: complex + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + ylabel: Amplitude + ymax: '0.1' + ymin: '-0.1' + yunit: '""' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [416, 132.0] + rotation: 0 + state: true +- name: uhd_usrp_source_0 + id: uhd_usrp_source + parameters: + affinity: '' + alias: '' + ant0: '"RX2"' + ant1: '' + ant10: '' + ant11: '' + ant12: '' + ant13: '' + ant14: '' + ant15: '' + ant16: '' + ant17: '' + ant18: '' + ant19: '' + ant2: '' + ant20: '' + ant21: '' + ant22: '' + ant23: '' + ant24: '' + ant25: '' + ant26: '' + ant27: '' + ant28: '' + ant29: '' + ant3: '' + ant30: '' + ant31: '' + ant4: '' + ant5: '' + ant6: '' + ant7: '' + ant8: '' + ant9: '' + bw0: '0' + bw1: '0' + bw10: '0' + bw11: '0' + bw12: '0' + bw13: '0' + bw14: '0' + bw15: '0' + bw16: '0' + bw17: '0' + bw18: '0' + bw19: '0' + bw2: '0' + bw20: '0' + bw21: '0' + bw22: '0' + bw23: '0' + bw24: '0' + bw25: '0' + bw26: '0' + bw27: '0' + bw28: '0' + bw29: '0' + bw3: '0' + bw30: '0' + bw31: '0' + bw4: '0' + bw5: '0' + bw6: '0' + bw7: '0' + bw8: '0' + bw9: '0' + center_freq0: fc + center_freq1: '0' + center_freq10: '0' + center_freq11: '0' + center_freq12: '0' + center_freq13: '0' + center_freq14: '0' + center_freq15: '0' + center_freq16: '0' + center_freq17: '0' + center_freq18: '0' + center_freq19: '0' + center_freq2: '0' + center_freq20: '0' + center_freq21: '0' + center_freq22: '0' + center_freq23: '0' + center_freq24: '0' + center_freq25: '0' + center_freq26: '0' + center_freq27: '0' + center_freq28: '0' + center_freq29: '0' + center_freq3: '0' + center_freq30: '0' + center_freq31: '0' + center_freq4: '0' + center_freq5: '0' + center_freq6: '0' + center_freq7: '0' + center_freq8: '0' + center_freq9: '0' + clock_rate: '0.0' + clock_source0: '' + clock_source1: '' + clock_source2: '' + clock_source3: '' + clock_source4: '' + clock_source5: '' + clock_source6: '' + clock_source7: '' + comment: '' + dc_offs0: 0+0j + dc_offs1: 0+0j + dc_offs10: 0+0j + dc_offs11: 0+0j + dc_offs12: 0+0j + dc_offs13: 0+0j + dc_offs14: 0+0j + dc_offs15: 0+0j + dc_offs16: 0+0j + dc_offs17: 0+0j + dc_offs18: 0+0j + dc_offs19: 0+0j + dc_offs2: 0+0j + dc_offs20: 0+0j + dc_offs21: 0+0j + dc_offs22: 0+0j + dc_offs23: 0+0j + dc_offs24: 0+0j + dc_offs25: 0+0j + dc_offs26: 0+0j + dc_offs27: 0+0j + dc_offs28: 0+0j + dc_offs29: 0+0j + dc_offs3: 0+0j + dc_offs30: 0+0j + dc_offs31: 0+0j + dc_offs4: 0+0j + dc_offs5: 0+0j + dc_offs6: 0+0j + dc_offs7: 0+0j + dc_offs8: 0+0j + dc_offs9: 0+0j + dc_offs_enb0: default + dc_offs_enb1: default + dc_offs_enb10: default + dc_offs_enb11: default + dc_offs_enb12: default + dc_offs_enb13: default + dc_offs_enb14: default + dc_offs_enb15: default + dc_offs_enb16: default + dc_offs_enb17: default + dc_offs_enb18: default + dc_offs_enb19: default + dc_offs_enb2: default + dc_offs_enb20: default + dc_offs_enb21: default + dc_offs_enb22: default + dc_offs_enb23: default + dc_offs_enb24: default + dc_offs_enb25: default + dc_offs_enb26: default + dc_offs_enb27: default + dc_offs_enb28: default + dc_offs_enb29: default + dc_offs_enb3: default + dc_offs_enb30: default + dc_offs_enb31: default + dc_offs_enb4: default + dc_offs_enb5: default + dc_offs_enb6: default + dc_offs_enb7: default + dc_offs_enb8: default + dc_offs_enb9: default + dev_addr: '""' + dev_args: '""' + gain0: gain + gain1: '0' + gain10: '0' + gain11: '0' + gain12: '0' + gain13: '0' + gain14: '0' + gain15: '0' + gain16: '0' + gain17: '0' + gain18: '0' + gain19: '0' + gain2: '0' + gain20: '0' + gain21: '0' + gain22: '0' + gain23: '0' + gain24: '0' + gain25: '0' + gain26: '0' + gain27: '0' + gain28: '0' + gain29: '0' + gain3: '0' + gain30: '0' + gain31: '0' + gain4: '0' + gain5: '0' + gain6: '0' + gain7: '0' + gain8: '0' + gain9: '0' + gain_type0: default + gain_type1: default + gain_type10: default + gain_type11: default + gain_type12: default + gain_type13: default + gain_type14: default + gain_type15: default + gain_type16: default + gain_type17: default + gain_type18: default + gain_type19: default + gain_type2: default + gain_type20: default + gain_type21: default + gain_type22: default + gain_type23: default + gain_type24: default + gain_type25: default + gain_type26: default + gain_type27: default + gain_type28: default + gain_type29: default + gain_type3: default + gain_type30: default + gain_type31: default + gain_type4: default + gain_type5: default + gain_type6: default + gain_type7: default + gain_type8: default + gain_type9: default + iq_imbal0: 0+0j + iq_imbal1: 0+0j + iq_imbal10: 0+0j + iq_imbal11: 0+0j + iq_imbal12: 0+0j + iq_imbal13: 0+0j + iq_imbal14: 0+0j + iq_imbal15: 0+0j + iq_imbal16: 0+0j + iq_imbal17: 0+0j + iq_imbal18: 0+0j + iq_imbal19: 0+0j + iq_imbal2: 0+0j + iq_imbal20: 0+0j + iq_imbal21: 0+0j + iq_imbal22: 0+0j + iq_imbal23: 0+0j + iq_imbal24: 0+0j + iq_imbal25: 0+0j + iq_imbal26: 0+0j + iq_imbal27: 0+0j + iq_imbal28: 0+0j + iq_imbal29: 0+0j + iq_imbal3: 0+0j + iq_imbal30: 0+0j + iq_imbal31: 0+0j + iq_imbal4: 0+0j + iq_imbal5: 0+0j + iq_imbal6: 0+0j + iq_imbal7: 0+0j + iq_imbal8: 0+0j + iq_imbal9: 0+0j + iq_imbal_enb0: default + iq_imbal_enb1: default + iq_imbal_enb10: default + iq_imbal_enb11: default + iq_imbal_enb12: default + iq_imbal_enb13: default + iq_imbal_enb14: default + iq_imbal_enb15: default + iq_imbal_enb16: default + iq_imbal_enb17: default + iq_imbal_enb18: default + iq_imbal_enb19: default + iq_imbal_enb2: default + iq_imbal_enb20: default + iq_imbal_enb21: default + iq_imbal_enb22: default + iq_imbal_enb23: default + iq_imbal_enb24: default + iq_imbal_enb25: default + iq_imbal_enb26: default + iq_imbal_enb27: default + iq_imbal_enb28: default + iq_imbal_enb29: default + iq_imbal_enb3: default + iq_imbal_enb30: default + iq_imbal_enb31: default + iq_imbal_enb4: default + iq_imbal_enb5: default + iq_imbal_enb6: default + iq_imbal_enb7: default + iq_imbal_enb8: default + iq_imbal_enb9: default + lo_export0: 'False' + lo_export1: 'False' + lo_export10: 'False' + lo_export11: 'False' + lo_export12: 'False' + lo_export13: 'False' + lo_export14: 'False' + lo_export15: 'False' + lo_export16: 'False' + lo_export17: 'False' + lo_export18: 'False' + lo_export19: 'False' + lo_export2: 'False' + lo_export20: 'False' + lo_export21: 'False' + lo_export22: 'False' + lo_export23: 'False' + lo_export24: 'False' + lo_export25: 'False' + lo_export26: 'False' + lo_export27: 'False' + lo_export28: 'False' + lo_export29: 'False' + lo_export3: 'False' + lo_export30: 'False' + lo_export31: 'False' + lo_export4: 'False' + lo_export5: 'False' + lo_export6: 'False' + lo_export7: 'False' + lo_export8: 'False' + lo_export9: 'False' + lo_source0: internal + lo_source1: internal + lo_source10: internal + lo_source11: internal + lo_source12: internal + lo_source13: internal + lo_source14: internal + lo_source15: internal + lo_source16: internal + lo_source17: internal + lo_source18: internal + lo_source19: internal + lo_source2: internal + lo_source20: internal + lo_source21: internal + lo_source22: internal + lo_source23: internal + lo_source24: internal + lo_source25: internal + lo_source26: internal + lo_source27: internal + lo_source28: internal + lo_source29: internal + lo_source3: internal + lo_source30: internal + lo_source31: internal + lo_source4: internal + lo_source5: internal + lo_source6: internal + lo_source7: internal + lo_source8: internal + lo_source9: internal + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + num_mboards: '1' + otw: '' + rx_agc0: Default + rx_agc1: Default + rx_agc10: Default + rx_agc11: Default + rx_agc12: Default + rx_agc13: Default + rx_agc14: Default + rx_agc15: Default + rx_agc16: Default + rx_agc17: Default + rx_agc18: Default + rx_agc19: Default + rx_agc2: Default + rx_agc20: Default + rx_agc21: Default + rx_agc22: Default + rx_agc23: Default + rx_agc24: Default + rx_agc25: Default + rx_agc26: Default + rx_agc27: Default + rx_agc28: Default + rx_agc29: Default + rx_agc3: Default + rx_agc30: Default + rx_agc31: Default + rx_agc4: Default + rx_agc5: Default + rx_agc6: Default + rx_agc7: Default + rx_agc8: Default + rx_agc9: Default + samp_rate: fs + sd_spec0: '' + sd_spec1: '' + sd_spec2: '' + sd_spec3: '' + sd_spec4: '' + sd_spec5: '' + sd_spec6: '' + sd_spec7: '' + show_lo_controls: 'False' + start_time: '-1.0' + stream_args: '' + stream_chans: '[]' + sync: sync + time_source0: '' + time_source1: '' + time_source2: '' + time_source3: '' + time_source4: '' + time_source5: '' + time_source6: '' + time_source7: '' + type: fc32 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [0, 196.0] + rotation: 0 + state: enabled +- name: zeromq_pub_msg_sink_0 + id: zeromq_pub_msg_sink + parameters: + address: tcp://127.0.0.1:5001 + affinity: '' + alias: '' + bind: 'True' + comment: '' + timeout: '10' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [920, 332.0] + rotation: 0 + state: enabled + +connections: +- [adsb_decoder_0, decoded, zeromq_pub_msg_sink_0, in] +- [adsb_demod_0, '0', qtgui_time_sink_x_0, '0'] +- [adsb_demod_0, demodulated, adsb_decoder_0, demodulated] +- [adsb_framer_1, '0', adsb_demod_0, '0'] +- [analog_const_source_x_0, '0', qtgui_time_sink_x_0, '1'] +- [blocks_complex_to_mag_0, '0', adsb_framer_1, '0'] +- [dc_blocker_xx_0, '0', blocks_complex_to_mag_0, '0'] +- [dc_blocker_xx_0, '0', qtgui_freq_sink_x_0, '0'] +- [dc_blocker_xx_0, '0', qtgui_time_sink_x_1, '0'] +- [uhd_usrp_source_0, '0', dc_blocker_xx_0, '0'] + +metadata: + file_format: 1 diff --git a/adsb_rx.py b/adsb_rx.py new file mode 100755 index 0000000..872e3b0 --- /dev/null +++ b/adsb_rx.py @@ -0,0 +1,371 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# +# SPDX-License-Identifier: GPL-3.0 +# +# GNU Radio Python Flow Graph +# Title: ADS-B Receiver +# Author: Matt Hostetter +# GNU Radio version: 3.10.1.1 + +from packaging.version import Version as StrictVersion + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print("Warning: failed to XInitThreads()") + +from PyQt5 import Qt +from gnuradio import eng_notation +from gnuradio import qtgui +from gnuradio.filter import firdes +import sip +from gnuradio import analog +from gnuradio import blocks +from gnuradio import filter +from gnuradio import gr +from gnuradio.fft import window +import sys +import signal +from argparse import ArgumentParser +from gnuradio.eng_arg import eng_float, intx +from gnuradio import uhd +import time +from gnuradio import zeromq +import gnuradio.adsb as adsb + + + +from gnuradio import qtgui + +class adsb_rx(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "ADS-B Receiver", catch_exceptions=False) + Qt.QWidget.__init__(self) + self.setWindowTitle("ADS-B Receiver") + qtgui.util.check_set_qss() + try: + self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) + except: + pass + self.top_scroll_layout = Qt.QVBoxLayout() + self.setLayout(self.top_scroll_layout) + self.top_scroll = Qt.QScrollArea() + self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) + self.top_scroll_layout.addWidget(self.top_scroll) + self.top_scroll.setWidgetResizable(True) + self.top_widget = Qt.QWidget() + self.top_scroll.setWidget(self.top_widget) + self.top_layout = Qt.QVBoxLayout(self.top_widget) + self.top_grid_layout = Qt.QGridLayout() + self.top_layout.addLayout(self.top_grid_layout) + + self.settings = Qt.QSettings("GNU Radio", "adsb_rx") + + try: + if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + else: + self.restoreGeometry(self.settings.value("geometry")) + except: + pass + + ################################################## + # Variables + ################################################## + self.threshold = threshold = 0.010 + self.gain = gain = 60 + self.fs = fs = 2e6 + self.fc = fc = 1090e6 + + ################################################## + # Blocks + ################################################## + self._threshold_tool_bar = Qt.QToolBar(self) + self._threshold_tool_bar.addWidget(Qt.QLabel("Detection Threshold" + ": ")) + self._threshold_line_edit = Qt.QLineEdit(str(self.threshold)) + self._threshold_tool_bar.addWidget(self._threshold_line_edit) + self._threshold_line_edit.returnPressed.connect( + lambda: self.set_threshold(eng_notation.str_to_num(str(self._threshold_line_edit.text())))) + self.top_grid_layout.addWidget(self._threshold_tool_bar, 0, 1, 1, 1) + for r in range(0, 1): + self.top_grid_layout.setRowStretch(r, 1) + for c in range(1, 2): + self.top_grid_layout.setColumnStretch(c, 1) + self._gain_tool_bar = Qt.QToolBar(self) + self._gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": ")) + self._gain_line_edit = Qt.QLineEdit(str(self.gain)) + self._gain_tool_bar.addWidget(self._gain_line_edit) + self._gain_line_edit.returnPressed.connect( + lambda: self.set_gain(eng_notation.str_to_num(str(self._gain_line_edit.text())))) + self.top_grid_layout.addWidget(self._gain_tool_bar, 0, 0, 1, 1) + for r in range(0, 1): + self.top_grid_layout.setRowStretch(r, 1) + for c in range(0, 1): + self.top_grid_layout.setColumnStretch(c, 1) + self.zeromq_pub_msg_sink_0 = zeromq.pub_msg_sink('tcp://127.0.0.1:5001', 10, True) + self.uhd_usrp_source_0 = uhd.usrp_source( + ",".join(("", "")), + uhd.stream_args( + cpu_format="fc32", + args='', + channels=list(range(0,1)), + ), + ) + self.uhd_usrp_source_0.set_samp_rate(fs) + self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec(0)) + + self.uhd_usrp_source_0.set_center_freq(fc, 0) + self.uhd_usrp_source_0.set_antenna("RX2", 0) + self.uhd_usrp_source_0.set_gain(gain, 0) + self.qtgui_time_sink_x_1 = qtgui.time_sink_c( + 1024, #size + fs, #samp_rate + "", #name + 1, #number of inputs + None # parent + ) + self.qtgui_time_sink_x_1.set_update_time(0.10) + self.qtgui_time_sink_x_1.set_y_axis(-0.1, 0.1) + + self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_1.enable_tags(True) + self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") + self.qtgui_time_sink_x_1.enable_autoscale(False) + self.qtgui_time_sink_x_1.enable_grid(False) + self.qtgui_time_sink_x_1.enable_axis_labels(True) + self.qtgui_time_sink_x_1.enable_control_panel(False) + self.qtgui_time_sink_x_1.enable_stem_plot(False) + + + labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', + 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ['blue', 'red', 'green', 'black', 'cyan', + 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + styles = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + markers = [-1, -1, -1, -1, -1, + -1, -1, -1, -1, -1] + + + for i in range(2): + if len(labels[i]) == 0: + if (i % 2 == 0): + self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.qwidget(), Qt.QWidget) + self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) + self.qtgui_time_sink_x_0 = qtgui.time_sink_f( + int(fs*150e-6), #size + int(fs), #samp_rate + "", #name + 2, #number of inputs + None # parent + ) + self.qtgui_time_sink_x_0.set_update_time(1.0/100.0) + self.qtgui_time_sink_x_0.set_y_axis(0, 1) + + self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_0.enable_tags(True) + self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0, 1.25e-6, 0, "burst") + self.qtgui_time_sink_x_0.enable_autoscale(False) + self.qtgui_time_sink_x_0.enable_grid(True) + self.qtgui_time_sink_x_0.enable_axis_labels(True) + self.qtgui_time_sink_x_0.enable_control_panel(False) + self.qtgui_time_sink_x_0.enable_stem_plot(False) + + self.qtgui_time_sink_x_0.disable_legend() + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ['blue', 'red', 'green', 'black', 'cyan', + 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + styles = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + markers = [0, -1, -1, -1, -1, + -1, -1, -1, -1, -1] + + + for i in range(2): + if len(labels[i]) == 0: + self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.qwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 2) + for r in range(1, 2): + self.top_grid_layout.setRowStretch(r, 1) + for c in range(0, 2): + self.top_grid_layout.setColumnStretch(c, 1) + self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( + 1024, #size + window.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + fs, #bw + "", #name + 1, + None # parent + ) + self.qtgui_freq_sink_x_0.set_update_time(0.10) + self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0.enable_grid(False) + self.qtgui_freq_sink_x_0.set_fft_average(1.0) + self.qtgui_freq_sink_x_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0.enable_control_panel(False) + self.qtgui_freq_sink_x_0.set_fft_window_normalized(False) + + + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + + for i in range(1): + if len(labels[i]) == 0: + self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.qwidget(), Qt.QWidget) + self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) + self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True) + self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) + self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, threshold) + self.adsb_framer_1 = adsb.framer(fs, threshold) + self.adsb_demod_0 = adsb.demod(fs) + self.adsb_decoder_0 = adsb.decoder("Extended Squitter Only", "None", "Brief") + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.adsb_decoder_0, 'decoded'), (self.zeromq_pub_msg_sink_0, 'in')) + self.msg_connect((self.adsb_demod_0, 'demodulated'), (self.adsb_decoder_0, 'demodulated')) + self.connect((self.adsb_demod_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.adsb_framer_1, 0), (self.adsb_demod_0, 0)) + self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 1)) + self.connect((self.blocks_complex_to_mag_0, 0), (self.adsb_framer_1, 0)) + self.connect((self.dc_blocker_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) + self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) + self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) + self.connect((self.uhd_usrp_source_0, 0), (self.dc_blocker_xx_0, 0)) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "adsb_rx") + self.settings.setValue("geometry", self.saveGeometry()) + self.stop() + self.wait() + + event.accept() + + def get_threshold(self): + return self.threshold + + def set_threshold(self, threshold): + self.threshold = threshold + Qt.QMetaObject.invokeMethod(self._threshold_line_edit, "setText", Qt.Q_ARG("QString", eng_notation.num_to_str(self.threshold))) + self.adsb_framer_1.set_threshold(self.threshold) + self.analog_const_source_x_0.set_offset(self.threshold) + + def get_gain(self): + return self.gain + + def set_gain(self, gain): + self.gain = gain + Qt.QMetaObject.invokeMethod(self._gain_line_edit, "setText", Qt.Q_ARG("QString", eng_notation.num_to_str(self.gain))) + self.uhd_usrp_source_0.set_gain(self.gain, 0) + + def get_fs(self): + return self.fs + + def set_fs(self, fs): + self.fs = fs + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.fs) + self.qtgui_time_sink_x_0.set_samp_rate(int(self.fs)) + self.qtgui_time_sink_x_1.set_samp_rate(self.fs) + self.uhd_usrp_source_0.set_samp_rate(self.fs) + + def get_fc(self): + return self.fc + + def set_fc(self, fc): + self.fc = fc + self.uhd_usrp_source_0.set_center_freq(self.fc, 0) + + + + +def main(top_block_cls=adsb_rx, options=None): + + if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + + tb.start() + + tb.show() + + def sig_handler(sig=None, frame=None): + tb.stop() + tb.wait() + + Qt.QApplication.quit() + + signal.signal(signal.SIGINT, sig_handler) + signal.signal(signal.SIGTERM, sig_handler) + + timer = Qt.QTimer() + timer.start(500) + timer.timeout.connect(lambda: None) + + qapp.exec_() + +if __name__ == '__main__': + main() diff --git a/webserver.py b/webserver.py new file mode 100755 index 0000000..cc17d70 --- /dev/null +++ b/webserver.py @@ -0,0 +1,46 @@ +import zmq +import pmt + +def zmq_pdu_subscriber(): + context = zmq.Context() + socket = context.socket(zmq.SUB) + + # 连接到GNU Radio的ZMQ Pub Sink + # 地址和端口需要与GNU Radio流图中的配置一致 + socket.connect("tcp://localhost:5001") + socket.setsockopt_string(zmq.SUBSCRIBE, "") + + print("等待接收ADS-B PDU消息...") + + try: + while True: + # 接收二进制PDU数据 + pdu_bin = socket.recv() + + # 反序列化PDU + pdu = pmt.deserialize_str(pdu_bin) + + # 提取数据部分(pmt.car获取PDU的数据) + plane = pmt.to_python(pmt.car(pdu)) + + # 处理ADS-B飞机数据 + print("收到飞机数据:") + print(f" ICAO地址: {plane.get('icao', 'N/A')}") + print(f" 时间: {plane.get('datetime', 'N/A')}") + print(f" 经度: {plane.get('longitude', 'N/A')}") + print(f" 纬度: {plane.get('latitude', 'N/A')}") + print(f" 高度: {plane.get('altitude', 'N/A')} 英尺") + print(f" 速度: {plane.get('speed', 'N/A')} 节") + print(f" 航向: {plane.get('heading', 'N/A')}°") + print("-" * 50) + + except KeyboardInterrupt: + print("\n接收端停止") + except Exception as e: + print(f"处理数据时出错: {e}") + finally: + socket.close() + context.term() + +if __name__ == "__main__": + zmq_pdu_subscriber()
\ No newline at end of file |
