Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from gnuradio import gr
- import pmt
- import threading
- class blk(gr.basic_block):
- def __init__(self): # only default arguments here
- gr.basic_block.__init__(
- self,
- name='File Source',
- in_sig=None,
- out_sig=None)
- # create an output port
- self.message_port_register_out(pmt.intern('out'))
- # Start a thread
- self.do_exit = threading.Event()
- self.thread = threading.Thread(target = self.callback)
- self.thread.start()
- def callback(self):
- while not self.do_exit.is_set():
- # read file
- arr = np.fromfile("data.dat", dtype=np.complex64)
- # output file on msg port "out"
- self.message_port_pub(pmt.intern("out"), pmt.cons(pmt.make_dict(), pmt.to_pmt(arr)))
- print("File Source done")
- # close the thread
- self.do_exit.set()
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement