lmqr15
Posts: 4
Joined: Sun Mar 22, 2015 7:42 pm

ascii input / display dcreen

Sun May 21, 2017 3:25 pm

Several (headless) raspi's in my house generate data on temperatures, flow-, pressure-, humidity- and light meters, there are a few event triggers (like: doorbell pressed, door opened) and a handful of relays that open/close valves or start/stop pumps, switch lights, boilers etc.
Yes, I have installed a dedicated LAMP server to do the job in displaying all data over several web pages. After some testing it appeared that the generation/refreshing of HTML pages was too slow for some of the data I wanted to display in real time (almost). Experimenting with the 7" touch screen directly hooked up to the RP concerned and a dedicated site + html page (the most natural thing to do - buttons sliders ...) to display events and data made things worse.
So my thought is to send these data via socket to the central node, draw the screen with the data displayed in near real time in old school screen refreshing. Only changing what is needed by putting the data on the right spot via ascii "cursor" codes. Rewriting lines on the terminal, scrolling up, is not a "clean / nice" option
So far I found no info how to do that on the Raspi (running headless): drawing a cadre and display some text and data.
Any suggestion will be appreciated

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: ascii input / display dcreen

Sun May 21, 2017 4:06 pm

If the system used to display the data has X, then you can just use X to display the data. Remember that the X Windowing System is defined as a means of remotely displaying graphics, though works well for text as well, by drawing the text.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

Heater
Posts: 15838
Joined: Tue Jul 17, 2012 3:02 pm

Re: ascii input / display dcreen

Mon May 22, 2017 12:00 am

lmqr15,

You don't really have a clear question there. Do you want to display all that data in web pages served up by a web server or do you want to just have a server collect all the data from the remote Pi and display it on its screen?

The advantage of the web pages approach being that you can view the data in a browser from any machine on your network. Or even make them available around the world. And of course your display will now be usable on Linux, Mac, Windows, Android, iPhone etc.
So my thought is to send these data via socket to the central node
So how are you currently sending data from your sensor Pis to the central server Pi?

Here is what I would do:

1) Have all the remote sensor Pi connect to a central server Pi using a TCP/IP socket.

2) On the central server Pi create a server that accepts all those socket connections and recieves the data from the remote Pis.

3) That same central server process will also be a webserver. Serving up the pages that display the data.

4) Those pages will contain Javascript that connects back to the central webserver using websockets. The data collected by the central server from the remote Pi is then streamed to the web pages for real-time (almost) display.

5) The Javascript in the web pages will update the web page content with new data as it arrives.

All that sounds rather complex but it can all be done relatively easily with a small amount of code if you use Jvascript for the central server running under node.js.

Forget all that complexity of Apache, PHP, etc. A simple webserver can be created in node.js with few lines of code. Same for the TCP/IP socket server. You will need Javascript in the web page to perform the display updates do you may as well use Javascript for the server as well.

Have a Google for:

node.js (The Javascript run time)
express.js (A node.js library form making the creation of a web server easy)
socket.io (A node.js library for making web sockets easy)

There are tons of blogs, tutorials etc around the net on how to get started with node.js.
Memory in C++ is a leaky abstraction .

Heater
Posts: 15838
Joined: Tue Jul 17, 2012 3:02 pm

Re: ascii input / display dcreen

Mon May 22, 2017 12:04 am

Of course the remote to central communications can be simplified by not using a plain TCP/IP socket but using a higher level protocol like MQTT.
Memory in C++ is a leaky abstraction .

Return to “General programming discussion”