26 #include "epicsVersion.h" 29 #include <epicsGetopt.h> 33 static unsigned statLevel = 0;
38 fprintf (
stderr,
"\nUsage: cainfo [options] <PV name> ...\n\n" 39 " -h: Help: Print this message\n" 40 " -V: Version: Show EPICS and CA versions\n" 41 "Channel Access options:\n" 42 " -w <sec>: Wait time, specifies CA timeout, default is %f second(s)\n" 43 " -s <level>: Call ca_client_status with the specified interest level\n" 44 " -p <prio>: CA priority (0-%u, default 0=lowest)\n" 45 "\nExample: cainfo my_channel another_channel\n\n" 47 fprintf (
stderr,
"\nEPICS Version %s, CA Protocol version %s\n", EPICS_VERSION_STRING,
ca_version() );
72 char *stateStrings[] = {
73 "never connected",
"previously connected",
"connected",
"closed" };
74 char *boolStrings[] = {
"no ",
"" };
81 for (n = 0; n < nPvs; n++) {
94 " Access: %sread, %swrite\n" 95 " Native data type: %s\n" 97 " Element count: %lu\n" 131 int main (
int argc,
char *argv[])
143 while ((opt =
getopt(argc, argv,
":nhVw:s:p:")) != -1) {
149 printf(
"\nEPICS Version %s, CA Protocol version %s\n", EPICS_VERSION_STRING,
ca_version() );
154 fprintf(
stderr,
"'%s' is not a valid timeout value " 155 "- ignored. ('cainfo -h' for help.)\n",
optarg);
160 if (sscanf(
optarg,
"%du", &statLevel) != 1)
162 fprintf(
stderr,
"'%s' is not a valid interest level " 163 "- ignored. ('cainfo -h' for help.)\n",
optarg);
170 fprintf(
stderr,
"'%s' is not a valid CA priority " 171 "- ignored. ('cainfo -h' for help.)\n",
optarg);
178 "Unrecognized option: '-%c'. ('cainfo -h' for help.)\n",
183 "Option '-%c' requires an argument. ('cainfo -h' for help.)\n",
194 if (!statLevel && nPvs < 1)
196 fprintf(
stderr,
"No pv name specified. ('cainfo -h' for help.)\n");
203 fprintf(
stderr,
"CA error %s occurred while trying " 204 "to start channel access.\n",
ca_message(result));
209 pvs = calloc (nPvs,
sizeof(
pv));
212 fprintf(
stderr,
"Memory allocation for channel structures failed.\n");
217 for (n = 0; optind < argc; n++, optind++)
218 pvs[n].name = argv[optind] ;
224 result =
cainfo(pvs, nPvs);
int getopt(int nargc, char *const *nargv, const char *ostr)
LIBCA_API unsigned epicsStdCall ca_write_access(chid chan)
#define dbf_type_to_text(type)
LIBCA_API unsigned long epicsStdCall ca_element_count(chid chan)
LIBCA_API enum channel_state epicsStdCall ca_state(chid chan)
LIBCA_API const char *epicsStdCall ca_host_name(chid channel)
#define dbf_type_to_DBR(type)
#define epicsScanDouble(str, to)
LIBCA_API short epicsStdCall ca_field_type(chid chan)
int epicsStdCall ca_client_status(unsigned level)
#define dbr_type_to_text(type)
int epicsStdCall ca_context_create(ca_preemptive_callback_select premptiveCallbackSelect)
int main(int argc, char *argv[])
LIBCA_API unsigned epicsStdCall ca_read_access(chid chan)
const char *epicsStdCall ca_message(long ca_status)
const char *epicsStdCall ca_version()
int cainfo(pv *pvs, int nPvs)
void epicsStdCall ca_context_destroy()