def __init__(self, queue, evt_type, evt_length):
     threading.Thread.__init__(self);
     self.d_type = evt_type;
     self.key_sym = pmt.pmt_intern("key");
     self.queue = queue;
     self.evt_length = evt_length;
     try:
         self.queue.register_event_type( pmt.pmt_intern( self.d_type ) );
     except:
         print "queue must be a valid es.queue !"
         sys.exit(-1);
	def __init__(self, baudrate=19200, device="/dev/pts/3"):
		grc_wxgui.top_block_gui.__init__(self, title="Simple Message Passing Example")

		##################################################
		# Parameters
		##################################################
		self.baudrate = baudrate
		self.device = device

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

		##################################################
		# Blocks
		##################################################
		self.openavionics_serial_io_0 = openavionics.serial_io(device,0,baudrate,0,1,False)
		self.blocks_message_strobe_0 = blocks.message_strobe(pmt.pmt_intern("TEST"), 1000)
		self.blocks_message_debug_0 = blocks.message_debug()

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.blocks_message_strobe_0, "strobe", self.openavionics_serial_io_0, "in")
		self.msg_connect(self.openavionics_serial_io_0, "out", self.blocks_message_debug_0, "print")
Пример #3
0
def keypress(event):
    print "evt running"
    if(event.keysym == 'Escape'):
        root.destroy();
    x = event.char
    print x;
    key_evt = es.event_create("key-press", 0, int(100e-3 * fs) );
    key_evt = es.event_args_add( key_evt, key_sym, pmt.pmt_intern(str(x)) );
    queue.add_event( key_evt );
Пример #4
0
 def __init__(self, msg_buf_name_in, msg_buf_name_out, N_rb_dl, ant_port):
     gr.sync_block.__init__(self,
         name="estimator_parameterizer_msg",
         in_sig=None,
         out_sig=None)
     #print msg_buf_name_in
     #print msg_buf_name_out
     #print N_rb_dl
     #print ant_port
     
     self.N_rb_dl = N_rb_dl
     self.ant_port = ant_port
     self.msg_buf_in = pmt.pmt_intern(msg_buf_name_in)
     self.msg_buf_out = pmt.pmt_intern(msg_buf_name_out)
     
     self.message_port_register_in(self.msg_buf_in)
     self.set_msg_handler(self.msg_buf_in, self.handle_msg)
     self.message_port_register_out(self.msg_buf_out)
Пример #5
0
    def run(self):
        while(self.count == -1 or self.count > 0):
            time.sleep(self.delay);
            timer_evt = es.event_create(self.d_type, 0, self.evt_length);
            timer_evt = es.event_args_add( timer_evt, pmt.pmt_intern("timer_counter"), pmt.pmt_from_long(self.count));
            self.queue.add_event( timer_evt );

            if(self.count > 0):
                self.count = self.count - 1;
Пример #6
0
 def __init__(self, queue, evt_type, evt_length, delay, count=-1):
     threading.Thread.__init__(self);
     self.d_type = evt_type;
     self.queue = queue;
     self.count = count;
     self.delay = delay;
     self.evt_length = evt_length;
     try:
         self.queue.register_event_type( pmt.pmt_intern( self.d_type ) );
     except:
         print "queue must be a valid es.queue !"
         sys.exit(-1);
Пример #7
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gr-eventstream; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.

import sys;
from gnuradio import gr, audio;
import es;
from gruel import pmt;

fs = 48e3;
evt_len = int(100e-3*fs);
key_sym = pmt.pmt_intern("key");

# Create our handler flowgraph, define the event's sources and/or sinks
def key_factory(index):
    print "FACTORY CALLED index = %d"%(index);
    r = es.es_pyhandler();
    src_L = gr.sig_source_f( 48e3, gr.GR_SIN_WAVE, 1440.0, 1.0, 0 );
    src_R = gr.sig_source_f( 48e3, gr.GR_SIN_WAVE, 480.0, 1.0, 0 );
    head_L = gr.head( gr.sizeof_float, evt_len );
    head_R = gr.head( gr.sizeof_float, evt_len );

    r.sink = es.vector_sink([gr.sizeof_float, gr.sizeof_float]);
    tb  = gr.top_block();
    tb.connect( (src_L,0), (head_L,0), (r.sink,0) );
    tb.connect( (src_R,0), (head_R,0), (r.sink,1) );
 def keypress(self, event):
     x = event.char;
     print "KEYPRESS!: %s"%(x);    
     key_evt = es.event_create(self.d_type, 0, self.evt_length);
     key_evt = es.event_args_add( key_evt, self.key_sym, pmt.pmt_intern(str(x)) );
     self.queue.add_event( key_evt );
#ph.run_factory();

ph.set_pyfactory_cb(test_factory_cb);
h = ph.run_factory();

ph.set_pyfactory_cb(test_factory_cb);
ph.run_factory();

ph.set_pyfactory_cb(test_factory_cb);
ph.run_factory();

ph.set_pyfactory_cb(test_factory_cb);
ph.run_factory();

a = ph.empty_vec();
b = pmt.pmt_intern("test");
c = es.stdMapStringBlock();

ph.set_pypre_hook_cb(test_hook_cb);
ph.set_pypost_hook_cb(test_hook_cb);


ph.run_pre_hook(a,b,h);
print "pre hook ran"

ph.run_post_hook(a,b,h);
print "post hook ran"



Пример #10
0
# Boston, MA 02110-1301, USA.

import random;
import time;
import sys;
from gnuradio import gr, audio;
import es;
from gruel import pmt;
import numpy;

SNR_db = 13;
sig_amp = 1.0;
noise_amp = 10**(-20.0/SNR_db);
print sig_amp, noise_amp;
fs = 1e5;
key_sym = pmt.pmt_intern("key");

# Create our handler flowgraph, define the event's sources and/or sinks
def key_factory(index):
    print "FACTORY CALLED index = %d"%(index);
    
    r = es.es_pyhandler();

    excess_bw = 0.5;
    sps = 4;
    amplitude = sig_amp;
    taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
                        sps,        # Sampling rate
                        1.0,        # Symbol rate
                        excess_bw,      # Roll-off factor
                        11*sps)         # Number of taps