/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * This file is distributed subject to a Software License Agreement found * in the file LICENSE that is included with this distribution. \*************************************************************************/ /* * * @(#)dopi.c 1.4 3/30/94 * * Jeff Hill * * Example dumb OPI CA client * * * * 1) converts channel name to a channel id * 2) writes an array of values to the channel if provided * 3) reads out an array of values from the channel and prints them * * * * acc dopi.c -I$(EPICS)/share/epicsH -L$(EPICS)/Unix/sun4/bin -lca -lCom * * */ #include #include #include #define USAGE "usage: dopi [,,...]" int main(int argc, char **argv) { unsigned nelem; unsigned i; char *name; float *pvalue; int status; chid chan; /* * Check for valid arguments */ if(argc<2){ printf("%s\n",USAGE); exit(-1); } name = argv[1]; if(!name){ printf("%s\n",USAGE); exit(-1); } nelem = argc-2; /* * Initialize CA */ SEVCHK(ca_task_initialize(),"Unable to initialize"); /* * get the channel id */ status = ca_search( name, /* channel ASCII name */ &chan /* ptr to chid */ ); SEVCHK(status, "Bad Channel Name?") /* * wait for the channel's IOC to be found */ status = ca_pend_io(1.0); if(status == ECA_TIMEOUT){ printf("%s: Not Found\n",name); exit(-1); } SEVCHK(status, NULL) if(nelem>ca_element_count(chan)){ printf("Specified element count =%d IOC element count=%d\n", nelem, ca_element_count(chan)); printf("%s\n",USAGE); exit(-1); } pvalue = (float *) calloc(ca_element_count(chan),sizeof(*pvalue)); if(!pvalue){ exit(-1); } if(nelem){ for(i=0;i