Skip to content

Commit bc47c38

Browse files
committed
Use epicsTypes.h for Base version related conditions
- fixes #44 - follows M. Davidsaver's suggestions for the original fix
1 parent 4b0acc6 commit bc47c38

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

caPutLogApp/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ INC += caPutLogAs.h
2828
DBD += caPutLog.dbd
2929

3030
# Add support for json format and arrays
31-
# This requires EPICS base version 7.0.1 or higher
31+
# This requires EPICS 7
3232
ifdef BASE_7_0
33-
USR_CPPFLAGS += -DJSON_AND_ARRAYS_SUPPORTED
3433
caPutLog_SRCS += caPutJsonLogTask.cpp
3534
caPutLog_SRCS += caPutJsonLogShellCommands.cpp
3635
INC += caPutJsonLogTask.h

caPutLogApp/caPutLogAs.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
#include <asTrapWrite.h>
5252
#include <epicsVersion.h>
5353

54-
#define BASE_3_14 (EPICS_VERSION * 100 + EPICS_REVISION < 315)
55-
56-
#if !(BASE_3_14)
54+
#if EPICS_VERSION_INT >= VERSION_INT(3,15,0,0)
5755
#include "dbChannel.h"
5856
#endif
5957

@@ -114,7 +112,7 @@ void caPutLogAsStop()
114112

115113
static void caPutLogAs(asTrapWriteMessage *pmessage, int afterPut)
116114
{
117-
#if BASE_3_14
115+
#if EPICS_VERSION_INT < VERSION_INT(3,15,0,0)
118116
dbAddr *paddr = pmessage->serverSpecific;
119117
#else
120118
struct dbChannel *pchan = pmessage->serverSpecific;
@@ -143,7 +141,7 @@ static void caPutLogAs(asTrapWriteMessage *pmessage, int afterPut)
143141

144142
epicsSnprintf(plogData->userid, MAX_USERID_SIZE, "%s", pmessage->userid);
145143
epicsSnprintf(plogData->hostid, MAX_HOSTID_SIZE, "%s", pmessage->hostid);
146-
#if BASE_3_14
144+
#if EPICS_VERSION_INT < VERSION_INT(3,15,0,0)
147145
dbNameOfPV(paddr, plogData->pv_name, PVNAME_STRINGSZ);
148146
#else
149147
epicsSnprintf(plogData->pv_name, PVNAME_STRINGSZ, "%s", pv_name);
@@ -201,9 +199,7 @@ static void caPutLogAs(asTrapWriteMessage *pmessage, int afterPut)
201199

202200
int caPutLogMaxArraySize(short type)
203201
{
204-
#if !JSON_AND_ARRAYS_SUPPORTED
205-
return 1;
206-
#else
202+
#if EPICS_VERSION >= 7
207203
static int const arraySizeLookUpTable [] = {
208204
MAX_ARRAY_SIZE_BYTES/MAX_STRING_SIZE, /* DBR_STRING */
209205
MAX_ARRAY_SIZE_BYTES/sizeof(epicsInt8), /* DBR_CHAR */
@@ -222,9 +218,11 @@ int caPutLogMaxArraySize(short type)
222218
if (type >= DBR_STRING || type <= DBR_ENUM){
223219
return arraySizeLookUpTable[type];
224220
} else {
225-
errlogSevPrintf(errlogMajor, "caPutLogAs: Array size for type %d can not be determind\n", type);
221+
errlogSevPrintf(errlogMajor, "caPutLogAs: Array size for type %d can not be determined\n", type);
226222
return 1;
227223
}
224+
#else
225+
return 1;
228226
#endif
229227
}
230228

caPutLogApp/caPutLogTask.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <shareLib.h>
55
#include <dbDefs.h>
66
#include <epicsTime.h>
7+
#include <epicsVersion.h>
78

89
#ifdef __cplusplus
910
extern "C" {
@@ -12,7 +13,7 @@ extern "C" {
1213
#define MAX_USERID_SIZE 32
1314
#define MAX_HOSTID_SIZE 256
1415

15-
#if JSON_AND_ARRAYS_SUPPORTED
16+
#if EPICS_VERSION >= 7
1617
#define MAX_ARRAY_SIZE_BYTES 400
1718
#else
1819
#define MAX_ARRAY_SIZE_BYTES 0
@@ -35,7 +36,7 @@ typedef union {
3536
epicsFloat64 v_double;
3637
char v_string[MAX_STRING_SIZE];
3738

38-
#if JSON_AND_ARRAYS_SUPPORTED
39+
#if EPICS_VERSION >= 7
3940
epicsInt8 a_int8[MAX_ARRAY_SIZE_BYTES/sizeof(epicsInt8)];
4041
epicsUInt8 a_uint8[MAX_ARRAY_SIZE_BYTES/sizeof(epicsUInt8)];
4142
epicsInt16 a_int16[MAX_ARRAY_SIZE_BYTES/sizeof(epicsInt16)];

0 commit comments

Comments
 (0)