Solved

How to display realtime meter reading data from TCP or serial on web

Posted on 2010-09-22
5
487 Views
Last Modified: 2012-06-21
I may need to display realtime meter reading values on the web site. The data will be received by the server through TCP or serial port.

I plan to make one program A on server to receive the realtime data and pass them to web server, and save to DB also. But I am not sure how to let the program A pass the data to the web server, or through whcih way.

When the end user start a web page, all and only the meters in this page need refresh the realtime display. The web server need to pass this meters ID to program A, and A start to polling these meters realtime value with faster speed. Can this be done in the web server.

Thanks.
0
Comment
Question by:turbot_yu
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 33750222
If your "realtime" data isn't to quick, you could have your program A send data to it using a simple GET request, and create a page on the server to process the request and write the data to the database.  For example:
  program A would GET www.server.com/update_value.cgi?value1=5&value2=10
  Then update_value.cgi would write the new values to the database.

To have the web browser display the data, you could use AJAX to get new data from the web server, and update the page.


I'd guess this would work for about 1 update/second.  Much faster than this, and you'll some other method.
0
 

Author Comment

by:turbot_yu
ID: 33750381
1 update/second is fine. May you give details about GET request.

Please see the attached screen.
meter.png
0
 
LVL 39

Expert Comment

by:Adam314
ID: 33750645
In your picture, program A writes to the database, but the webserver does not interface with the database.  Is this how it will work?  If so, I misunderstood your requirements.

I thought that the program A would interface with the web server and the polling data back - not the database - and the web server with interface with the database.  If so, how you send the GET request will depend on the language.  If you are using perl for program A, you can use the LWP::Simple module, and the request is just 1 line (plus 1 line to include the module):
    use LWP::Simple;   #Include module
    #whatever code to read from polling data back goes here
    my $content = get("http://www.your-server-here.com/update_value.cgi?value1=$value1");
0
 

Author Comment

by:turbot_yu
ID: 33753902
Sorry, I forgot to draw the link from DB to web server.

Most of the data that web client want to view is not realtime data, just the data in the DB.

Actually, there are 2 kinds of data. One is trending data, which refresh every 10 mins, another realtime data, which refresh every second.

I am new to the GET. Is it from the web server? Any syntax of it.
meter-1-.png
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
ID: 33758163
GET is one of the methods a web client communicates with a web server.
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

This is what is used when you type an address in a web browser - the web browser sends a GET request to the web server, and the server responds with the data for that page.

On the web server, if the page is just plain html, the web server will just send the page to the client.  If the page is a program (perl, php, whatever), the web server runs the program, and sends the results to the client.

Depending on the language, you may not need to know the detailed syntax of the protocol - the language has a library that implements it for you.  The example I gave is in perl, and uses the LWP::Simple module.  With this module, you call the "get" function, with handles all of the protocol with the server.  If the language you choose does not have any libraries to help with this, the basic syntax is "GET page\r\n" where "page" is replaced with whatever page you want.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question