From ae6ebc410693cae1cc890c159dbff89c5415d08c Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Wed, 10 Oct 2018 10:16:27 +0200 Subject: [PATCH] mbbo changes: use SHFT and MASK even with VAL (if no xxVL defined or ENUM format) --- docs/mbbo.html | 13 ++++--------- src/devmbboStream.c | 20 +++++++------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/docs/mbbo.html b/docs/mbbo.html index 1bc7105..590cca2 100644 --- a/docs/mbbo.html +++ b/docs/mbbo.html @@ -23,7 +23,7 @@ written or read value.
Not allowed.
-
LONG format (e.g. %i):
+
LONG or ENUM format (e.g. %i):
If any of ZRVL ... FFVL is set @@ -41,17 +41,12 @@ written or read value.
If none of ZRVL ... FFVL is set (all are 0):
-
- Output: x=VAL
- Input: VAL=x
+
+ Output: x=(VAL<<SHFT)&MASK
+ Input: VAL=(RBV=(x&MASK))>>SHFT
-
ENUM format (e.g. %{):
-
- Output: x=VAL
- Input: VAL=x
-
STRING format (e.g. %s):
Output: Depending on VAL, one of ZRST diff --git a/src/devmbboStream.c b/src/devmbboStream.c index ecdfdfc..61ff2ee 100644 --- a/src/devmbboStream.c +++ b/src/devmbboStream.c @@ -33,11 +33,12 @@ static long readData(dbCommon *record, format_t *format) { case DBF_ULONG: case DBF_LONG: + case DBF_ENUM: { if (streamScanf(record, format, &val) == ERROR) return ERROR; + if (mbbo->mask) val &= mbbo->mask; mbbo->rbv = val; mbbo->rval = val; - if (mbbo->mask) val &= mbbo->mask; if (mbbo->shft > 0) val >>= mbbo->shft; /* read VAL or RBV? Look if any value is defined */ if (mbbo->sdef) @@ -56,12 +57,6 @@ static long readData(dbCommon *record, format_t *format) mbbo->val = (epicsEnum16)val; break; } - case DBF_ENUM: - { - if (streamScanf(record, format, &val) == ERROR) return ERROR; - mbbo->val = (epicsEnum16)val; - break; - } case DBF_STRING: { char buffer[sizeof(mbbo->zrst)]; @@ -110,39 +105,38 @@ static long writeData(dbCommon *record, format_t *format) switch (format->type) { case DBF_ULONG: + case DBF_ENUM: /* print VAL or RVAL ? */ val = mbbo->val; + if (mbbo->shft > 0) val <<= mbbo->shft; if (mbbo->sdef) for (i=0; i<16; i++) { if ((&mbbo->zrvl)[i]) { /* any values defined ? */ val = mbbo->rval; - if (mbbo->mask) val &= mbbo->mask; break; } } + if (mbbo->mask) val &= mbbo->mask; return streamPrintf(record, format, val); case DBF_LONG: { /* print VAL or RVAL ? */ val = (epicsInt16)mbbo->val; + if (mbbo->shft > 0) val <<= mbbo->shft; if (mbbo->sdef) for (i=0; i<16; i++) { if ((&mbbo->zrvl)[i]) { /* any values defined ? */ val = (epicsInt32)mbbo->rval; - if (mbbo->mask) val &= mbbo->mask; break; } } + if (mbbo->mask) val &= mbbo->mask; return streamPrintf(record, format, val); } - case DBF_ENUM: - { - return streamPrintf(record, format, mbbo->val); - } case DBF_STRING: { if (mbbo->val >= 16) return ERROR;