Hello,
I'm trying to make a custom block in GNU Radio with the "Python Block"
block in order to create a TCP server that is continuously receiving
information from a TCP Client created in Python.
The code of my block is the following:
import socket
import numpy as np
from gnuradio import gr
class blk(gr.sync_block):
def __init__(self, address='localhost', port=2002): # only default
arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='TCP Server', # will show up in GRC
in_sig=[],
out_sig=[np.uint8]
)
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.address = address
self.port = port
def work(self, input_items, output_items):
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((self.address, self.port))
server_socket.listen(1)
print("Waiting for connections...")
while True:
client_socket, client_address = server_socket.accept()
try:
print('Connection with {}.'.format(client_address))
while True:
data = client_socket.recv(1024)
if data:
for bytes in data:
output_items[0][:]=bytes
else:
print('No more data from
{}.'.format(client_address))
break
finally:
client_socket.close()
return len(output_items[0])
I try to visualize the bytes arriving from the TCP client, adding a "File
Sink" block. But nothing is written to the file. I can't get the incoming
information to be transmitted over the GNU Radio stream.
The Python client that I use to do the tests is the following:
import socket
import numpy
for i in range(0,10):
s = socket.create_connection(("127.0.0.1", 2002))
gnss_position = 'Latitude: 6461516515654 Longitude: 34168546515231
Altitude: 616516841613 '
print(gnss_position)
s.sendall(bytes(gnss_position,'UTF-8'))
s.close()
Also, with this information, I would like to simulate the sending of data
through a 5G signal characterization, but I have not seen that there are
specific blocks for it.
Thank you. All the best,
Marta
--
INFORMACIÓ SOBRE PROTECCIÓ DE DADES DE LA UNIVERSITAT OBERTA DE
CATALUNYA (UOC)
Us informem que les vostres dades identificatives i les
contingudes en els missatges electrònics i fitxers adjunts es poden
incorporar a les nostres bases de dades amb la finalitat de gestionar les
relacions i comunicacions vinculades a la UOC, i que es poden conservar
mentre es mantingui la relació. Si ho voleu, podeu exercir el dret a
accedir a les vostres dades, rectificar-les i suprimir-les i altres drets
reconeguts normativament adreçant-vos a l'adreça de correu emissora o a
[email protected] <mailto:[email protected]>.
Aquest missatge i qualsevol
fitxer que porti adjunt, si escau, tenen el caràcter de confidencials i
s'adrecen únicament a la persona o entitat a qui s'han enviat.
Així
mateix, posem a la vostra disposició un delegat de protecció de dades que
no només s'encarregarà de supervisar tots els tractaments de dades de la
nostra entitat, sinó que us podrà atendre per a qualsevol qüestió
relacionada amb el tractament de dades. La seva adreça de contacte és
[email protected] <mailto:[email protected]>.
INFORMACIÓN SOBRE PROTECCIÓN DE DATOS DE
LA UNIVERSITAT OBERTA DE CATALUNYA (UOC)
Os informamos de que vuestros
datos identificativos y los contenidos en los mensajes electrónicos y
ficheros adjuntos pueden incorporarse a nuestras bases de datos con el fin
de gestionar las relaciones y comunicaciones vinculadas a la UOC, y de que
pueden conservarse mientras se mantenga la relación. Si lo deseáis, podéis
ejercer el derecho a acceder a vuestros datos, rectificarlos y suprimirlos
y otros derechos reconocidos normativamente dirigiéndoos a la dirección de
correo emisora o a [email protected] <mailto:[email protected]>.
Este mensaje y
cualquier fichero que lleve adjunto, si procede, tienen el carácter de
confidenciales y se dirigen únicamente a la persona o entidad a quien se
han enviado.
Así mismo, ponemos a vuestra disposición a un delegado de
protección de datos que no solo se encargará de supervisar todos los
tratamientos de datos de nuestra entidad, sino que podrá atenderos para
cualquier cuestión relacionada con el tratamiento de datos. Su dirección de
contacto es [email protected] <mailto:[email protected]>.
UNIVERSITAT OBERTA DE
CATALUNYA (UOC) DATA PROTECTION INFORMATION
Your personal data and the data
contained in your email messages and attached files may be stored in our
databases for the purpose of maintaining relations and communications
linked to the UOC, and the data may be stored for as long as these
relations and communications are maintained. If you so wish, you can
exercise your rights to access, rectification and erasure of your data, and
any other legally held rights, by writing to the sender’s email address or
to [email protected] <http://[email protected]>.
This message and, where
applicable, any attachments are confidential and addressed solely to the
individual or organization they were sent to.
The UOC has a data protection
officer who not only supervises the data processing carried out at the
University, but who will also respond to any questions you may have about
this data processing. You can contact our data protection officer by
writing to [email protected] <http://[email protected]>.