09-11-2012 05:17 AM
Hello All,
suddenly I ran into a weird problem with the TCP Read node. Here is an excerpt of my code:
If I'm still OK, it should wait for 5 bytes during 30 seconds and then return 5 bytes in the data out output or timeout error. The problem is that sometimes it returns no error and zero bytes! How could this happen?
I'm using LV 2009 SP1. If you need any additional info on my application -- just shout.
Any suggestions are highly appreciated!
09-11-2012 09:41 AM
Hi!
TCP Read is waiting the 30s when zero bytes are read?
Does it output a warning if not an error?
Regards,
Marco
09-11-2012 10:01 AM - edited 09-11-2012 10:02 AM
Hi Marco,
thank you for your reply. Both questions are interesting. Never got any warnings from TCP Read—do they exist?
Anyway I'll try to check and get back to you with my results. Thanks again!
09-11-2012 10:04 AM
Maybe the TCP read is returning non-displayable characters. You could try setting your string indicator to hex display.
09-11-2012 10:11 AM
Hello Max,
unfortunately the string is really empty—it's not shown on the VI image but surely I used String Length function to check it.
Many thanks for your reply anyway!
09-11-2012 10:49 AM - edited 09-11-2012 10:50 AM
Do you have some code that "sends" the data which reproduces the problem? That way others can run it on their computers.
09-11-2012 10:51 AM
@endvr wrote:
Hello Max,
unfortunately the string is really empty—it's not shown on the VI image but surely I used String Length function to check it.
Many thanks for your reply anyway!
Where did you check the string length? Did you check it before the case statement? You could be reading partial data and returning a timeout error. Have you verified using probes (better for timing related debugging than breakpoints or execution highlighting) that you are truly executing the true case and not the error case? BTW, it is better to have the indicator outside of the case statement rather than inside it.
09-11-2012 01:42 PM
Hello Greg,
thanks for the reply. Actually this code is communicating with some special hardware so it's impossible to reproduce this situation on another PC.
09-11-2012 01:46 PM
Hi Max,
the code from the picture is just a simplified version of what I did. Actually I add logging to the No Error case and wrote data and its length to the file in case of length<>5. The result was:
,0
,0
,0
Btw, I'm also CLA 😉
Thanks!
09-11-2012 02:26 PM
Have you tried using Wireshark or something similar to capture the network traffic. That may give you a clue as to what is happening. I have been using the TCP primitives since they first came out and have never seen this.