#!/usr/bin/env python # GNU Radio blocks for the Red Pitaya transceiver # Copyright (C) 2015 Renzo Davoli # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os import numpy import struct import socket from gnuradio import gr, blocks class source(gr.hier_block2): '''Red Pitaya Source''' rates = {20000:0, 50000:1, 100000:2, 250000:3, 500000:4, 1250000:5} def __init__(self, addr, port, freq, rate, corr): gr.hier_block2.__init__( self, name = "red_pitaya_source", input_signature = gr.io_signature(0, 0, 0), output_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex) ) self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.ctrl_sock.connect((addr, port)) self.ctrl_sock.send(struct.pack('