rasProject_01 / weSweetHome  R. 240
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
growattRead.c File Reference

A CGI program for a Growatt PV inverter. More...

#include "sysBasic.h"
#include "arch/config.h"
#include "growattHome.h"
#include "weCGIajax.h"
#include "weShareMem.h"
#include "weModbus.h"
#include <fcntl.h>

Functions

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

Variables

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

Detailed Description

A CGI program for a Growatt PV inverter.

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

Revision history

Rev. 247 5.05.2023
Rev. 209 16.07.2019 : new; derived from meteRead.c
Rev. 210 28.07.2019 : JSON syntax (https://jsonformatter.org/json-parser)
Rev. 211 01.08.2019 : P U I f like meteRead instead of U I P f
Rev. 212 03.08.2019 : read holding registers on request
Rev. 215 27.08.2019 : from direct Modbus read to shared memory

Client functions

This program gets values from growattLink 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 (growattRead) This program gets values from a Growatt PV inverter via a serial Modbus link.

In future, under the same semaphore (#0) lock, it may set command codes via 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 (common gateway interface) server functions

This program's output (i.e. AJAX answer) are physical readings, status values and times as JSON object, leaving 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 would not be a problem, if a number is needed.

This beta version is fixed to: 9600 baud slave 1 and 1 inverter with 1 panel, 0 batteries and 1 AC-power line. All read values are put in one "reads:"[] array. This will have to be more structured (c.f. meteRead.c) in future.

GCI back-link – command by query

Not implemented yet.

Library usage

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

cross-compile by:

make PROGRAM=growattRead TARGET=growPi clean all

program by:

make PROGRAM=growattRead TARGET=growPi FTPuser=pi:piSecret progapp

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()