discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

messages from Embedded Python block parsed by Message Pair to Var result


From: Edwin van Eggelen
Subject: messages from Embedded Python block parsed by Message Pair to Var results in value None in variable/QT GUI Entry
Date: Sat, 22 May 2021 18:38:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

I am trying to change a variable from within the work function of an Embedded Python block. Within the Embedded Python block I send a message and parse it with Message Pair to Var. When the message is sent by the QT GUI Toggle Button it works as expected ( the correct value is shown). However, when the message is sent from the Embedded Python Block the QT GUI Entry changes to None( So it does not show the right value). The Message Debug shows the correct log in both cases. No error messages are given.

I am running GNURadio 3.9.1.0 on Ubuntu 20.4 ( installed from PPA )

Please find the graph, code from the Python block and log file.

Any help is really appreciated.





Python code in Embedded Python block:

import pmt
import numpy as np
from gnuradio import gr


class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example - a simple multiply const"""

def __init__(self, example_param=1.0): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='Embedded Python Block', # will show up in GRC
in_sig=[np.complex64],
out_sig=[np.complex64]
)
self.message_port_register_out(pmt.intern('msg_out'))
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.example_param = example_param
self.sendMessage=0
self.sendMessageCount=123

def work(self, input_items, output_items):

print (".%d." % (self.sendMessage),end="")
self.sendMessage=self.sendMessage+len(output_items[0])
if (self.sendMessage>=32000):
self.sendMessage=0

key0 = pmt.intern("test")
val0 = pmt.from_long(self.sendMessageCount)

msg = pmt.make_dict()
msg = pmt.dict_add(msg, key0, val0)

self.message_port_pub(pmt.intern('msg_out'), msg);

self.sendMessageCount=self.sendMessageCount+1

"""example: multiply with constant"""
output_items[0][:] = input_items[0] * self.example_param
return len(output_items[0])


Generating: '/home/xxxx/Documents/GNURadio/message.py'

Executing: /usr/bin/python3 -u /home/xxxxx/Documents/GNURadio/message.py

.0..4096..8191..12287..14335..15359..15871..16127..16255..16319..16351..16367..16375..16379..16381..16382..20478..22526..23550..24062..24318..24446..24510..24542..24558..24566..24570..24572..24573..28669..30717..31741.******* MESSAGE DEBUG PRINT ********
((test . 123))<- Message from python block ( None value is shown )
************************************
.0..256..384..448..480..496..504..508..510..511..4607..6655..7679..8191..8447..8575..8639..8671..8687..8695..8699..8701..8702..12798..14846..15870..16382..16638..16766..16830..16862..16878..16886..16890..16892..16893..20989..23037..24061..24573..24829..24957..25021..25053..25069..25077..25081..25083..25084..29180..31228.******* MESSAGE DEBUG PRINT ********
((test . 124))
************************************
.0..512..768..896..960..992..1008..1016..1020..1022..1023..5119..7167..8191..8703..8959..9087..9151..9183..9199..9207..9211..9213..9214..13310..15358..16382..16894..17150..17278..17342..17374..17390..17398..17402..17404..17405..21501..23549..24573..25085..25341..25469..25533..25565..25581..25589..25593..25595.******* MESSAGE DEBUG PRINT ********
(test . 200)<- Message from QT GUI Toggle Button ( shows the correct value in QT GUI Entry)
************************************
.25596..29692..31740.******* MESSAGE DEBUG PRINT ********
((test . 125))
************************************
.0..512..768..896..960..992..1008..1016..1020..1022..1023.******* MESSAGE DEBUG PRINT ********
(test . 100)
************************************
.5119..7167..8191..8703..8959..9087..9151..9183..9199..9207..9211..9213..9214..13310..15358..16382..16894..17150..17278..17342..17374..17390..17398..17402..17404..17405..21501..23549..24573..25085..25341..25469..25533..25565..25581..25589..25593..25595..25596..29692..31740.******* MESSAGE DEBUG PRINT ********
((test . 126))
************************************
.0..512..768..896..960..992..1008..1016..1020..1022..1023.

Attachment: MessageTest.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]