LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to communicate with a device through "xml telegrams"

I have a Sevenexcellence pH meter that I want to read a pH reading from using LV 2020 via USB. I contacted their support and it seems this device uses xml telegrams to communicate and they don't provide further help.

I am not familiar with this type of communication so I was wondering if there were any examples, modules, or drivers for VIs that I can use for this type of communication? I have attached a reference document that I got from their support for remote control of this device.

I am fine with starting from scratch, I just don't know where to start from since I am not sure how I will go about sending these xml telegrams.

Any help would be appreciated.

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

@acemet1 wrote:

I have a Sevenexcellence pH meter that I want to read a pH reading from using LV 2020 via USB. I contacted their support and it seems this device uses xml telegrams to communicate and they don't provide further help.

I am not familiar with this type of communication so I was wondering if there were any examples, modules, or drivers for VIs that I can use for this type of communication? I have attached a reference document that I got from their support for remote control of this device.

I am fine with starting from scratch, I just don't know where to start from since I am not sure how I will go about sending these xml telegrams.

Any help would be appreciated.


It's Ok, the support you got from Sevenexcellence is pretty typical, they gave you all the info you need but are not going to hold your hand. All you need to do is break the project down into separate issues and solve each of them in turn. For a first step is to see if your computer can talk to the thing (code comes next), do they have any software for the device that you can download? This may include a USB driver or an application that you can use to interact with the instrument. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 2 of 9
(1,964 Views)

I see the device also supports Ethernet.  Is that an option for you to use instead?  You could probably manage that with standard TCP/IP nodes and not need to import DLLs or use a USB RAW driver or something like that.

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

The manual is pretty sparse in information. It only documents the XML messages and not very systematically but rather as a dump of possible messages. The manual has "Prelimenary version" on each page, for some reason.

 

It says nothing about what communication method is used for the USB connection. I would hesitate to even make an estimate for needed work to communicate with it through USB because of that. Definitely forget about VISA USB Raw, if you have to go that path you can better stop now instead of getting yourself frustrated. It never really was the solution for almost any problem communicating to an USB device, but definitely isn't nowadays as the manufacturers almost never are willing to document their low level USB protocol and to make things even more complicated, modern OSes require driver signing so you have to purchase a certificate to sign your VISA USB Raw driver in order to let Windows (or MacOS) load it at all.

 

My prefered method would be to use the network connection. That has some chance to be actually workable with the information contained in this "manual". For USB there is simply not enough information available unless you can get Mettler Toledo to provide you a much more technical document.

 

The challenge will be to generate the correct XML messages to send to the device and to parse the response. That is always a very "fun" business. LabVIEW comes with an XML library but you still have to build the XML message structure explicitly and to specify the x-Path to the parsing function to retrieve specific elements. Doable but quite tedious. Unfortunately there is not a much easier way also in other programming languages. XML was once hailed as the solution to everything including sliced bread, toasters and vendor independent communication protocols. People overlooked that while XML is indeed text based (and rather verbose in that) it is also encoding the entire data structure as well and anyone trying to build or interpret XML messages needs to understand that schema exactly. XML schema descriptions were supposed to solve that but really just moved the actual problem onto a different level.

 

JSON eventually was used more. It has the same difficulty of incorporating the data type schema as XML has, but is a lot more concise and compact and actually easier to read for humans with minimal training about the JSON format. And parsing libraries also tend to be significantly easier to use with JSON. 

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

Hello,

 

I apologize if I'm reopening this post. Did you manage to remotely control your ph meter via ethernet?
I have contacted support who have provided me with more up to date documents but still lacking information. My network communications seem fine, but my ph meter seems to be deaf to XML frames.

 

Have you received the documentation explaining the XML library?

 

Thank you for your feedback.

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

Any update on this topic?

 

I'm trying to send xml messages to the sevenexcellence using the code below but I'm receiving the following error 'Connection aborted.', BadStatusLine.  Any help will be greatly appreciated.

 

import requests

 

url = "http://10.246.116.23:8016"

 

xml_data = """<?xml version="1.0" encoding="utf8" standalone="yes" ?>

            <Telegram xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"xmlns="LancePlatform">

            <Request requestId="2251275" requestType="instrument.getInfo /">

            </Telegram>"""

try:

    headers = {'Content-Type': 'application/xml'}

    response =  requests.post(url, data = xml_data, headers=headers)

    print (response.status_code)

 

except Exception as inst:

    print(inst)

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

Unfortunately, I could not get the xml telegrams to work out. Never figured it out. Only the vendor provided software was capable of logging data.

0 Kudos
Message 7 of 9
(1,234 Views)

Do you still have the updated version of the remote control manual?   If you do can you share it?

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

@acemet1 wrote:

Unfortunately, I could not get the xml telegrams to work out. Never figured it out. Only the vendor provided software was capable of logging data.


Oh boy this is where the real fun starts. Next you need to download Wireshark and capture some communication between the vendor software and the instrument. In this way you should be able to see what the vendor software is sending. Using that knowledge you can create your own XML messages that are formatted correctly. Hopefully they don't do something silly like 

 

<command>

... binary data here ...

</command>

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 9 of 9
(1,208 Views)