コード例 #1
0
    def __init__(self, mode='MODE-S', input_rate=0, context=None):
        assert input_rate > 0
        gr.hier_block2.__init__(
            self,
            type(self).__name__, gr.io_signature(1, 1,
                                                 gr.sizeof_gr_complex * 1),
            gr.io_signature(0, 0, 0))

        demod_rate = 2000000
        transition_width = 500000

        hex_msg_queue = gr.msg_queue(100)

        self.__band_filter = MultistageChannelFilter(
            input_rate=input_rate,
            output_rate=demod_rate,
            cutoff_freq=demod_rate / 2,
            transition_width=transition_width)  # TODO optimize filter band
        self.__demod = air_modes.rx_path(
            rate=demod_rate,
            threshold=7.0,  # default used in air-modes code but not exposed
            queue=hex_msg_queue,
            use_pmf=False,
            use_dcblock=True)
        self.connect(self, self.__band_filter, self.__demod)

        self.__messages_seen = 0
        self.__message_rate_calc = LazyRateCalculator(
            lambda: self.__messages_seen, min_interval=2)

        # Parsing
        # TODO: These bits are mimicking gr-air-modes toplevel code. Figure out if we can have less glue.
        # Note: gr pubsub is synchronous -- subscribers are called on the publisher's thread
        parser_output = gr.pubsub.pubsub()
        parser = air_modes.make_parser(parser_output)
        cpr_decoder = air_modes.cpr_decoder(
            my_location=None)  # TODO: get position info from device
        air_modes.output_print(cpr_decoder, parser_output)

        def msq_runner_callback(msg):  # called on msgq_runner's thread
            # pylint: disable=broad-except
            try:
                reactor.callFromThread(parser, msg.to_string())
            except Exception:
                print(traceback.format_exc())

        self.__msgq_runner = gru.msgq_runner(hex_msg_queue,
                                             msq_runner_callback)

        def parsed_callback(msg):
            timestamp = time.time()
            self.__messages_seen += 1
            context.output_message(
                ModeSMessageWrapper(msg, cpr_decoder, timestamp))

        for i in six.moves.range(0, 2**5):
            parser_output.subscribe('type%i_dl' % i, parsed_callback)
コード例 #2
0
ファイル: __init__.py プロジェクト: langxj/shinysdr
 def __init__(self, mode='MODE-S', input_rate=0, mode_s_information=None, context=None):
     assert input_rate > 0
     gr.hier_block2.__init__(
         self, 'Mode S/ADS-B/1090 demodulator',
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
         gr.io_signature(0, 0, 0))
     self.mode = mode
     self.input_rate = input_rate
     if mode_s_information is not None:
         self.__information = mode_s_information
     else:
         self.__information = ModeSInformation()
     
     hex_msg_queue = gr.msg_queue(100)
     
     band_filter = MultistageChannelFilter(
         input_rate=input_rate,
         output_rate=demod_rate,
         cutoff_freq=demod_rate / 2,
         transition_width=transition_width)  # TODO optimize filter band
     self.__demod = air_modes.rx_path(
         rate=demod_rate,
         threshold=7.0,  # default used in air-modes code but not exposed
         queue=hex_msg_queue,
         use_pmf=False,
         use_dcblock=True)
     self.connect(
         self,
         band_filter,
         self.__demod)
     
     self.__messages_seen = 0
     self.__message_rate_calc = LazyRateCalculator(lambda: self.__messages_seen, min_interval=2)
     
     # Parsing
     # TODO: These bits are mimicking gr-air-modes toplevel code. Figure out if we can have less glue.
     # Note: gr pubsub is synchronous -- subscribers are called on the publisher's thread
     parser_output = gr.pubsub.pubsub()
     parser = air_modes.make_parser(parser_output)
     cpr_decoder = air_modes.cpr_decoder(my_location=None)  # TODO: get position info from device
     air_modes.output_print(cpr_decoder, parser_output)
     def callback(msg):  # called on msgq_runner's thrad
         # pylint: disable=broad-except
         try:
             reactor.callFromThread(parser, msg.to_string())
         except Exception:
             print traceback.format_exc()
     
     self.__msgq_runner = gru.msgq_runner(hex_msg_queue, callback)
     
     def parsed_callback(msg):
         self.__messages_seen += 1
         self.__information.receive(msg, cpr_decoder)
     
     for i in xrange(0, 2 ** 5):
         parser_output.subscribe('type%i_dl' % i, parsed_callback)
コード例 #3
0
ファイル: __init__.py プロジェクト: gstark307/shinysdr
    def __init__(self,
                 mode='MODE-S',
                 input_rate=0,
                 mode_s_information=None,
                 context=None):
        assert input_rate > 0
        gr.hier_block2.__init__(
            self, 'Mode S/ADS-B/1090 demodulator',
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(0, 0, 0))
        self.mode = mode
        self.input_rate = input_rate
        if mode_s_information is not None:
            self.__information = mode_s_information
        else:
            self.__information = ModeSInformation()

        hex_msg_queue = gr.msg_queue(100)

        band_filter = MultistageChannelFilter(
            input_rate=input_rate,
            output_rate=demod_rate,
            cutoff_freq=demod_rate / 2,
            transition_width=transition_width)  # TODO optimize filter band
        self.__demod = air_modes.rx_path(
            rate=demod_rate,
            threshold=7.0,  # default used in air-modes code but not exposed
            queue=hex_msg_queue,
            use_pmf=False,
            use_dcblock=True)
        self.connect(self, band_filter, self.__demod)

        # Parsing
        # TODO: These bits are mimicking gr-air-modes toplevel code. Figure out if we can have less glue.
        # Note: gr pubsub is synchronous -- subscribers are called on the publisher's thread
        parser_output = gr.pubsub.pubsub()
        parser = air_modes.make_parser(parser_output)
        cpr_decoder = air_modes.cpr_decoder(
            my_location=None)  # TODO: get position info from device
        air_modes.output_print(cpr_decoder, parser_output)

        def callback(msg):  # called on msgq_runner's thrad
            # pylint: disable=broad-except
            try:
                reactor.callFromThread(parser, msg.to_string())
            except Exception:
                print traceback.format_exc()

        self.__msgq_runner = gru.msgq_runner(hex_msg_queue, callback)

        def parsed_callback(msg):
            self.__information.receive(msg, cpr_decoder)

        for i in xrange(0, 2**5):
            parser_output.subscribe('type%i_dl' % i, parsed_callback)