rasProject_01 / weSweetHome  R. 146 2026-09-26
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
meteRead.c File Reference

A CGI program to co-operate with hometerControl. More...

#include "sysBasic.h"
#include "sweetHome.h"
#include "weCGIajax.h"
#include "weShareMem.h"

Functions

int main (int argc, char **argv)
 The program.

Variables

char const prgNamPure []
 The pure program name.
char const prgSVNdat []
 The complete SVN date string.
char const prgSVNrev []
 The complete SVN revision string.

Detailed Description

A CGI program to co-operate with hometerControl.

Copyright (c) 2018 - 2026 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 143 29.08.2026
Rev. 76+ 06.12.2017 : new; derived from hometersConsol.c
Rev. 125 23.03.2018 : power factor (all meters and phases) added
Rev. 132 28.04.2018 : batModU added
Rev. 149 17.06.2010 : pps value added
Rev. 166 14.07.2018 : more pps commands, more help texts (title) in JSON
Rev. 170 24.07.2018 : real temperature names; Umlauts got working
Rev. 187 14.10.2018 : JSON sequences: P in front, T resorted
Rev. 220 09.11.2019 : Growatt values added to valFilVal_t
Rev. 251 11.07.2023 : update for 2nd heater element and prep. car load
Rev. 257 13.07.2024 : surplus power, HTML update (title's UTF8 problems)
Rev. 81 26.03.2025 : comments on web upload updated
Rev. 90 06.08.2025 : battery state of charge (SOC)/%; soc(Ubat)
Rev. 112 19.01.2026 : minor comment changes
Rev. 119 28.05.2026 : separation of tempTankMiddle and tempTankTop
Rev. 140 20.08.2026 : battery state of charge (SOC) by Bluetooth .by[11]
Rev. 141 23.08.2026 : comments, typos
Smart meters' and other process values.
Definition sweetHome.h:611

Client functions

This program gets values from ::hometersControl via shared memory synchronised with a set of semaphores:

sem # 0: exclusive lock of shared memory
(for the shortest time possible !)
sem # 1: signal from from ::hometersControl to other program
sem # 2: signal from from ::hometersControl to this program

Under the same semaphore (#0) lock it may set command codes in the shared memory according to the query string. A query will usually be part of the request when buttons were pressed in the web page.

GCI server functions

This program's output (i.e. AJAX answer) are physical readings, status values and times as a JSON object, leaving the selection of values and their display to the HTML page respectively its Javascript code.

In the JSON object's text delivered all numerical values (int, float) are put as strings in appropriate form and precision. The rationale is to avoid auto parsing of data, all or most of which will probably be formatted (back to text) to be put in the web page. And, alas, formatting is not Javascript's strong point, while parsing a string to a number is no problem in the few cases where a number is needed.

GCI back-link – command by query

This program evaluates a query string parameter command=command. command (2nd) = startPump | stopPump etc. see sweetHome.h and cmdLookUp.

Library usage

The program uses the library (lib...): pthread

Build the program

cross-compile by:

make PROGRAM=meteRead TARGET=meterPi clean all

program by:

make PROGRAM=meteRead TARGET=meterPi progapp

Due to bugs in C make use winscp directly by entering the commands displayed

winscp.com /script=progTransWin /parameter sweet:0123 meterPi var/www/cgi meteRead

The "due to bugs in C make" remark above applies to all winscp command lines displayed.
Uploading / updating a (this) CGI program might require stopping the loop imposed by the corresponding HTML page.

load the matching HTML page(s) respectively update all web files by:

make PROGRAM=www TARGET=meterPi progapp

Due to said bugs in C make use winscp directly by entering the commands displayed

winscp.com /script=dirTransWin /parameter sweet:0123 192.168.178.87 var/www www
winscp.com /script=dirTransWin /parameter sweet:0123 192.168.178.87 var/www www_meterPi

The first will transfer all web files common to projects and targets while the second one will transfer the target specific ones potentially overwriting a non fitting common one. Hence, keep the order displayed.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

The program.

Run by (Apache) web server as (cgi) script with optional (query string) parameters.

Variable Documentation

◆ prgNamPure

char const prgNamPure[]

The pure program name.

To be provided in the application's / program's source.

See also
progNam() progNamB()

◆ prgSVNrev

char const prgSVNrev[]

The complete SVN revision string.

To be provided in the application's / program's source.

See also
progRev()

◆ prgSVNdat

char const prgSVNdat[]

The complete SVN date string.

To be provided in the application's / program's source.

See also
progDat()