Page 1 of 1

Webserver client example using LabVIEW instead of browser

PostPosted: Fri Jul 01, 2016 10:17 am
by DerekM
Something like this may have been posted before, but here's an example (see attached, LV2014 SP1 Home version) of using the built-in LabVIEW HTTP protocol VIs (specifically GET) instead of a browser to interact with the webserver program. This saves having to learn any Java to program a nice UI in a browser, plus you get all the advantages of having a completely stand-alone LabVIEW program. I'm using a RPi 3 rather than a BBB, but the principle is the same. Also, in my program, I just have a digital input rather than an analog temperature input, but again it works fine for the example. My deployed application looks like this:

Deployed VI.jpg
Deployed VI.jpg (45.71 KiB) Viewed 1581 times


The only other change I make to the tutorial program is to set the output type for the digital input GET method to 'Text' (see below). This is not critical; it just saved having to do any conversion in the LabVIEW 'Client'.

ws_properties.jpg
ws_properties.jpg (61.3 KiB) Viewed 1581 times


Note that I found I had to deploy the code above as a 'Run at Startup' program to the RPi, using the instructions in this tutorial. The Webserver option also had to be 'checked' in the build properties. Then I had to close down the project before trying to run the 'client' program, or LabVIEW would continually try to redeploy to the RPi.

The next step was to build the LabVIEW "client". This is a completely stand-alone program, and can be designed separately in its own project. For this example I just used a simple producer-consumer design, with no error handling (so watch out for that). The block diagram is shown below, with the case for setting the LED also shown. It simply uses the HTTP 'GET.vi' function found in LV at 'Data Communication -> Protocols ->HTTP Client'. It just does exactly what the browser was doing in the tutorial, using the exact same text that was entered in the URL bar.

lv_http_get_bd.jpg
lv_http_get_bd.jpg (93.53 KiB) Viewed 1581 times


The case where the digital input is read is shown next. Again, it just mirrors what a browser was doing.

bd2.jpg
bd2.jpg (29.49 KiB) Viewed 1581 times


Finally, the front panel for the client is below. You need to enter the correct url and port number as dictated by your application. Also, the "body" indicator on the FP shows the result of the digital input when you press the Read Digital In button. It shows simple text because I set it to text in the webserver properties as mentioned above.

lv_http_get_fp.jpg
lv_http_get_fp.jpg (89.85 KiB) Viewed 1581 times

Re: Webserver client example using LabVIEW instead of browse

PostPosted: Fri Jul 01, 2016 11:32 am
by sharpk
Hi DerekM,

That's a really good idea using LabVIEW as the client to avoid writing HTML/Javascript. Thanks for posting!

I'm definitely going to recommend this pattern to people that don't want to take the HTML plunge.

-Ken

Re: Webserver client example using LabVIEW instead of browse

PostPosted: Sat Jul 02, 2016 5:37 am
by DerekM
You're welcome, glad it might help people. Javascript is on my "to-learn" list (I'm comfortable enough with HTML) so I'll definitely be returning to the browser method in the future, but the ability to code UIs in LV appeals to me more anyway. Another thing I see is that you can still deploy the stand-alone client as a remote application as well.

remote_panel.jpg
remote_panel.jpg (82.26 KiB) Viewed 1561 times

Re: Webserver client example using LabVIEW instead of browse

PostPosted: Mon Nov 28, 2016 4:06 pm
by scott620
Hey Derek,
you were able to access the remote panel from your RPI?

How did you deploy it so that you were able to access the remote panel? if you dont mind me asking.

That is huge, because JS is also on my to-do list, at the moment I have no experience with it.

Thanks!

Re: Webserver client example using LabVIEW instead of browse

PostPosted: Thu Dec 01, 2016 7:35 am
by DerekM
scott620 wrote:Hey Derek,
you were able to access the remote panel from your RPI?

How did you deploy it so that you were able to access the remote panel? if you dont mind me asking.

That is huge, because JS is also on my to-do list, at the moment I have no experience with it.

Thanks!


Just to clarify, the remote application I'm talking about above (in my last post) is the application that runs on the development PC, not on the RPi. So there is a web server running on the RPi, and a LV application running on the development PC that communicates with the web server on the RPi. Then, as an extra step, it is possible to configure the application on the dev PC so that it too can be accessed remotely by another PC.

I'm just clarifying because I think possibly you're looking for something different?

Re: Webserver client example using LabVIEW instead of browse

PostPosted: Thu Jan 26, 2017 1:49 pm
by scott620
DerekM wrote:
scott620 wrote:Hey Derek,
you were able to access the remote panel from your RPI?

How did you deploy it so that you were able to access the remote panel? if you dont mind me asking.

That is huge, because JS is also on my to-do list, at the moment I have no experience with it.

Thanks!


Just to clarify, the remote application I'm talking about above (in my last post) is the application that runs on the development PC, not on the RPi. So there is a web server running on the RPi, and a LV application running on the development PC that communicates with the web server on the RPi. Then, as an extra step, it is possible to configure the application on the dev PC so that it too can be accessed remotely by another PC.

I'm just clarifying because I think possibly you're looking for something different?


Derek,
I did misunderstand, but now I get it, awesome job btw. I would much prefer doing it this way!

-Scott