News:

  • April 16, 2024, 12:52:23 AM

Login with username, password and session length

Author Topic: Example: WebServing from DoMore  (Read 20711 times)

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Example: WebServing from DoMore
« on: May 01, 2013, 08:08:04 AM »
This is a small example to help someone who wants to set up a server on a DoMore.
Please feel free to critique the program and post back.
To run the program, simply download and open with DMD, and load the program onto the simulator. Turn on X0 on the simulator. Use a web browser and enter: http:// xxx.xxx.xxx.xxx:8080 (replace x's with your computers ip address), or simply type: localhost:8080

This is a little way of giving back a small portion of what has been given to me on these forums.

Regards, Jason W

EDIT: See the program posted below \/
« Last Edit: November 03, 2015, 05:34:14 PM by plcnut »
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #1 on: May 01, 2013, 08:15:13 AM »
If you are a FireFox user then the webpages will not display properly (unless you set the port to 80).
Google chrome seems to work fine.

If anyone has any advice on what needs changed to make FireFox display html on a port other than 80 then please let me know.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #2 on: August 30, 2013, 11:04:34 AM »
If anyone has any advice on what needs changed to make FireFox display html on a port other than 80 then please let me know.

As a follow-up:
The DoMore is not able to send the proper response header for HTML.
Most web browsers will automatically parse a page as HTML when it comes over port 80 even without the proper header because it is the standard HTTP port.
So, the options are:
1) Use Chrome for the browser.
2) Set up a Reverse Proxy on a local server (contact me for details)
3) Use port 80, and only allow one connection at a time.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5983
  • Yes Pinky, Do-more will control the world!
Re: Example: WebServing from DoMore
« Reply #3 on: August 30, 2013, 11:28:03 AM »
If anyone has any advice on what needs changed to make FireFox display html on a port other than 80 then please let me know.

As a follow-up:
The DoMore is not able to send the proper response header for HTML.
Most web browsers will automatically parse a page as HTML when it comes over port 80 even without the proper header because it is the standard HTTP port.
So, the options are:
1) Use Chrome for the browser.
2) Set up a Reverse Proxy on a local server (contact me for details)
3) Use port 80, and only allow one connection at a time.

What is required that we aren't able to do?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #4 on: August 30, 2013, 11:40:13 AM »
Here is a screenshot of a DoMore response header, and a google.com response header, side by side.
Web browsers (since HTML5 I believe) have stopped using meta tags to determine the content-type, and now use the "Content-Type" variable of the Response header.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5983
  • Yes Pinky, Do-more will control the world!
Re: Example: WebServing from DoMore
« Reply #5 on: August 30, 2013, 02:48:41 PM »
Right...but aren't you the one providing the content? Do-more isn't doing any of that anyway, and should be able to output anything you give it. What am I missing?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #6 on: August 30, 2013, 03:21:39 PM »
I have no control over the "Response Header". DoMore issues a "HTTP/0.9 200 OK" each time it STREAMs. I can only edit the "Content" of the STREAM.
I can edit these headers when I configure WAMP server, or IIS in windows, but it appears DoMore is using a generic response.
I don't know how that works from your end, but if you want to view the headers, you can get an extension for firefox called "Live HTTP headers 0.17" so you can view them.
I would really like to be able to edit the headers some how, but I figured it was asking an awful lot from you guys, because I don't know that many would use it.

...I don't know enough to be able to dissect where the header is located in the packet using wireshark, but I did find this page that may help: http://wiki.wireshark.org/HowToDissectAnything
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5983
  • Yes Pinky, Do-more will control the world!
Re: Example: WebServing from DoMore
« Reply #7 on: August 30, 2013, 03:42:55 PM »
That isn't Do-more, at least not my code. It is possible that the IP stack is doing something without my consent, but I would have thought all stream content was coming from your code only. If it is coming from the stack, it needs to be fixed.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #8 on: November 03, 2015, 05:27:50 PM »
I just went back and looked over some of this code and scared myself that I would post such a thing!
I made a couple of changes so that now it may actually work without tweaking...
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #9 on: July 01, 2016, 10:48:47 AM »
I just deployed a new application using the Do-more webserver as the sole HMI. I was forced to use another port besides 80 (HTTP) and finally learned how to make a browser render the html on a non-http port. Simply add this string to the very beginning of the STRPRINT for the WebPagePrefix:
Code: [Select]
HTTP/1.0 200 OK$0D$0AContent-type: text/html$0D$0A$0D$0A

This is the actual Response header. Each line of the header must be separated by the CRLF, and the header is ended with 2 CRLF's.
Enjoy!
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3657
    • Host Engineering
Re: Example: WebServing from DoMore
« Reply #10 on: July 01, 2016, 11:12:43 AM »
I just deployed a new application using the Do-more webserver as the sole HMI.

SWEET!  Could you post a sample screen shot of your browser/HMI?

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #11 on: July 01, 2016, 11:50:31 AM »
This is a very simple application that monitors the pressure of a water system. There is not much to see, but here is a screenshot of the home screen:

And one of the single settings screen:


The system logs the lowest pressure reading as well as the date and time every second. The database holds 20,000 lines and can be downloaded as a .csv file using the link on the home page. It will also send out an email to one of our private email servers whenever the pressure drops below our alarm threshold.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

HB_GUY

  • Full Member
  • ***
  • Posts: 43
Re: Example: WebServing from DoMore
« Reply #12 on: January 05, 2017, 03:49:16 AM »
Awesome stuff!
I used this to make a simple dashboard for one of my systems in Northern California!
I also have this DoMore sending daily telemetry to my WebServer for billing purposes.

Great work plcnut, and the whole HostEng team for making such a great product!

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Example: WebServing from DoMore
« Reply #13 on: January 05, 2017, 04:22:35 AM »
Cool beans!
I'm glad you were able to put the code to use. I have made several new developments with this project including adding in the header information to a csv file so that the downloader in Firefox can display the percent completed, as well as serving up the actual favicon directly from the Do-more. I have not had any play time for quite a while, and so I have not posted any of the code for doing this...
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

henke

  • Full Member
  • ***
  • Posts: 21
Re: Example: WebServing from DoMore
« Reply #14 on: January 26, 2017, 09:58:40 PM »
This is a very simple application that monitors the pressure of a water system. There is not much to see, but here is a screenshot of the home screen:
And one of the single settings screen:

@plcnut: VERY cool! Fantastic work. Thanks for sharing that. I can't get the settings page to work yet but it's a thrill to just have the PLC serve values to a web browser.
Works great browsing via my phone on that same network too!
Where's my kitty?