GNU Radio TCP and MATLAB

Hello again,
I have decided to try the GNURadio → TCP → MATLAB route. I am
running
into a few problems.

First, I downloaded Jamie Cooley’s GNURadio TCP Socket code here…

http://alumni.media.mit.edu/~jcooley/gr_experiments/experiments/gr_socket.ht
m

Then I downloaded a free matlab TCP toolbox as David suggested.

http://www.mathworks.nl/matlabcentral/fileexchange/loadFile.do?objectId=345&
objectType=file

I can set up the connection and send data to matlab, but the data I
receive
is all messed up. I think the format is off. For those who have done
this,
what data type are you sending and how are you receiving it? Currently,
I
am just sending a complex sine wave. If I sink it to a file, I can open
it
in matlab with no problem. But when I send it via TCP, I get garbage.

My matlab commands are basically…

Con = pnet(sock,‘tcplisten’);
data = pnet(con, ‘read’, 1000, ‘SINGLE’);
cdata = data(1:2:end)+j*data(2:2:end);
plot(log(abs(fft(cdata))))

Is ‘SINGLE’ the correct type to use? (I tried all the others and I still
get
gargabe).

Thanks for the help,
Kevin

On Thu, Apr 26, 2007 at 12:52:40PM -0400, Kevin Rudd (Contractor) wrote:

http://www.mathworks.nl/matlabcentral/fileexchange/loadFile.do?objectId=345&
Con = pnet(sock,‘tcplisten’);
data = pnet(con, ‘read’, 1000, ‘SINGLE’);
cdata = data(1:2:end)+j*data(2:2:end);
plot(log(abs(fft(cdata))))

Is ‘SINGLE’ the correct type to use? (I tried all the others and I still get
gargabe).

Thanks for the help,
Kevin

Not sure about the MATLAB end of things, but gr.file_descriptor_sink
will be sending binary native-endian data. The format will depend on
what you’re sending into it. float or gr_complex (==
std::complex)
are the usual suspects. Is the MATLAB code expecting binary or ASCII
data?

Eric

Thanks for the suggestion. I dove into the TCP code to try and figure
out
what it was doing. I found my problem. I have to use the following
read
command…

data = pnet(con, ‘read’, 1000, ‘SINGLE’, ‘NATIVE’);

Now I notice that matlab seems to be lag behind the USRP. So, maybe
matlab
is not the best path to process the data in realtime. I am curious what
the
best data rate someone has sustained using a TCP connection.

If I get it up and going, I will post my code and a howto so others can
stream data to and from MATLAB in real time.

Thanks,
Kevin

On Thu, Apr 26, 2007 at 02:48:34PM -0400, Kevin Rudd (Contractor) wrote:

Thanks for the suggestion. I dove into the TCP code to try and figure out
what it was doing. I found my problem. I have to use the following read
command…

data = pnet(con, ‘read’, 1000, ‘SINGLE’, ‘NATIVE’);

Now I notice that matlab seems to be lag behind the USRP. So, maybe matlab
is not the best path to process the data in realtime. I am curious what the
best data rate someone has sustained using a TCP connection.

TCP on GigE can do upwards of 100MB/s :wink:

If I get it up and going, I will post my code and a howto so others can
stream data to and from MATLAB in real time.

Thanks.

Eric