Hello everyone,
I have been attempting to make my own block that sends out a boolean message if certain time related conditions are met.
I am unable to figure out why my block does not work. This seems to be the line of interest:
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_T)
This line should cause the block to output a PMT true through port msg_out right?
My full block is attached bellow. Any help would be greatly appreciated.
Thank you all for your time,
Ali
import numpy as np
from gnuradio import gr
import pmt
import datetime
class msg_block(gr.basic_block): # other base classes are basic_block, decim_block, interp_block
"""This block checks time and sends true or false if capture period is desired"""
def __init__(self, minutes=15, seconds=10): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.basic_block.__init__(
self,
name='Time Enable', # will show up in GRC
in_sig=None,
out_sig=None
)
self.message_port_register_out(pmt.intern('msg_out'))
now = datetime.datetime.now()
#P_true = pmt.PMT_T
#P_false = pmt.PMT_F
if ((now.minute % minutes) == 0): #check if minute is ok
if (now.second < seconds): #check if capture period is ok
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_T)
else:
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_F)
else:
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_F)
def work(self, input_items, output_items):
pass
from gnuradio import gr
import pmt
import datetime
class msg_block(gr.basic_block): # other base classes are basic_block, decim_block, interp_block
"""This block checks time and sends true or false if capture period is desired"""
def __init__(self, minutes=15, seconds=10): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.basic_block.__init__(
self,
name='Time Enable', # will show up in GRC
in_sig=None,
out_sig=None
)
self.message_port_register_out(pmt.intern('msg_out'))
now = datetime.datetime.now()
#P_true = pmt.PMT_T
#P_false = pmt.PMT_F
if ((now.minute % minutes) == 0): #check if minute is ok
if (now.second < seconds): #check if capture period is ok
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_T)
else:
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_F)
else:
self.message_port_pub(pmt.intern('msg_out'), pmt.PMT_F)
def work(self, input_items, output_items):
pass
=====================================
No comments:
Post a Comment