From 1d6d23b44413acea3cc657566b272459d8510a88 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Wed, 6 Jun 2018 15:53:29 +0200 Subject: [PATCH] support for lsi and lso records added --- src/CONFIG_STREAM | 4 +++ src/devlsiStream.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++ src/devlsoStream.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 src/devlsiStream.c create mode 100644 src/devlsoStream.c diff --git a/src/CONFIG_STREAM b/src/CONFIG_STREAM index 7dcd911..2d6c2f7 100644 --- a/src/CONFIG_STREAM +++ b/src/CONFIG_STREAM @@ -15,6 +15,10 @@ ifdef BASE_3_14 RECORDTYPES += calcout endif +ifdef BASE_3_15 +RECORDTYPES += lsi lso +endif + ifdef BASE_3_16 RECORDTYPES += int64in int64out endif diff --git a/src/devlsiStream.c b/src/devlsiStream.c new file mode 100644 index 0000000..e253a72 --- /dev/null +++ b/src/devlsiStream.c @@ -0,0 +1,78 @@ +/*************************************************************** +* Stream Device record interface for string input records * +* * +* (C) 1999 Dirk Zimoch (zimoch@delta.uni-dortmund.de) * +* (C) 2005 Dirk Zimoch (dirk.zimoch@psi.ch) * +* * +* This is an EPICS record Interface for StreamDevice. * +* Please refer to the HTML files in ../doc/ for a detailed * +* documentation. * +* * +* If you do any changes in this file, you are not allowed to * +* redistribute it any more. If there is a bug or a missing * +* feature, send me an email and/or your patch. If I accept * +* your changes, they will go to the next release. * +* * +* DISCLAIMER: If this software breaks something or harms * +* someone, it's your problem. * +* * +***************************************************************/ + +#include "lsiRecord.h" +#include "epicsExport.h" +#include "devStream.h" + +static long readData(dbCommon *record, format_t *format) +{ + lsiRecord *lsi = (lsiRecord *)record; + + if (format->type == DBF_STRING) + { + long len; + if ((len = streamScanfN(record, format, lsi->val, lsi->sizv) == ERROR)) + { + lsi->len = 0; + return ERROR; + } + lsi->len = len; + return OK; + } + return ERROR; +} + +static long writeData(dbCommon *record, format_t *format) +{ + lsiRecord *lsi = (lsiRecord *)record; + + if (format->type == DBF_STRING) + { + return streamPrintf(record, format, lsi->val); + } + return ERROR; +} + +static long initRecord(dbCommon *record) +{ + lsiRecord *lsi = (lsiRecord *)record; + + return streamInitRecord(record, &lsi->inp, readData, writeData) == ERROR ? + ERROR : OK; +} + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read; +} devlsiStream = { + 5, + streamReport, + streamInit, + initRecord, + streamGetIointInfo, + streamRead +}; + +epicsExportAddress(dset,devlsiStream); diff --git a/src/devlsoStream.c b/src/devlsoStream.c new file mode 100644 index 0000000..4331783 --- /dev/null +++ b/src/devlsoStream.c @@ -0,0 +1,77 @@ +/*************************************************************** +* Stream Device record interface for string output records * +* * +* (C) 2018 Dirk Zimoch (dirk.zimoch@psi.ch) * +* * +* This is an EPICS record Interface for StreamDevice. * +* Please refer to the HTML files in ../doc/ for a detailed * +* documentation. * +* * +* If you do any changes in this file, you are not allowed to * +* redistribute it any more. If there is a bug or a missing * +* feature, send me an email and/or your patch. If I accept * +* your changes, they will go to the next release. * +* * +* DISCLAIMER: If this software breaks something or harms * +* someone, it's your problem. * +* * +***************************************************************/ + +#include "lsoRecord.h" +#include "epicsExport.h" +#include "devStream.h" + +static long readData(dbCommon *record, format_t *format) +{ + lsoRecord *lso = (lsoRecord *)record; + + if (format->type == DBF_STRING) + { + long len; + if ((len = streamScanfN(record, format, lso->val, lso->sizv) == ERROR)) + { + lso->len = 0; + return ERROR; + } + lso->len = len; + return OK; + } + return ERROR; +} + +static long writeData(dbCommon *record, format_t *format) +{ + lsoRecord *lso = (lsoRecord *)record; + + if (format->type == DBF_STRING) + { + return streamPrintf(record, format, lso->val); + } + return ERROR; +} + +static long initRecord(dbCommon *record) +{ + lsoRecord *lso = (lsoRecord *)record; + + return streamInitRecord(record, &lso->out, readData, writeData) == ERROR ? + ERROR : OK; +} + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write; +} devlsoStream = { + 5, + streamReport, + streamInit, + initRecord, + streamGetIointInfo, + streamWrite +}; + +epicsExportAddress(dset,devlsoStream);