Merge ~bhill/epics-base:pvAccess-envDefs.h into ~epics-core/epics-base/+git/epics-base:7.0

Proposed by Bruce Hill
Status: Needs review
Proposed branch: ~bhill/epics-base:pvAccess-envDefs.h
Merge into: ~epics-core/epics-base/+git/epics-base:7.0
Diff against target: 127 lines (+80/-0)
3 files modified
configure/CONFIG_ENV (+18/-0)
modules/libcom/src/env/envDefs.h (+20/-0)
modules/libcom/src/env/envSubr.c (+42/-0)
Reviewer Review Type Date Requested Status
mdavidsaver Needs Fixing
Andrew Johnson Needs Fixing
Review via email: mp+358197@code.launchpad.net

Description of the change

Adds pvAccess env variables to envDefs.h

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

Will you be making the necessary pvAccessCPP changes to have it use the envDefs.h envConfigParam APIs to match? Any appropriate default values should also be set in the configure/CONFIG_ENV and/or configure/CONFIG_SITE_ENV files.

~bhill/epics-base:pvAccess-envDefs.h updated
6e96884... by Bruce Hill

Added pvAccess environment variable defaults to CONFIG_ENV.

Revision history for this message
Bruce Hill (bhill) wrote :

Sorry, didn't notice the env defaults in CONFIG_ENV.
I got the defaults from pvAccessConfig.xlsx

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

> I got the defaults from pvAccessConfig.xlsx

Where did you find this file? I don't think I've come across it before.

I like the idea of allowing users to check the PVA settings in the same way as the CA settings. The unfortunate reality is that these two are managed quite differently. cf. pv/configuration.h

I don't think it would be a good idea to merge this without corresponding changes to pvAccessCPP. To do so would potentially confuse users by showing incorrect values when defaults are being override in code, of when environment variables are ignored altogether.

review: Needs Fixing
Revision history for this message
Bruce Hill (bhill) wrote :

There are 2 copies online of pvAccessConfig.xlsx I know of:
https://github.com/epics-base/pvDataWWW/blob/master/mainPage/pvAccessConfig.xlsx
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=2ahUKEwiMqY7h677eAhWHLnwKHSkmA2sQFjABegQIABAC&url=http%3A%2F%2Fepics-pvdata.sourceforge.net%2FpvAccessConfig.xlsx&usg=AOvVaw0zhw0cg-Urqyso6CLM_0Gf

Both appear to be compatible.

I agree w/ your concern re the settings matching w/ pvAccessCPP.

I noticed these env variables were missing when I was asked to update our iocAdmin (iocStats)
with the PVA env variables. We use it to create PV's that display how each
env variable is set, but I don't think it will reflect how one env variable can get
it's default from another env variable.

There doesn't appear to be any support in the CA libs either re staying in sync
with the env variables in envDefs.h.

Revision history for this message
Andrew Johnson (anj) wrote :

Hi Bruce,

I don't understand your point about env variables getting defaults from other env variables, we don't do that.

The CA code uses the routines in envDefs.h to access environment variables, but because of our default mechanism (and to avoid confusion) the code calls them environment parameters. There is a script libCom/src/env/bldEnvData.pl that reads values from Base's CONFIG_ENV, CONFIG_SITE_ENV and any os/CONFIG_SITE_ENV.$(T_A) files and the envDefs.h header and generates an envDefs.c file containing those values, which the API then provides as the default value for a parameter if no environment variable by that name exists at run-time.

The PVA code does not currently use the routines in envDefs.h to access environment variables, so it can't rely on the default value mechanism of environment parameters. This was probably because it's not possible to add extra environment parameters in a sub-module or support module, they currently have to be listed in the envDefs.h file in libCom/env.

I do want to change the way that this code works so modules can define their own parameters and this is probably the right time to do that (after the 7.0.2 release), but exactly how that should work isn't completely clear without doing some more development.

