Skip to content

Commit 079dc77

Browse files
JJL772anjohnson
authored andcommitted
caPutLogShellCommands: Avoid calling certain commands before caPutLog has been initialized
1 parent 51a6c1e commit 079dc77

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

caPutLogApp/caPutLog.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
#define LOCAL static
3838
#endif
3939

40+
static int _caPutLogInitialized = 0;
41+
42+
int caPutLogInitialized()
43+
{
44+
return _caPutLogInitialized != 0;
45+
}
46+
4047
/*
4148
* caPutLogShow ()
4249
*/
@@ -106,6 +113,8 @@ int caPutLogInit (const char *addr_str, int config, double timeout)
106113
return caPutLogError;
107114
}
108115

116+
_caPutLogInitialized = 1;
117+
109118
epicsAtExit(caPutLogExitProc, NULL);
110119

111120
errlogSevPrintf(errlogInfo, "caPutLog: successfully initialized\n");

caPutLogApp/caPutLog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ epicsShareFunc int caPutLogReconf (int config, double timeout);
2525
epicsShareFunc void caPutLogShow (int level);
2626
epicsShareFunc void caPutLogSetTimeFmt (const char *format);
2727
epicsShareFunc void caPutLogSetBurstTimeout (double timeout);
28+
epicsShareFunc int caPutLogInitialized(void);
2829

2930
#ifdef __cplusplus
3031
}

caPutLogApp/caPutLogShellCommands.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ static const iocshArg *const caPutLogReconfArgs[] = {
3636
static const iocshFuncDef caPutLogReconfDef = {"caPutLogReconf", 2, caPutLogReconfArgs};
3737
static void caPutLogReconfCall(const iocshArgBuf *args)
3838
{
39+
if (!caPutLogInitialized()) {
40+
printf("caPutLog not initialized\n");
41+
return;
42+
}
3943
caPutLogReconf(args[0].ival, args[1].dval);
4044
}
4145

@@ -46,6 +50,10 @@ static const iocshArg *const caPutLogShowArgs[] = {
4650
static const iocshFuncDef caPutLogShowDef = {"caPutLogShow", 1, caPutLogShowArgs};
4751
static void caPutLogShowCall(const iocshArgBuf *args)
4852
{
53+
if (!caPutLogInitialized()) {
54+
printf("caPutLog not initialized\n");
55+
return;
56+
}
4957
caPutLogShow(args[0].ival);
5058
}
5159

0 commit comments

Comments
 (0)