udp fread issue

Asked by matthew martinez on 20 Jun 2012
Latest activity Commented on by matthew martinez on 26 Jun 2012

I am sending data through ethernet from my pc to a virtex 6 fpga board. I am able to save the data in the fpga perfectly. Now I am having problems reading back data when needed. here is my matlab code:

u = udp('192.168.1.255','localport',9091,'remoteport',7,'timeout',15,'DatagramTerminateMode','off','timeout',15,'inputbuffersize',1200,'outputbuffersize',1200);
fopen(u);
fwrite(u,dataout,'uint8');
read= fread(u);

but read comes back empty and the following error message is seen:

Warning: The specified amount of data was not returned within the
Timeout period.

any help would be great! thanks!

0 Comments

matthew martinez

Tags

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 20 Jun 2012

You turned off datagramterminatemode, so fread() is not going to look for any kind of terminator. Instead it is going to look only for timeout or for the input buffer to be full. You have set that size to 1200, so if you do not receive 1200 bytes of data before the timeout (15 seconds) then you are going to get that warning message.

44 Comments

matthew martinez on 22 Jun 2012

I was thinking about reading the broadcast adress in C and seeing what I can get and sending the packet from matlab

Walter Roberson on 22 Jun 2012

Hmmm, messy. You would need to socket() AF_INET SOCK_RAW

http://sock-raw.org/papers/sock_raw has some fairly dense technical details. There must be something around with a better overview.

(My university days predate TCP/IP being finalized...)

matthew martinez on 26 Jun 2012

just a little update, I decided to make a change in the source code...The destination and source were being swapped on the fpga side so that the source becomes the destination and the destination becomes the source. I decided to hardcode the computer adress into the destination and try to read from that adress without luck...Also tried using the fpga adress for the source so that the comp might accept the message since it recognizes the source. Still no luck but going to try some more changes on the fpga side if you have any advice it would be greatly appreciated.

Walter Roberson
Answer by matthew martinez on 20 Jun 2012

Thanks, your probably right, but I'm more concerned with reading the data from the fpga. I'm getting nothing from fread after writing I should get dataout back. I checked the fpga side and I am getting the correct output. I just cant recieve it back into matlab.

0 Comments

matthew martinez

Contact us