Transcript for:
LabVIEW TCP Data Transmission

hello and welcome everyone to the labview exercises in today's video we will see how to send some data to uh from that is by using tcp protocol from client to server so that it can read by using a remote port so if i run my server and again run my program right now so this is our client side so which will send the data and this is our server side that will read the data basically so if i change any of the value from my client side then the server will also read the data over the tcp protocol so right now as we know we are not using any of a sensor right now since we are using a thermometer as our sensor right now so this will be just as for demo purpose so let's just move on to its block diagram all right in order to make this program we need to start a new vi so this is our front panel on our front panel we just place a thermometer here a thermometer will act as a sensor right now since we have not attached a real sensor so we will go with the digital display so it will show us the exactly the numbers in the fraction form so that if we increase or decrease it will show us in the form of the fractions so i'll just make it out change it to control and now we will just go on to our data communication and there we will find out protocols and then there is a tcp protocol just pin this palette in here now we will use gcp open tcp write and tcp close function so i'll just close this out so this is our tcp open this is our tcp right actually we will make two copies of tcp write so now i'll just start connecting it one by one so here is our first connection and this is connected to the second tcp right and this is connected to close connection and now it will be connected with the tcp close so why i am using two tcp right in our client side i will tell you later on so right now we have a thermometer that we need to convert it to although we can use number string palette but i am searching another function format into string that will give us the flexibility to bring the string form a fractional form in this so right now all of the time out is set like 60 it shows that there is a 60 second timeout but i'll make it -1 so it means that there's no time out and similarly with this one and similarly with this one so it means that there is no time out for the tcp right now i will enclose that within the while loop create a control of it and also give it a time of wait multiple second and create a constant of 1000 which means that the loop will iterate every one second so now we have to give a remote id to this tcp right client side so we'll create a constant which is 2021 as our remote port id so this is our service name or more port id and now why we have used our this first tcp right so we'll go to string function basically what we need is we need to send this byte return create an indicator these are the bytes that this thermometer contains the data we need to send this bytes data to our server side which is very important to read the message overall so we will go to string function again information to string again connect the output to here that will that will catch the length of the uh thermometer basically change it to input one and here it will be just connected to this and now it will give me just the bite return so now we will just so this is our client side basically we can just stop this out and we can now save this file as this pc and here i can just name it as client all right and now i will open a new vi which will be our server basically so here i will again create an thermometer but this thermometer will be have a different color so this is our thermometer and we can just change its color so that it will be more distinguishable that which one is our client and which one is our so here is our digital display so now i'll make this as a server by using the data communication protocols again tcp and pin it out so first we will start from the tcp listen then tcp read function and tcp close function close this out make a copy of it and then connect all of the things again all right so we have the second tcp read function that will tell us what is the data output basically so let's just change the decimal string to number or fractional string to a number basically this out in here and this will be our number and [Music] then again we have bytes to read this is the main problem that for which i have just built our first tcp read or write function that will basically check how much data is coming from it so i will just change it out again to right now we have an output as string so we need basically string decimal string to number we will just connect it out in here and give the number to this one and again we'll set all of these as -1 so that it has no time limit of timeout again timeout is weird forever it is already set to -1 and then now the port name is again 2021 all right enclose that within the while loop and what else we can do is create again a control of it as well and the timing palette is which so we have 1 000 in here so now if we run our program let's just run this client side and let's just run the server side we see a problem in here that this doesn't communicate with this server side so what is the problem basically so the problem is we must have to set we have already set the bytes to be read for the second tcp but we didn't have set the points to be read for the first one so we will just go on to our parts written create an indicator and we will see that these bytes that have written to our first uh tcp right will not go more than of almost one so we just set this out as buys to be read create a constant as one so it means that there will be almost one byte since the data out uh or the first one have almost one byte only to send since this is the length of the string so that will contain only the one byte so now we will just shift out to our front panels and now if i run my program on the both hands we see that this has just started again so run our first server first then our client first and then it is shifting our values from here to the uh our server so as you can see right now we can just check our values so that is how we can make our program to send the census data from a client to server basically so i hope you will like my effort thank you so much [Music]