LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP communication

Solved!
Go to solution

Hi everyone

 

I would like to use TCP communication to send temperature sensor data and data from my USB camera to another client pc. I have  tried using remote panels with limited success because of  the bandwidth requirements for the camera. Using the VI attached can someone help me on how I can use TCP communication in this application. An illustration (or reference) would be greatly appreciated .

0 Kudos
Message 1 of 14
(3,916 Views)

Hey,

 

Please have a look at LabVIEWs TCP Examples (e.g. Simple Data Client/Server).

You will need to cast your Temperature Data and you Image Data to String Datatype to send it via TCP/IP.

 

 

Christian

Message 2 of 14
(3,913 Views)

Thanks Christian. I understand the examples you mentioned . What I dont understand is how to combine data from the two loops so I can send  it. 

0 Kudos
Message 3 of 14
(3,901 Views)

The best way to do this would be to have a loop which runs that will send the data to the ultimate destination read a queue. The two loops that are reading data from your devices would post the data to the queue for processing. The data processing loop would get the queued messages and process them in whatever way you need (format, write to file, send to another device, update the UI, etc.). This is essentially the producer/consumer archtiecture. LabVIEW has examples of that as well.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 4 of 14
(3,893 Views)

Hey,

 

I agree with Mark. You might think about synchonization between the temperature data and the image data too.

 

Another thing I forgot to mention is "Network Streams", if you are working with LabVIEW 2010. Just have a look at the examples for more information.

 

 

Thanks,

Christian

0 Kudos
Message 5 of 14
(3,877 Views)

Ok, so here is my shot at what you guys are talking about. The sever and client see each other just fine but I cannot read any of the data. I think that  my problem is that I don't know how to read the scan correctly. Can someone show how to do that ?

Download All
0 Kudos
Message 6 of 14
(3,833 Views)

@sent wrote:

Ok, so here is my shot at what you guys are talking about. The sever and client see each other just fine but I cannot read any of the data. I think that  my problem is that I don't know how to read the scan correctly. Can someone show how to do that ?


Do you know that format of your messages? Are they terminated with a specific character or pattern? A common way for messages to be sent via TCP is to have some type of message header which identifies the message type and generally provides the message length. If you data follows such a protocol you will need to get the specifics of the header. You would then read the header which will let you know how much more data you will need to read. The most basic header is simply the number of data bytes that follow. So the message would consist of a number (generally 4 bytes) followed by the number of bytes for the value of number.

 

If you don't have a message header of any type another way that you can read variable length data (but it is not fool proof) is to read a single character. This is where you would have your overall timeout for receiving a message. If you don't receive a message in the designated amount of time you can perform what ever error handling you need. Once you a read a single character you then begin reading chunks of data (perhaps 1024 bytes at a time) and use a very short timeout. When a timeout occurs on this read that would be an indication that there is no more data. This type of approach only works when you have some time between your messages.

 

The last alternative is if you have some type of message termination character or pattern. In this case you would read data until you see the termination character or pattern.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 14
(3,818 Views)

I would really appreciate an illustration while i continue to read about this ??

0 Kudos
Message 8 of 14
(3,795 Views)
Solution
Accepted by topic author Charles.m

Here is a very basic example.

 

Do not run this because the code is not functional for the parallel communications. This is for example only. To actually use each method the read in the top most setion of code should be replaced with the desired read method.

 

Test Basic TCP Reads.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 14
(3,788 Views)

I am using method 1 of your solution (known amount of data). However there are interruptions in the video on the client. I am thinking that it could be a result of the numeric data which is not being sent correctly. Is this true and if so how do I correct it?

 

 

Thanks a lot !

Download All
0 Kudos
Message 10 of 14
(3,772 Views)