Added printf device support for stringout record => stdout or stderr

This commit is contained in:
Andrew Johnson
2008-09-24 22:40:37 +00:00
parent 1269897998
commit 506b303c3c
3 changed files with 70 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ LIBSRCS += devMbboDirectSoftCallback.c
LIBSRCS += devSoSoftCallback.c
LIBSRCS += devTimestamp.c
LIBSRCS += devSoStdio.c
LIBRARY_IOC += softDevIoc
softDevIoc_LIBS += miscIoc recIoc asIoc dbIoc registryIoc dbStaticIoc ca Com

View File

@@ -0,0 +1,67 @@
/*************************************************************************\
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include "dbCommon.h"
#include "devSup.h"
#include "recGbl.h"
#include "recSup.h"
#include "epicsExport.h"
#include "stringoutRecord.h"
static long add(dbCommon *pcommon) {
stringoutRecord *prec = (stringoutRecord *) pcommon;
if (prec->out.type != INST_IO)
return S_dev_badOutType;
if (strcmp(prec->out.value.instio.string, "stdout") == 0) {
prec->dpvt = stdout;
} else if (strcmp(prec->out.value.instio.string, "stderr") == 0) {
prec->dpvt = stderr;
} else
return -1;
return 0;
}
static long del(dbCommon *pcommon) {
stringoutRecord *prec = (stringoutRecord *) pcommon;
prec->dpvt = NULL;
return 0;
}
static struct dsxt dsxtSoStdio = {
add, del
};
static long init(int pass)
{
if (pass == 0) devExtend(&dsxtSoStdio);
return 0;
}
static long write(stringoutRecord *prec)
{
if (prec->dpvt)
fprintf((FILE *)prec->dpvt, "%s\n", prec->val);
return 0;
}
/* Create the dset for devSoStdio */
static struct {
dset common;
DEVSUPFUN write;
} devSoStdio = {
{5, NULL, init, NULL, NULL}, write
};
epicsExportAddress(dset, devSoStdio);

View File

@@ -39,3 +39,5 @@ device(ai, INST_IO,devAiGeneralTime,"General Time")
device(bo, INST_IO,devBoGeneralTime,"General Time")
device(longin, INST_IO,devLiGeneralTime,"General Time")
device(stringin,INST_IO,devSiGeneralTime,"General Time")
device(stringout,INST_IO,devSoStdio,"stdio")