From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading XML data from socket (have IP address and port #) using labview

Thanks for the suggestions. 

 

Actually, what I am doing is trying to read the XML data from the TCP/IP server.

Each XML string has values from tip, sleeve, pressure and temperature.

I need to read the string approximately 3 times in a second. 

 

I am not sure if the way I am using the match pattern is working or not? Is it reading all the data correctly or not?

 

Thanks

0 Kudos
Message 11 of 17
(1,171 Views)

I also tried the parsing method. But it keeps on giving me the Error shown in the screenshot. 

I am not sure if its due to schema or something else?


Thanks

0 Kudos
Message 12 of 17
(1,168 Views)

Your code may miss samples. It will do this if the packet you read has more then one sample of a particular kind. If there are two pressure values then your code will miss the second one.

 

Match pattern only returns the first match. To find later matches, you have to take the string past match output and search it again.

 

From this end it is hard to decide what to suggest since I don't know much about the XML string from the server. Hopefully there is some information in the XML or the way it sent to you that would help this process. For instance do you always get four values everytime you read from the socket? Are the packets always the same size or smaller? and so on.

 

Knowing nothing, I would take a brute force approach. I would assume that this is a continuous stream of XML data. That subsequent packets are to be appended to the end of packets I have already read. That the breaks between packets may happen in the middle of a string instead of helpfully at the end of a section or a line.

 

I would read a packet and place it in a string shift register. I would search it for each of the four kinds of data. For the kind closest to the beginning of the string, I would parse out the data and then discard that section of the packet. (The part up to and including the match.) Repeat with the other three searches. Get another packet and append it to whatever string you have left. Repeat the search on this string. Loop indefinitely.

 

Does that make sense?

0 Kudos
Message 13 of 17
(1,161 Views)

Each packet will have one value each for tip, sleeve, pressure and temperature. 

Would it still miss any points?

0 Kudos
Message 14 of 17
(1,155 Views)

I think so, presumming that it can keep up with the data rate. Since the data rate is 3 times a second it should have no problem.

 

An obvious way to tell is to run it for an hour or so and count how many points are in the stream. If you get a count consistant with 3 samples per second then you code is working. If not, you will know there is a problem.

0 Kudos
Message 15 of 17
(1,148 Views)

Manny09,

 

Can you give us an update?

I hope everything worked out fine.

In the mean time I'm working on getting solid documentation on XML and examples but I haven't had much luck, just basic stuff. Although it seem that the match patter function will only return a value, it will make sense to me that if you use a shift register or another method that, let's call it , "repeats the last action" which was get a match patter, and do that 3 times on intervals of x number of seconds it might work. I will keep on searching in the mean time.

 

If you have further questions regarding this issue please let me know.

Sincerely,

Siggi D.

AE

"everything is achieveable through technology'
0 Kudos
Message 16 of 17
(1,119 Views)

I just tested the match pattern with my system. So far it looks good. 

I am just reading 3 samples per channel each second, so I think its safe to use the match pattern. 

But I will try some more tests and let you know how it goes.

 

Thanks

0 Kudos
Message 17 of 17
(1,117 Views)