LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

display data for every iteration of loop for dll

Hello All,

 

i have created tcp client program and i have created two dll 

1st dll will have socket creation and connect function

2nd dll will have recv function inside while loop

 

i'am passing socket_id(Connectsocket) from 1st dll to 2nd dll

as i execute it gets connected but the 2nd dll will not display the data value as it is inside while(1) and it will never end

how can i display value for every iteration of loop.

 

Regards

Tushar

 

 

Regards

Tushar

0 Kudos
Message 1 of 9
(1,608 Views)

@tushar.V wrote:

Hello All,

 

i have created tcp client program and i have created two dll 

1st dll will have socket creation and connect function

2nd dll will have recv function inside while loop

 

i'am passing socket_id(Connectsocket) from 1st dll to 2nd dll

as i execute it gets connected but the 2nd dll will not display the data value as it is inside while(1) and it will never end

how can i display value for every iteration of loop.

 

Regards

Tushar

 

 

Regards

Tushar


Have you checked at-least for iteration working without loop as a part of debugging.

Also you cannot have a While loop with No stop button, Else you may need to abort which is not the recommended method.

 

If in case it works for single iteration and its not reading the data in the second time in the loop wire the connection socket output of DLL1 in both the ends of shift register.

If you are able to read the data and you need to append all the received data use Shift register to store the previous results.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 9
(1,588 Views)

the code for 2nd dll is like this 

 

Client1(SOCKET &ConnectSocket, int data)

{

while(1)

{

recv(ConnectSocket,data,sizeof(data),0);

 

}

}

as it is inside while loop it will never end, so i'am not getting data value 

0 Kudos
Message 3 of 9
(1,579 Views)

@tushar.V wrote:

the code for 2nd dll is like this 

 

Client1(SOCKET &ConnectSocket, int data)

{

while(1)

{

recv(ConnectSocket,data,sizeof(data),0);

 

}

}

as it is inside while loop it will never end, so i'am not getting data value 


Of course not! Remove that while(1) completely if you want to actually call this function from anywhere. Otherwise it just makes no sense!

 

And SOCKET is a pointer sized datatype. So it would not be correct to represent that as UIN32 if you ever intend to use LabVIEW 64-bit and an accordingly compiled 64-bit DLL.

 

And you could avoid these problems altogether by using the LabVIEW TCP nodes instead. No need for an external DLL to implement network communication!

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 9
(1,570 Views)

if i remove while(1)  the code will run every time from the beginiging , so the recv will lose connection, is there any other way where i can get data continuosly through dll

0 Kudos
Message 5 of 9
(1,566 Views)

i'am trying to implement it like below image , it works correctly , so i want to do it with dll

am i missing something or have i written wrong code for 2nd dll

0 Kudos
Message 6 of 9
(1,557 Views)

@tushar.V wrote:

if i remove while(1)  the code will run every time from the beginiging , so the recv will lose connection, is there any other way where i can get data continuosly through dll


Huuuuh???? I have no idea what you are talking about.

 

What is in that function other than the while (1) and the recv()?

Why would it loose connection?

 

Why can't you do the loop around the call to recv() in the LabVIEW diagram?

Why even bother with DLLs if you have the exactly some functions as native LabVIEW functions too?

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 9
(1,554 Views)

sorry this is my complete code

Client1(SOCKET &ConnectSocket, int data1)
{
int data1[100];
while(1)

{

recv(ConnectSocket,data,sizeof(data),0);
for(int i=0;i<100;i++)
{
data1[i]=data;
}
count ++;
if (count ==5)
break;

}

}

i'am trying to display data1 for every iteration of loop, but i get data1 only after loop breaks 

0 Kudos
Message 8 of 9
(1,536 Views)

That would never compile! You use a data variable in the call to recv() but have declared twice a data1 variable in your code (once as function parameter and once as local variable.

 

And even considering that your code simply makes no sense!

 

And yes the C function only returns after it has iterated through the 5 loops of course, and LabVIEW CAN'T see any data until the function returns. If you want to see the data in each iteration of the outer loop you have to move that loop to the LabVIEW diagram! There is NO other way. The DLL function is for LabVIEW a black box that it can not peek into! Nada, niente, nothing!

 

So if you want to display intermediate data you have to return to the caller everytime you want LabVIEW to display that data and then let LabVIEW call that function again!

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 9
(1,502 Views)