Re: [Discuss-gnuradio] embedded-python block for pocsag paging: help request by first-time GR programer

2018-08-30 Thread Kristoff

Hi Kevin,


(inline comments).



On 27-08-18 02:57, Kevin Reid wrote:

Some partial answers, from memory and not necessarily correct:

Well, they where usefull anyway, so thanks. :-)





On Sun, Aug 26, 2018 at 1:26 PM Kristoff > wrote:


- Can somebody explain how to implement a source-block using
embedded-python?
In the code I have now, it is implemented as a sync-block, taking
in a
signal from a signal-generator block, but that is probably
(surely!) not
the correct way to do this.


A source block is just a block with no inputs. I haven't yet tried it 
in Python but it /should/ be simply specifying in_sig=[] in the 
__init__. This means that your work function will be called repeatedly 
rather than only when input data is available.

Correct.

Got that to work. Thx!

But do note that  you should also use "self.set_output_multiple" to set 
the number of bits you will send into the output queue every time the 
"work" function is called.




I did notice that the signal-generator blocks that exists in GRC
do have
a input-port that is greyed-out and not connected. I probably need to
implement something simular.


No, gray ports in GRC are message ports for receiving control 
messages. It is a separate additional feature of that block and not 
one you have to implement.

OK. I didn'tknow these block have control-ports. I should look into that :-)


(cut some more interesting stuff .. thx for that :-) )






- Basically, a pocsag paging-message is a packet, not a continuous
stream.
It is possible to create a source-block that creates a stream of a
limited length and then stop the execution of the graph?


There are two things you can do depending on what you need.

You can return -1 from the work function to indicate you are done. 
This propagates to downstream blocks, and causes the top_block.wait() 
call that exists in most GR programs to stop waiting and return, but 
it can instead choose to (reconfigure and) restart the flow graph if 
you have an application where that makes sense.


For some reason, tThat didn't work in my case. Returning -1 from the 
worker function did not stop the flow-graph.


I do get a lot of "U"s in the console, but the application does not stop.
No idea why this is.


If you mean you want to pause work and resume when the next packet 
comes along, then your source should just block until more data is 
available. You might need to pad the output with zeroes at the end to 
ensure the packet isn't cut off by sitting in partial buffers.


That DID work, .. starving the output-channel did caused the osmocom 
transmitter-module to stop transmit, .. but it did not revive when I 
restarted sending data out the egress port.


In my case, it was OK as I only wanted to send one single packet, but it 
does not looks to be a sollution for just switching on and off a 
transmitter.

OK. It's good enough for what I needed it for.





(I haven't worked with the second approach, so there might be other 
caveats, and there may be better tools — my work with GNU Radio has 
been primarily analog/continuous receiving rather than 
transmitters/transceivers using packets.)

No problem.
Thanks for your reply. It was very helpfull.


Kristoff

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] runtime error while running flowgraph

2018-08-30 Thread Rensi Mathew
 I am trying to implement this discussion:[Discuss-gnuradio] Change frequency 
in USRPsource 
automatically(https://lists.gnu.org/archive/html/discuss-gnuradio/2016-03/msg00402.html).
 My objective is to create a block which changes the frequency automatically in 
steps of 2e6, starting from 2.37e9.

My block has a code given below:
import stringimport numpy
import pmt
from gnuradio import gr
from gnuradio import digital

class frew_sweep_v1_f(gr.sync_block):
    """
    docstring for block frew_sweep_v1_f
    """
    def __init__(self,initial_freq=2.37e9, step=2e6):
    gr.sync_block.__init__(self,
    name="frew_sweep_v1_f",
    in_sig=[],
    out_sig=[])

    self.message_port_register_in(pmt.intern('clock'))
        self.message_port_register_out(pmt.intern('sync'))
    self.set_msg_handler(pmt.intern('clock'),self.handler)
    self.freq=initial_freq
    self.step=step

    def handler(self,pdu):
    
self.message_port_pub(pmt.intern('sync'),pmt.cons(pmt.intern("freq"),pmt.to_pmt(self.freq)))
    self.freq+=self.step
the xml file has a code  given below:
 

  frew_sweep_v1_f
  tutorial_frew_sweep_v1_f
  [tutorial]
  import tutorial
  from gnuradio.digital import packet_utils
  tutorial.frew_sweep_v1_f($initial_freq, $step)
  post_message($msg)
  
    message
    msg
    string
  
  
    in
    message
  
 
  
    out
    message
  


I inserted this new block between a message block and message debug block.The 
new top_block code generated is given below:

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 PyQt4 import Qt
from gnuradio import digital
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.digital import packet_utils
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import pmt
import sys
import tutorial
from gnuradio import qtgui


class top_blockRSM_frew_sweepv1(gr.top_block, Qt.QWidget):

    def __init__(self):
    gr.top_block.__init__(self, "Top Blockrsm Frew Sweepv1")
    Qt.QWidget.__init__(self)
    self.setWindowTitle("Top Blockrsm Frew Sweepv1")
    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", "top_blockRSM_frew_sweepv1")
    self.restoreGeometry(self.settings.value("geometry").toByteArray())

    ##
    # Variables
    ##
    self.samp_rate = samp_rate = 32000

    ##
    # Blocks
    ##
    self.tutorial_frew_sweep_v1_f_0 = Template error: 
tutorial.frew_sweep_v1_f($initial_freq, $step)
    cannot find 'initial_freq'
    self.blocks_message_strobe_0 = 
blocks.message_strobe(pmt.intern("freq"), 1)
    self.blocks_message_debug_0 = blocks.message_debug()

    ##
    # Connections
    ##
    self.msg_connect((self.blocks_message_strobe_0, 'strobe'), 
(self.tutorial_frew_sweep_v1_f_0, 'in'))
    self.msg_connect((self.tutorial_frew_sweep_v1_f_0, 'out'), 
(self.blocks_message_debug_0, 'print'))

    def closeEvent(self, event):
    self.settings = Qt.QSettings("GNU Radio", "top_blockRSM_frew_sweepv1")
    self.settings.setValue("geometry", self.saveGeometry())
    event.accept()

    def get_samp_rate(self):
    return self.samp_rate

    def set_samp_rate(self, samp_rate):
    self.samp_rate = samp_rate


def main(top_block_cls=top_blockRSM_frew_sweepv1, options=None):

    from distutils.version import StrictVersion
    if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.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 quitting():
    tb.stop()
    

[Discuss-gnuradio] OFDM Carrier Allocator

2018-08-30 Thread dapodun nudopad
Hello, I have trouble assigning parameters to sync words in OFDM Carrier
allocator block in gnu radio.
Does anyone has an example to share.
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio