diff --git a/src/std/dev/devAaiSoft.c b/src/std/dev/devAaiSoft.c index ff985b088..768ddb00e 100644 --- a/src/std/dev/devAaiSoft.c +++ b/src/std/dev/devAaiSoft.c @@ -52,8 +52,11 @@ epicsExportAddress(dset,devAaiSoft); static long init_record(aaiRecord *prec) { + long nRequest = prec->nelm; + if (prec->inp.type == CONSTANT) { - prec->nord = 0; + dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nRequest); + prec->nord = (nRequest > 0) ? nRequest : 0; } return 0; } diff --git a/src/std/dev/devWfSoft.c b/src/std/dev/devWfSoft.c index c18b9007c..4128ed47a 100644 --- a/src/std/dev/devWfSoft.c +++ b/src/std/dev/devWfSoft.c @@ -49,22 +49,23 @@ epicsExportAddress(dset, devWfSoft); static long init_record(waveformRecord *prec) { - if (prec->inp.type == CONSTANT) { - prec->nord = 0; - } - return 0; + long nelm = prec->nelm; + long status = dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nelm); + + prec->nord = !status && (nelm > 0) ? nelm : 0; + return status; } static long read_wf(waveformRecord *prec) { long nRequest = prec->nelm; + long status = dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest); - dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest); - if (nRequest > 0) { + if (!status && nRequest > 0) { prec->nord = nRequest; if (prec->tsel.type == CONSTANT && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } - return 0; + return status; } diff --git a/src/std/rec/aSubRecord.c b/src/std/rec/aSubRecord.c index 0df5d5cad..2e0785087 100644 --- a/src/std/rec/aSubRecord.c +++ b/src/std/rec/aSubRecord.c @@ -130,8 +130,12 @@ static long init_record(aSubRecord *prec, int pass) struct link *plink = &(&prec->inpa)[i]; if (plink->type == CONSTANT) { - if ((&prec->noa)[i] < 2) - recGblInitConstantLink(plink, (&prec->fta)[i], (&prec->a)[i]); + short dbr = (&prec->fta)[i]; + long n = (&prec->noa)[i]; + + dbLoadLinkArray(plink, dbr, (&prec->a)[i], &n); + if (n > 0) + (&prec->nea)[i] = n; } } diff --git a/src/std/rec/test/arrayOpTest.c b/src/std/rec/test/arrayOpTest.c index 27c0becdd..d77921081 100644 --- a/src/std/rec/test/arrayOpTest.c +++ b/src/std/rec/test/arrayOpTest.c @@ -8,6 +8,7 @@ #include #include "dbAccess.h" +#include "dbTest.h" #include "dbUnitTest.h" #include "errlog.h" @@ -45,16 +46,16 @@ static void testGetPutArray(void) testAbort("Failed to find record wfrec"); memcpy(&save, &addr, sizeof(save)); - testDiag("Fetch initial value"); + testDiag("Fetch initial value of %s", prec->name); dbScanLock(addr.precord); - testOk1(prec->nord==0); + testOk(prec->nord==3, "prec->nord==3 (got %d)", prec->nord); nreq = NELEMENTS(data); if(dbGet(&addr, DBF_DOUBLE, &data, NULL, &nreq, NULL)) testFail("dbGet fails"); else { - testOk(nreq==0, "nreq==0 (got %ld)", nreq); + testOk(nreq==3, "nreq==3 (got %ld)", nreq); } dbScanUnlock(addr.precord); @@ -101,10 +102,10 @@ static void testGetPutArray(void) testAbort("Failed to find record wfrec1"); memcpy(&save, &addr, sizeof(save)); - testDiag("Fetch initial value"); + testDiag("Fetch initial value of %s", prec->name); dbScanLock(addr.precord); - testOk1(prec->nord==0); + testOk(prec->nord==0, "prec->nord==0 (got %d)", prec->nord); nreq = NELEMENTS(data); if(dbGet(&addr, DBF_DOUBLE, &data, NULL, &nreq, NULL)) diff --git a/src/std/rec/test/arrayOpTest.db b/src/std/rec/test/arrayOpTest.db index fc809fbe9..1c011e755 100644 --- a/src/std/rec/test/arrayOpTest.db +++ b/src/std/rec/test/arrayOpTest.db @@ -1,6 +1,7 @@ record(waveform, "wfrec") { field(NELM, "10") field(FTVL, "LONG") + field(INP, [1, 2, 3]) } record(waveform, "wfrec1") { field(NELM, "1")