LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading network shared variables from web

Hi All,

 

I'm trying to access and read network shared variables from web using the instructions given in LV help.

http://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/vws_reading_a_variable/

 

I'm send the request as follows, but cannot get the value.

http://169.254.141.232:8080/nivariable/VariableValues('ni.var.psp://169.254.141.232/NSV/Status')/Val...

 

I've created couple of variables, deployed them and continuously updating their values on the target. I can successfully read those variable in LV host application, but cannot get them as described in the corresponding help instructions.

 

Any help is appreciated.

 

Thanks,

Arev

0 Kudos
Message 1 of 12
(4,014 Views)

Does anybody know some other solution to get data without websocket from RT target in the Web?

 

Thanks,

Arev

0 Kudos
Message 2 of 12
(3,888 Views)

You can use Open Variable Connection, Read Variable, Close Variable Connection.

 

Not sure if that uses websockets? What is the goal?

0 Kudos
Message 3 of 12
(3,872 Views)

Thank you for for your reply.

 

Actually I need to get shared variable data not in the LabVIEW environment, but web.

 

I need to get the value with HTTP Get command. In the help the command is described as follows, but I cannot get it to work.

 

GET http://169.254.141.232:8080/nivariable/VariableValues('ni.var.psp://169.254.141.232/NSV/Status')/Val...

 

I'm using Postman to send the request and get response, but never get it. 

 

Thanks,

Arev

0 Kudos
Message 4 of 12
(3,864 Views)

You can give curl a try. I think it's build in, at least in my Windows 10, but probably earlier as well.

 

Although I don't see why the results would be different, it would be a 2nd opinion.

 

You should also be able to use that URL in a browser. IIRC, you can remove parts from the end of the URL, and get a higher level response. So you might be able to remove from the URL until you get anything, and than build up the URL small steps at a time.

 

A ping would rule out any network problems.

 

I'll do some digging, I'm sure I did this a while ago. But most recently I did it for SystemLink, which is similar but with variation on the URL. I'd think the URL is the biggest problem here. I'm sure I put a link to useful info somewhere...

0 Kudos
Message 5 of 12
(3,859 Views)

I have tried with the browser as well, but got the same result.

 

Also the Postman is running Curl inside, so it is also not helping.

 

I'm getting the following response:

 

<!DOCTYPE html>
<html><head><title>Not Found</title></head>
<body>
<h2>Access Error: 404 -- Not Found</h2>
<pre>Cannot open document for: /nivariable/VariableValues(%27ni.var.psp://169.254.141.232/NSV/Status%27)/Value</pre>
</body>
</html>

0 Kudos
Message 6 of 12
(3,835 Views)

I used (from localhost) this in the past:

http://localhost:3580/nivariable/VariableValues('ni.var.psp://localhost/EtherCAT Master/Mod3/DI1')/Value

 

So IIRC, port 8080 is used for HTTP, but not for the shared variable engine. 3580 is probably default.

0 Kudos
Message 7 of 12
(3,826 Views)

I have tried to create and deploy shared variables on Host PC as well, and tried to get their values as:

 

GET http://localhost:3580/nivariable/VariableValues('ni.var.psp://localhost/NSV/Status')/Value

 

But again the same error, both with the Postman and browser. Still cannot figure out what is the issue.

0 Kudos
Message 8 of 12
(3,816 Views)

Are there any settings for the shared variable that maybe I'm missing, or perhaps some software on the target?

0 Kudos
Message 9 of 12
(3,811 Views)


Do you get anything with:

 

curl "http://Admin:@localhost:3580/nivariable/"

(Admin, "" as credentials) or

curl "http://localhost:3580/nivariable/"

 

I get XML:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<service xml:base="http://localhost:3580/nivariable/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="VariableObjects">
      <atom:title>VariableObjects</atom:title>
    </collection>
    <collection href="VariableValues">
       <atom:title>VariableValues</atom:title>
    </collection>
     <collection href="VariableValueGroups">
       <atom:title>VariableValueGroups</atom:title>
    </collection>
  </workspace>
</service>

 

Any other request I get "&quot;&quot; does not have permission to read VariableValues".

0 Kudos
Message 10 of 12
(3,807 Views)