The ENV_PARAM objects with their default values should be compiled into the library built by the module, so the bldEnvData.pl script will need to be modified to load a module-specific header file. How and where we specify default values (particularly for parameters that we expect sites to want to set themselves — they shouldn't have to edit CONFIG_SITE* files inside sub-modules) still needs some thought and discussion; it would be best to have that discussion before writing significant amounts of code to implement something.

- Andrew

review: Needs Fixing
~bhill/epics-base:pvAccess-envDefs.h updated
f6b12f8... by Bruce Hill

Replaced defaults w/ empty for EPICS_PVAS_* env vars that default to their EPICS_PVA_* equivalent.

Allows code such as the following from rsrc/caservertask.c to work for EPICS_PVA_* environment parameters.
    if ( envGetConfigParamPtr ( &EPICS_CAS_SERVER_PORT ) ) {
        ca_server_port = envGetInetPortConfigParam ( &EPICS_CAS_SERVER_PORT, (unsigned short) CA_SERVER_PORT );
    }
    else {
        ca_server_port = envGetInetPortConfigParam ( &EPICS_CA_SERVER_PORT, (unsigned short) CA_SERVER_PORT );
    }

Revision history for this message
Bruce Hill (bhill) wrote :

So looking more in to how defaults are handled in CA vs PVA code, I needed to change
CONFIG_ENV to set most of the EPICS_PVAS_* defaults to empty or empty string.
The empty setting allows code such as this from rsrv/caservertask.c to use
EPICS_CA_SERVER_PORT as the default for EPICS_CAS_SERVER_PORT, even if neither are
actually defined as process environment variables.

if ( envGetConfigParamPtr ( &EPICS_CAS_SERVER_PORT ) ) {
    ca_server_port = envGetInetPortConfigParam ( &EPICS_CAS_SERVER_PORT,
                                 (unsigned short) CA_SERVER_PORT );
}
else {
    ca_server_port = envGetInetPortConfigParam ( &EPICS_CA_SERVER_PORT,
                                 (unsigned short) CA_SERVER_PORT );
}

My point from this is that the envGet*ConfigParam*() routines don't
provide any insight to client code such as in iocStats() re this defaulting
of EPICS_CAS_SERVER_PORT to EPICS_CA_SERVER_PORT, which I think refutes
part of Michael's objection.

As I see it, the make variables defined in CONFIG_ENV allow user overrides
via CONFIG_SITE_ENV to set site defaults for CA environment parameters.

The only change needed to make pvAccess compatible is to use those make
variables to override the default values in pvAccess/src/pva/pv/pvaConstants.h

pvAccess wouldn't need to use the envGet*ConfigParam*() calls as it's current
code in src/server/serverContext.cpp that calls getPropertyAs*() routines
can stay as is.

Revision history for this message
Bruce Hill (bhill) wrote :

I was reviewing this merge request to see what remaining work I needed to do and am not convinced any more changes are needed other than perhaps modifying pvAccessCPP to allow EPICS_PVA* defaults to be configured via configure/CONFIG_ENV.

As I see it, there are two issues here.
1. Allowing configuration of CA and PVA defaults via configure/CONFIG_ENV. This isn't something that we do at SLAC, but should perhaps be supported for PVA for sites which use CONFIG_ENV. Since most sites likely follow our practice and configure via scripts that set the actual environment variables, the values in CONFIG_ENV are only knowable if you examine the file or startup a virgin softIOC and use envGet*() calls to see the default values.

2. Allowing runtime examination of CA and PVA settings via the various envGet*() functions and modules such as iocStats that expose them as PVs.

I think the current state of the patch supports the 2nd use case, and a separate patch would be needed for pvAccessCPP to support build time configuration of PVA defaults.

Revision history for this message
Andrew Johnson (anj) wrote :

Core Mtg: AI on MAD tyo trim the list of var's and Bruce to adjust this. Approved after that.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

Some of these ENVs need to be removed. I need to go through the list again.

review: Needs Fixing
~bhill/epics-base:pvAccess-envDefs.h updated
688a339... by Bruce Hill

Added envFindConfigParam() function so clients can find ENV_PARAM instances.

Revision history for this message
Bruce Hill (bhill) wrote :

Should I remove EPICS_PVAS_MAX_ARRAY_BYTES from envDefs.h?
Any others?

Revision history for this message
Bruce Hill (bhill) wrote :

Also EPICS_PVA_MAX_ARRAY_BYTES?

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

pvAccessCPP will now use these parameters.

However, I'm having second (third?) thoughts about the idea of having a second or third set of default values for these parameters, which are sometimes are used, and sometimes ignored.

Probably the most confusing is EPICS_PVAS_PROVIDER_NAMES. A default value of "local" will actually prevent QSRV from starting! ("local" is the name used by pvDatabaseCPP) The actual default is "<all>", which selects all registered server-type ChannelProviders.

I'm tempted to say that it would be better to defer to the "pvasr" iocsh function, which can print the configuration actually being used by the running server (in IOCs).

That said, the set of parameters which I think should be advertised are:

EPICS_PVA_ADDR_LIST
EPICS_PVA_AUTO_ADDR_LIST
EPICS_PVA_BROADCAST_PORT
EPICS_PVA_SERVER_PORT
EPICS_PVAS_BEACON_ADDR_LIST
EPICS_PVAS_SERVER_PORT
EPICS_PVAS_INTF_ADDR_LIST
EPICS_PVAS_BROADCAST_PORT

Unmerged commits

688a339... by Bruce Hill

Added envFindConfigParam() function so clients can find ENV_PARAM instances.

f6b12f8... by Bruce Hill

Replaced defaults w/ empty for EPICS_PVAS_* env vars that default to their EPICS_PVA_* equivalent.

Allows code such as the following from rsrc/caservertask.c to work for EPICS_PVA_* environment parameters.
    if ( envGetConfigParamPtr ( &EPICS_CAS_SERVER_PORT ) ) {
        ca_server_port = envGetInetPortConfigParam ( &EPICS_CAS_SERVER_PORT, (unsigned short) CA_SERVER_PORT );
    }
    else {
        ca_server_port = envGetInetPortConfigParam ( &EPICS_CA_SERVER_PORT, (unsigned short) CA_SERVER_PORT );
    }

6e96884... by Bruce Hill

Added pvAccess environment variable defaults to CONFIG_ENV.

78addcc... by Bruce Hill

Adding pvAccess env variables to envDefs.h

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/configure/CONFIG_ENV b/configure/CONFIG_ENV
index 59e72d8..826be9f 100644
--- a/configure/CONFIG_ENV
+++ b/configure/CONFIG_ENV
@@ -47,6 +47,24 @@ EPICS_CAS_SERVER_PORT=
47EPICS_CAS_INTF_ADDR_LIST=""47EPICS_CAS_INTF_ADDR_LIST=""
48EPICS_CAS_IGNORE_ADDR_LIST=""48EPICS_CAS_IGNORE_ADDR_LIST=""
4949
50EPICS_PVA_ADDR_LIST=""
51EPICS_PVA_AUTO_ADDR_LIST=YES
52EPICS_PVA_BEACON_PERIOD=15.0
53EPICS_PVA_BROADCAST_PORT=5076
54EPICS_PVA_CONN_TMO=30.0
55EPICS_PVA_DEBUG=0
56EPICS_PVA_MAX_ARRAY_BYTES=16384
57EPICS_PVA_PROVIDER_NAMES="local"
58EPICS_PVA_SERVER_PORT=5075
59
60EPICS_PVAS_AUTO_BEACON_ADDR_LIST=""
61EPICS_PVAS_BEACON_ADDR_LIST=""
62EPICS_PVAS_BEACON_PERIOD=
63EPICS_PVAS_BROADCAST_PORT=
64EPICS_PVAS_MAX_ARRAY_BYTES=
65EPICS_PVAS_PROVIDER_NAMES=""
66EPICS_PVAS_SERVER_PORT=
67
50# Servers to disable68# Servers to disable
51EPICS_IOC_IGNORE_SERVERS=""69EPICS_IOC_IGNORE_SERVERS=""
5270
diff --git a/modules/libcom/src/env/envDefs.h b/modules/libcom/src/env/envDefs.h
index 8be00a9..915e822 100644
--- a/modules/libcom/src/env/envDefs.h
+++ b/modules/libcom/src/env/envDefs.h
@@ -60,6 +60,25 @@ epicsShareExtern const ENV_PARAM EPICS_CAS_SERVER_PORT;
60epicsShareExtern const ENV_PARAM EPICS_CA_BEACON_PERIOD; /* deprecated */60epicsShareExtern const ENV_PARAM EPICS_CA_BEACON_PERIOD; /* deprecated */
61epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PERIOD;61epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PERIOD;
62epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PORT;62epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PORT;
63
64epicsShareExtern const ENV_PARAM EPICS_PVA_ADDR_LIST;
65epicsShareExtern const ENV_PARAM EPICS_PVA_AUTO_ADDR_LIST;
66epicsShareExtern const ENV_PARAM EPICS_PVA_BEACON_PERIOD;
67epicsShareExtern const ENV_PARAM EPICS_PVA_BROADCAST_PORT;
68epicsShareExtern const ENV_PARAM EPICS_PVA_CONN_TMO;
69epicsShareExtern const ENV_PARAM EPICS_PVA_DEBUG;
70epicsShareExtern const ENV_PARAM EPICS_PVA_MAX_ARRAY_BYTES;
71epicsShareExtern const ENV_PARAM EPICS_PVA_PROVIDER_NAMES;
72epicsShareExtern const ENV_PARAM EPICS_PVA_SERVER_PORT;
73
74epicsShareExtern const ENV_PARAM EPICS_PVAS_AUTO_BEACON_ADDR_LIST;
75epicsShareExtern const ENV_PARAM EPICS_PVAS_BEACON_ADDR_LIST;
76epicsShareExtern const ENV_PARAM EPICS_PVAS_BEACON_PERIOD;
77epicsShareExtern const ENV_PARAM EPICS_PVAS_BROADCAST_PORT;
78epicsShareExtern const ENV_PARAM EPICS_PVAS_MAX_ARRAY_BYTES;
79epicsShareExtern const ENV_PARAM EPICS_PVAS_PROVIDER_NAMES;
80epicsShareExtern const ENV_PARAM EPICS_PVAS_SERVER_PORT;
81
63epicsShareExtern const ENV_PARAM EPICS_BUILD_COMPILER_CLASS;82epicsShareExtern const ENV_PARAM EPICS_BUILD_COMPILER_CLASS;
64epicsShareExtern const ENV_PARAM EPICS_BUILD_OS_CLASS;83epicsShareExtern const ENV_PARAM EPICS_BUILD_OS_CLASS;
65epicsShareExtern const ENV_PARAM EPICS_BUILD_TARGET_ARCH;84epicsShareExtern const ENV_PARAM EPICS_BUILD_TARGET_ARCH;
@@ -87,6 +106,7 @@ epicsShareFunc const char * epicsShareAPI
87 envGetConfigParamPtr(const ENV_PARAM *pParam);106 envGetConfigParamPtr(const ENV_PARAM *pParam);
88epicsShareFunc long epicsShareAPI 107epicsShareFunc long epicsShareAPI
89 envPrtConfigParam(const ENV_PARAM *pParam);108 envPrtConfigParam(const ENV_PARAM *pParam);
109epicsShareFunc const ENV_PARAM * envFindConfigParam( const char * envVarName );
90epicsShareFunc long epicsShareAPI 110epicsShareFunc long epicsShareAPI
91 envGetInetAddrConfigParam(const ENV_PARAM *pParam, struct in_addr *pAddr);111 envGetInetAddrConfigParam(const ENV_PARAM *pParam, struct in_addr *pAddr);
92epicsShareFunc long epicsShareAPI 112epicsShareFunc long epicsShareAPI
diff --git a/modules/libcom/src/env/envSubr.c b/modules/libcom/src/env/envSubr.c
index 283b132..1e0f9ba 100644
--- a/modules/libcom/src/env/envSubr.c
+++ b/modules/libcom/src/env/envSubr.c
@@ -24,6 +24,7 @@
24* QUICK REFERENCE24* QUICK REFERENCE
25* #include "envDefs.h"25* #include "envDefs.h"
26* ENV_PARAM param;26* ENV_PARAM param;
27* ENV_PARAM * envFindConfigParam( envVarName )
27* char *envGetConfigParamPtr( pParam )28* char *envGetConfigParamPtr( pParam )
28* char *envGetConfigParam( pParam, bufDim, pBuf )29* char *envGetConfigParam( pParam, bufDim, pBuf )
29* long envGetLongConfigParam( pParam, pLong )30* long envGetLongConfigParam( pParam, pLong )
@@ -52,6 +53,47 @@
5253
5354
5455
55/*+/subr**********************************************************************56/*+/subr**********************************************************************
57* NAME envFindConfigParam - Find an ENV_PARAM for the specified environment variable.
58*
59* DESCRIPTION
60* Returns a pointer to an environment configuration parameter.
61* If the configuration parameter isn't found in the environment,
62* then a NULL pointer is returned.
63*
64* RETURNS
65* pointer to the environment variable, or
66* NULL if no environment configuration parameter was found
67*
68* EXAMPLES
69* 1. Get a pointer to the ENV_PARAM for the EPICS-defined
70* environment parameter EPICS_TS_NTP_INET.
71*
72* #include "envDefs.h"
73* const ENV_PARAM * pParam;
74*
75* pParam = envFindConfigParam( "EPICS_TS_NTP_INET" );
76* if (!pParam) {
77* printf("No ENV_PARAM for EPICS_TS_NTP_INET\n" );
78* }
79*
80*-*/
81const ENV_PARAM * envFindConfigParam( const char * envVarName )
82{
83 const ENV_PARAM **ppParam = env_param_list;
84
85 /* Find a match with one of the EPICS env vars */
86 while (*ppParam) {
87 if ( strcmp( envVarName, (*ppParam)->name ) == 0 ) {
88 return *ppParam;
89 }
90 ppParam++;
91 }
92
93 return 0;
94}
95
96
5697
98/*+/subr**********************************************************************
57* NAME envGetConfigParamPtr - returns a pointer to the configuration 99* NAME envGetConfigParamPtr - returns a pointer to the configuration
58* parameter value string100* parameter value string
59*101*

Subscribers

People subscribed via source and target branches