Contact Login
  • Home
    • About
  • Learn
    • LabVIEW
      • Basics
    • LINX
      • BeagleBone Black and Raspberry Pi
      • Digilent Physical Computing Kit
      • Sparkfun Inventors Kit
      • All LINX Tutorials
      • Reference
    • Kinect One
  • Libraries
    • LabVIEW
    • Android / iOS
    • LINX - Arduino, Raspberry Pi and BeagleBone Black
    • LEGO Mindstorms
    • Leap Motion
    • Kinect One
    • Nest Thermostat
    • PS4 Controller
    • Xbox One Controller
    • See All Libraries
  • Projects
    • Share Your Project
    • See All Projects
  • Forums
  • Get LabVIEW
  • Board index ‹ General ‹ LabVIEW Programming
  • Change font size
  • Print view
  • FAQ
  • Register
  • Login

Webserver client example using LabVIEW instead of browser

LabVIEW Programming Help And Discussions
Post a reply
6 posts • Page 1 of 1

Webserver client example using LabVIEW instead of browser

Postby DerekM » Fri Jul 01, 2016 10:17 am

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 4080 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 4080 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 4080 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 4080 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 4080 times
Attachments
lv_http_get.vi
(20.79 KiB) Downloaded 141 times
User avatar
DerekM
 
Posts: 159
Joined: Mon Jun 27, 2016 9:41 am
Top

Re: Webserver client example using LabVIEW instead of browse

Postby sharpk » Fri Jul 01, 2016 11:32 am

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
sharpk
 
Posts: 331
Joined: Fri Aug 15, 2014 10:06 am
Top

Re: Webserver client example using LabVIEW instead of browse

Postby DerekM » Sat Jul 02, 2016 5:37 am

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 4060 times
User avatar
DerekM
 
Posts: 159
Joined: Mon Jun 27, 2016 9:41 am
Top

Re: Webserver client example using LabVIEW instead of browse

Postby scott620 » Mon Nov 28, 2016 4:06 pm

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!
scott620
 
Posts: 35
Joined: Wed Jul 15, 2015 9:19 pm
Top

Re: Webserver client example using LabVIEW instead of browse

Postby DerekM » Thu Dec 01, 2016 7:35 am

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?
User avatar
DerekM
 
Posts: 159
Joined: Mon Jun 27, 2016 9:41 am
Top

Re: Webserver client example using LabVIEW instead of browse

Postby scott620 » Thu Jan 26, 2017 1:49 pm

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
scott620
 
Posts: 35
Joined: Wed Jul 15, 2015 9:19 pm
Top


Post a reply
6 posts • Page 1 of 1

Return to LabVIEW Programming

Who is online

Users browsing this forum: No registered users and 3 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC - 6 hours [ DST ]
LabView Hacker LabVIEW MakerHub
Driven by LabVIEW users. Created by NI.