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)
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)
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)
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6 / self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6/self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self,rate,threshold): gr.hier_block2.__init__(self, "modes_block", gr.io_signature(1,1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0,0,0)) # Output signature self.message_port_register_hier_out("out") #self.message_port_register_hier_out('out') self._queue = gr.msg_queue() self.rx_path = air_modes.rx_path(rate, threshold, self._queue) self.connect(self, self.rx_path) #self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr="inproc://modes-radio-pub") self._queue_to_blob = _queue_to_blob(self._queue)
def __init__(self, rate, threshold): gr.hier_block2.__init__( self, "modes_block", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self.message_port_register_hier_out("out") #self.message_port_register_hier_out('out') self._queue = gr.msg_queue() self.rx_path = air_modes.rx_path(rate, threshold, self._queue) self.connect(self, self.rx_path) #self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr="inproc://modes-radio-pub") self._queue_to_blob = _queue_to_blob(self._queue)