LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send message from one PC to another via TCP/IP.

Solved!
Go to solution

Hello,

I need to connect to PC's. In the first, I will have a VI receiving data from two RF antennas. The same messages are received containing several data and a CRC. Each line is checked for their consistency and the one with no errors is selected and saved in a text file. If the two messages have no error, then Antenna 1 have priority.

Now I want to transfer this lines to another computer, to be processed in another VI that displays the data from the message.

Let’s say that the first computer and VI acts like a server after checking for the “best” message.

For this data transfer I am thinking about using TCP/IP connecting the two computers via cable.

I saw some examples of VI’s for sending and receiving but I am not very familiar with this protocol and procedures.

Can I have your help please?

Thank you.

Duarte

Message 1 of 14
(6,835 Views)

Hi Duarte,

 

in the example finder you will find an example on a server and client VI, which communicate by TCP/IP.

What is the problem with those example VIs?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 14
(6,820 Views)

The two routes I would recommend are: 1) use Network Streams (handles a lot of the low level TCP stuff for you) and 2) the STM (Simple TCP/IP Messaging) library (free on the LabVIEW Tools Network).  The Network Streams is probably the better route for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 14
(6,811 Views)

crossrulz escreveu:

The two routes I would recommend are: 1) use Network Streams (handles a lot of the low level TCP stuff for you) and 2) the STM (Simple TCP/IP Messaging) library (free on the LabVIEW Tools Network).  The Network Streams is probably the better route for you.


Hello and thank you.

Before I do it in my main project, I tried to do some tests. Bellow I have the snippets of my writer and reader sides. Its fine but if I abort the execution on the reader side the writer keeps sending strings. If I run the reader VI again it doesn’t receive any data. I have to abort writer VI and run it again.

I was wondering how can I make reader VI to reestablish data reception after aborting the execution one or more times?

Thank you.

 

WRITER VI

writer.png

 

 

READER VI

reader.png

0 Kudos
Message 4 of 14
(6,764 Views)

Stop your loops on an error.  You will get an error when the other disconnects.  This will clear out the connections.  Then you can just run both again.

 

Alternatively, you have a state machine to manage your connections.  If you lose a connection, you go into a state of waiting for a connection again.  When you have the connection, go back into the Write or Read state.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 14
(6,759 Views)

Ok! Thank you.

I have one more question, please. Is it possible to send a character from the reader to the writer by pressing a button for example?

 

0 Kudos
Message 6 of 14
(6,744 Views)

Hi Duarte,

 

use a second network stream…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 14
(6,742 Views)

Well,

I’m not sure if am in the wright path.

Now my writer(PC1) is also a reader and my reader(PC2) becomes a writer. I am testing by sending a character from PC2 back to the writer (PC1) if the button is pressed.

I still can’t put this into work. Should I se the same line like VISA?

Any idea please?

Bellow my snippets:

PC1 (now with the second NS to read from PC2)

writer.png

 

PC2 (now with second NS to write characters to PC1)

reader.png

0 Kudos
Message 8 of 14
(6,726 Views)

Hi Duarte,

 

you need to use a second NetworkStream with a unique name - as is shown in the example VI, that comes with LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(6,719 Views)

Well,

I think it's to much for me.

I don't get how to adapt it. 😞

 

Thank you!

0 Kudos
Message 10 of 14
(6,706 Views)