265 int enumAsString = 0;
284 putenv(
"POSIXLY_CORRECT=");
286 while ((opt =
getopt(argc, argv,
":cnlhatsVS#:w:p:F:")) != -1) {
292 printf(
"\nEPICS Version %s, CA Protocol version %s\n", EPICS_VERSION_STRING,
ca_version() );
322 fprintf(
stderr,
"'%s' is not a valid timeout value " 323 "- ignored. ('caput -h' for help.)\n",
optarg);
328 if (sscanf(
optarg,
"%d", &count) != 1)
330 fprintf(
stderr,
"'%s' is not a valid array element count " 331 "- ignored. ('caput -h' for help.)\n",
optarg);
338 fprintf(
stderr,
"'%s' is not a valid CA priority " 339 "- ignored. ('caget -h' for help.)\n",
optarg);
349 "Unrecognized option: '-%c'. ('caput -h' for help.)\n",
354 "Option '-%c' requires an argument. ('caput -h' for help.)\n",
366 fprintf(
stderr,
"No pv name specified. ('caput -h' for help.)\n");
370 fprintf(
stderr,
"No value specified. ('caput -h' for help.)\n");
382 fprintf(
stderr,
"CA error %s occurred while trying " 383 "to start channel access.\n",
ca_message(result));
388 pvs = calloc (nPvs,
sizeof(
pv));
390 fprintf(
stderr,
"Memory allocation for channel structure failed.\n");
413 for (i = optind; i < argc; i++) {
414 len += strlen(argv[i]);
417 cbuf = calloc(len,
sizeof(
char));
419 fprintf(
stderr,
"Memory allocation failed.\n");
422 strcpy(cbuf, argv[optind]);
424 if (argc > optind+1) {
425 for (i = optind + 1; i < argc; i++) {
427 strcat(cbuf, argv[i]);
431 if ((argc - optind) >= 1)
436 sbuf = calloc (count,
sizeof(
EpicsStr));
437 dbuf = calloc (count,
sizeof(
double));
439 fprintf(
stderr,
"Memory allocation failed\n");
452 fprintf(
stderr,
"Read operation timed out: ENUM data was not read.\n");
458 for (i = 0; i < count; ++
i) {
460 if (*(argv+optind+i) == pend) {
461 fprintf(
stderr,
"Enum index value '%s' is not a number.\n",
465 if (dbuf[i] >= bufGrEnum.no_str) {
466 fprintf(
stderr,
"Warning: enum index value '%s' may be too large.\n",
474 for (i = 0; i < count; ++
i) {
480 for (len = 0; len < bufGrEnum.no_str; len++)
481 if (!strcmp(sbuf[i], bufGrEnum.strs[len]))
484 if (len >= bufGrEnum.no_str) {
487 if (sbuf[i] == pend || enumAsString) {
488 fprintf(
stderr,
"Enum string value '%s' invalid.\n", sbuf[i]);
491 if (dbuf[i] >= bufGrEnum.no_str) {
492 fprintf(
stderr,
"Warning: enum index value '%s' may be too large.\n", sbuf[i]);
503 ebuf = calloc(len,
sizeof(
char));
505 fprintf(
stderr,
"Memory allocation failed\n");
510 for (i = 0; i < count; ++
i) {
519 if (format !=
terse) {
521 result =
caget(pvs, nPvs, format, 0, 0);
526 else if (dbrType ==
DBR_CHAR) pbuf = ebuf;
536 result =
ca_array_put (dbrType, count, pvs[0].chid, pbuf);
545 fprintf(
stderr,
"Write operation timed out: Data was not written.\n");
551 fprintf(
stderr,
"Write callback operation timed out\n");
566 result =
caget(pvs, nPvs, format, 0, 0);
int getopt(int nargc, char *const *nargv, const char *ostr)
LIBCA_API int epicsStdCall ca_array_put_callback(chtype type, unsigned long count, chid chanId, const void *pValue, caEventCallBackFunc *pFunc, void *pArg)
int epicsStdCall ca_pend_io(ca_real timeout)
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout(epicsEventId id, double timeOut)
Wait an the event or until the specified timeout period is over.
#define epicsScanDouble(str, to)
LIBCA_API short epicsStdCall ca_field_type(chid chan)
int epicsStdCall ca_context_create(ca_preemptive_callback_select premptiveCallbackSelect)
LIBCA_API int epicsStdCall ca_array_put(chtype type, unsigned long count, chid chanId, const void *pValue)
int caget(pv *pvs, int nPvs, OutputT format, chtype dbrType, unsigned long reqElems)
LIBCA_API int epicsStdCall ca_array_get(chtype type, unsigned long count, chid chanId, void *pValue)
const char *epicsStdCall ca_message(long ca_status)
const char *epicsStdCall ca_version()
char EpicsStr[MAX_STRING_SIZE]
void epicsStdCall ca_context_destroy()
void put_event_handler(struct event_handler_args args)
LIBCOM_API epicsEventId epicsEventCreate(epicsEventInitialState initialState)
Create an epicsEvent for use from C code, or return NULL.
int epicsStrnRawFromEscaped(char *dst, size_t dstlen, const char *src, size_t srclen)