UDP fread not returning entire datagram

1 次查看(过去 30 天)
Jay
Jay 2013-4-15
I have an application where I am using UDP to get data from another application. I have my UDP object in DatagramTerminateMode, and I am calling fread in my callback.
The application was working just fine until today, and I am not exactly sure what I changed. Some calls to fread are only returning 256 bytes instead of roughly 8000 bytes. If I add a command to my callback and leave off the semicolon it seems to make everything work again.
This would suggest that fread is being called before data is ready, but I am in DatagramTerminateMode so there should always be a datagram available when the callback is executed.
You may also be thinking... "are you sure that datagram isn't actually 256 bytes?" Well I am rather certain that is it not... When I debug the other application it appear to never be sending a datagram less than 8000 bytes.
  11 个评论
Jay
Jay 2013-4-19
编辑:Jay 2013-4-19
I have modified the data portion of the UDP packets to simply be:
  • int32 Index
  • lots of zeros
  • 0xAA
I am using this index to line up the erronous packets in matlab with the packets in wireshark.
I run my matlab application with a breakpoint checking whether the entire datagram was read. I break in the case that there is a partially read datagram. I then read out the packet index from matlab and find that packet in wireshark.
Wireshark shows the packet correctly: index, lots of zeros, 0xAA. 505 bytes of data total.
Matlab reports that there are 505 data bytes, but only read 391 bytes. The bytes that it read are correct, it just ends before it gets to the 0xAA.
As a precaution I have set udpobject.Terminator = '';
Walter Roberson
Walter Roberson 2013-4-19
I think you should take this to tech support.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multicore Processor Targets 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by