I'm currently trying to send data from a python code to a GNUradio SUB Message block but I've an issue. I think I don't configure correctly my socket or my data must be preambled but I don't find any solutions from the web.
Here is my GNUradio blocks : GNUradio block
Here is my python code which generates an error :
import zmq
import time
ctx = zmq.Context()
socket = ctx.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:4444")
tab = [0xFF] * 256
tab = bytes(tab)
print("Starting loop...")
while True:
socket.send(tab)
time.sleep(5)
Here is my GNUradio error :
**Generating: '/home/X/test.py'
Executing: /usr/bin/python3 -u /home/X/test.py
Warning: failed to XInitThreads()
terminate called after throwing an instance of 'pmt::exception'
what(): pmt::deserialize: malformed input stream, tag value = : 255
Done (return code -6)**
If I try with this python code :
import zmq
import time
ctx = zmq.Context()
socket = ctx.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:4444")
tab = [0x00] * 256
tab = bytes(tab)
print("Starting loop...")
while True:
socket.send(tab)
time.sleep(5)
I've got this result on GNUradio :
**Generating: '/home/X/test.py'
Executing: /usr/bin/python3 -u /home/X/test.py
Warning: failed to XInitThreads()
******* MESSAGE DEBUG PRINT ********
#t
********************************************
I'm also seeing different result if I change
tab = [0x00] * 256
to tab = [0x01] * 256
:
Generating: '/home/X/test.py'
Executing: /usr/bin/python3 -u /home/X/test.py
Warning: failed to XInitThreads()
******* MESSAGE DEBUG PRINT ********
#f
************************************
Can someone help me with this please?
Thanks a lot !
Edit :
With the advice of darth baba with this code it works properly :
import zmq
import time
import pmt
ctx = zmq.Context()
socket = ctx.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:4444")
tab = [0xFF] * 256
print("Starting loop...")
while True:
socket.send (pmt.serialize_str(pmt.to_pmt(tab)))
time.sleep(5)
I've got this result on GNUradio :
Generating: '/home/X/test.py'
Executing: /usr/bin/python3 -u /home/X/test.py
Warning: failed to XInitThreads()
******* MESSAGE DEBUG PRINT ********
#(255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255)
************************************