LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP decode c++

Open TCP/IP using port number and IP adress of the server
If openning ok, than start a while loop
While loop reads data from sensor and builts an bytearray, where first byte say which sensor it is, next 8 bytes are a sensor value and next8 are timestamp
Than send this byte array using TCP/IP Write function


Message Edited by Eugen Graf on 01-22-2008 10:31 AM
Download All
0 Kudos
Message 21 of 39
(2,700 Views)
0 Kudos
Message 22 of 39
(2,696 Views)
Hi Eugen,

it's me again (concerning the TCP/IP)... Now I have the c-program as the client from my partner and the program works, which is great! Thanks again for your help!
The only problem I have is that if the client stops sending datagrams and after a while sends again datagrams, my server doesn't notice. Once the client stopped sending data I have to stop my server and start it again, so that he'll notice if the client sends data again. But I don't like to stop my server every time as I don't know whether the client stops or not. The server should notice this.
I chose the same structure as you did in your first VI (s. your first picture): while loop - case structure - while loop - case structure and I think the server should notice if the client stopped sending data and should listen again, but he doesn't.
Do you have an idea why? What should I change?

Thank you very much!
Steffi
0 Kudos
Message 23 of 39
(2,657 Views)
The inner loop should exit if a timeout  occures, than you are in the outer loop. And the outer loop will listen for a new connection from client and re/open it if neccessary.


Message Edited by Eugen Graf on 02-06-2008 08:18 AM
0 Kudos
Message 24 of 39
(2,653 Views)
Maybe you can have a look at my vi, I don't find my mistake. I set the timeout to 10, so after 0,01 sec it should exit the loop, shouldn't it?

Thank you...
0 Kudos
Message 25 of 39
(2,646 Views)

Hi Steffi

in your last example you can only exit the loop while pressing the "stop communication" button. to exit the loop if an error occurs you have to connect the error status to the loop condition.

Mike

0 Kudos
Message 26 of 39
(2,641 Views)
No, it will not exit the loop because the condition to exit them is the TRUE value of the stop button. But it's ok, you can let it.
 
How often the client sends the packages? Change your timeout value to 1 second, if you will get problems, than look on the client side. The client have open communication only once if it starts and close the communication only once if it exits.
 
Try to debug your VI looking on the error output of TCP Read.


Message Edited by Eugen Graf on 02-06-2008 08:42 AM
0 Kudos
Message 27 of 39
(2,637 Views)
I changed it the way Mike suggested. And I think it works?! Thank you!!
But if I keep my simple error handler in my program of course the following warning occurs: "LabVIEW:  The network connection was closed by the peer." and I have to press "continue" every time. If I delete the error handler then everything is perfect. But I would like to know if there is a way to "ignore" this special "error" for my error handler (not for my loop as I need it there), but that the error handler still tells me if there was another error?

Thanks to you both!
Steffi
0 Kudos
Message 28 of 39
(2,627 Views)
No, no. NEVER ignore errors. Look on my previous post. Check your if client closes communication only once!
0 Kudos
Message 29 of 39
(2,623 Views)
Ok. Well, we would like to embed the server in a huge program which runs over hours during tests. Within these hours the client starts and stops communication several time, but we don't want to stop the server each time... So, I'm not sure what your suggestion was in your previous post, sorry. You said it will only exit the loop if the stop button is pressed, but that I could let it this way. Why? I think the server needs to exit the inner loop to notice that the client stopped communication and to listen again (to get into the outer loop)?

Sorry, I didn't get it, my fault. Maybe you can explain your suggestion in another way? Thanks.
0 Kudos
Message 30 of 39
(2,613 Views)