LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading C Structure over TCP in LabVIEW

There are likely two possibilities:

 

1) The sender sends the entire package including 128 * 64 * 2 bytes

2) The sender sends only numpkts * 64 * 2 bytes at the end

 

In the second case you have to first read the header until you get to the numpkts variable and then calculate how much more you need to read!

 

Which of these two or maybe even a different format is something which the protocol description should define. If you don't have such a description the only way to find out is by trial and error and lots and lots of testing.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 11 of 15
(1,319 Views)

Sender sends the enire packet everytime (from Linux based PC). I also came to know that, the version number is the only the fractional value in this packet and remains constaant for all commands that my application receives in LabVIEW.

 

I developed the attached code (sorry- it's not clean and commented) and wish to use version number as a reference for parsing the packet. 

 

This works fine for only first time, and there after it doesn't work. Tried playing with timeout/ loop delay, tcp read mode etc. but no success. 

 

Don't know, what is the mistake that I am commiting.

0 Kudos
Message 12 of 15
(1,295 Views)

Hi ,

 

Still in trouble.....can someone help....

0 Kudos
Message 13 of 15
(1,247 Views)

It's difficult to say what might be the problem without being able to run it myself, but I would check your error clusters. You don't mention how it doesn't work multiple times. Does it abort after the first packet because of an error? Or does it just not receive another packet afterwards? How fast is the other side supposed to send a package? Is it supposed to send more than one package per connection request?

 

What errors do you see? You need to be aware that TCP/IP nodes can return errors such as timeout (56) that don't need to be treated as fatal depending on the underlaying protocol, but should rather cause your code to simply retry later once or more times. As it is now a timeout error will simply abort your whole program.

 

Generally you have either protocols that require first to send a command to request a particular response, or that send out one packet after connection request and then close, or spew out data every x ms, independent if the receiver is ready or not. This last one would be a very nasty protocol.

 

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 14 of 15
(1,222 Views)

Let me elaborate. Very first time, it can read the packet, parse it correctly and display the parameters of the structure on GUI. Program keeps running after this, but doesn't capture the (complete?) packet afterwards. May be because I have put a check on version number, it never gets that and doesn't parse/ display the parameters. The program keeps running (though the currect code is made to stop, even if it is a timeout error- which I'll correct) and doesn't report the TCP timeout eror. Not sure, what is the reason, it can't capture the complete packate again.

 

The counter application keeps sending the domon (at every 1 sec.) or someother command (based on user action) and labVIEW program is supposed to respond to these commands accordingly with the appropriate data. 

0 Kudos
Message 15 of 15
(1,203 Views)