LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

tcp

Hi i have this code that i make but ´dont work!?
 
hi work with serial port and for this i constructu similar code and fuctionaly correctely. i used in serial comunication a porperty node for read the number of the bytes but i dont know if it is necessary in tcp/ip!
 
can help me with this code ... my doubt is if i need a porperty node for read numbr of bytes that i received by tcp/ip..
 
Thanks all

Attachment tcp.vi (31 kb)

0 Kudos
Message 1 of 3
(2,833 Views)

I would highly recommend looking at the Example Finder and look at the TCP communication examples.  Also look at the context and labview help for the TCP functions.

With your TCP read, the defaults (since none of the control inputs are wired up) cause it to read in all bytes present after the timeout of 25 seconds occurs.  That means it will take a long time to get data.  It may be incomplete, or it may be getting multiple data points (depending how the other device is sending data).  And the code you have only handles one point at a time.

Another thing I'm not sure about, and someone with more TCP communication experience should answer, is whether you can read and write to the some open port connection.

I would also recommend cleaning up the code by straightening wires, set up data flow from left to write.  Replace the False constant in you main loop with a stop button control.  As you have it now, the only way the code will stop is if you hit the abort button.  When that happens, the TCP close command that occurs after the loop cannot execute.

0 Kudos
Message 2 of 3
(2,822 Views)
I agree with the previous comments. I'm assuming your constants are in there for debugging, but if not...

If you're looking for an equivalent to the "Bytes at Serial Port" function for TCP, there isn't one, since TCP doesn't use a UART like the serial port. This means you need to know how many bytes to read, or just wire in a large number and wait for the timeout. Usually when you set up a communication scheme using TCP/IP you set up a protocol in which the receiver knows what to expect. As pointed out, look at the examples that ship with LabVIEW. The "Simple Data Client" and "Simple Data Server" show this mechanism.
0 Kudos
Message 3 of 3
(2,803 Views)