Hello Guys I'm currently in the process of creating a block in python that does two things; takes in a certain number of input items, and once it reaches a certain number of input items 2) it sends a command to the UHD USRP sink block to adjust its gain by a certain amount.
I have a few questions. 1) Is it even possible to create a single block that can accomplish both these tasks? 2) How exactly do I make this block issue the command to adjust the gain after it receives a certain number of values??Below is some code that I currently have constructed for this purpose. I'm pretty new to python so I'm sure this code is probably not the most efficient way but any suggestions are welcome. Tellrell import numpy as np from gnuradio import gr import pmt from random import uniform class blk(gr.sync_block): def __init__(self, initial_gain=5, stop_gain=15, step=0.5)# only default arguments here gr.sync_block.__init__( self, name='Gain Sweeper', in_sig=[np.complex32], out_sig=[np.complex32] ) self.message_port_register_in(pmt.intern('msg_in')) self.set_msg_handler(pmt.intern('msg_in'),self.handle_msg) self.message_port_register_out(pmt.intern('msg_out')) self.gain = initial_gain self.step = step self.stop = stop_gain def handle_msg(self, pdu, a= 0000000000): self.message_port_pub(pmt.intern('msg_out'),pmt.cons (pmt.intern("gain"),pmt.to_pmt(self.gain))) self.gain+=self.step return 1 def work(self, input_items, output_items): in0 = input_items[0] out = output_items[0] while i <= 100000000: sample = in0[i] if i == 100000000: sample = 0 return len(output_items[0])
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio