Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
from gnuradio import gr, digital, blocks
from math import pi
def main( ):
fg = transmit_topblock(pi/8, sps=2)
while True:
debug_data =
if debug_data != ():
print debug_data
class transmit_topblock(gr.top_block):
def __init__(self, watermark_angle, sps):
self.source = blocks.udp_source(gr.sizeof_char, "", 12002)
#self.modulator = digital.wbpsk_mod(angle=watermark_angle, samples_per_symbol=sps)
# put the usrp sink here
self.nullsink = blocks.null_sink(gr.sizeof_gr_complex)
# for debugging
self.debug = blocks.vector_sink_b( )
# connect everything
#self.connect(self.source, self.modulator, self.nullsink)
self.connect(self.source, self.debug)
if __name__ == '__main__':
main( )
import socket
UDP_IP = ""
UDP_PORT = 12002
MESSAGE = '\x23\x55\xaa'
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment