Added -p option to specify CA priority.

This commit is contained in:
Ralph Lange
2008-11-14 13:03:25 +00:00
parent e48b9ec4ab
commit c5773eafb4
6 changed files with 52 additions and 11 deletions
+12 -2
View File
@@ -52,6 +52,7 @@ void usage (void)
"Channel Access options:\n"
" -w <sec>: Wait time, specifies CA timeout, default is %f second(s)\n"
" -c: Asynchronous get (use ca_get_callback and wait for completion)\n"
" -p <prio>: CA priority (0-%u, default 0=lowest)\n"
"Format options:\n"
" Default output format is \"name value\"\n"
" -t: Terse mode - print only value, without name\n"
@@ -87,7 +88,7 @@ void usage (void)
" -0b: Print as binary number\n"
"\nExample: caget -a -f8 my_channel another_channel\n"
" (uses wide output format, doubles are printed as %%f with precision of 8)\n\n"
, DEFAULT_TIMEOUT);
, DEFAULT_TIMEOUT, CA_PRIORITY_MAX);
}
@@ -348,7 +349,7 @@ int main (int argc, char *argv[])
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); /* Set stdout to line buffering */
while ((opt = getopt(argc, argv, ":taicnhse:f:g:#:d:0:w:")) != -1) {
while ((opt = getopt(argc, argv, ":taicnhse:f:g:#:d:0:w:p:")) != -1) {
switch (opt) {
case 'h': /* Print usage */
usage();
@@ -402,6 +403,15 @@ int main (int argc, char *argv[])
count = 0;
}
break;
case 'p': /* CA priority */
if (sscanf(optarg,"%u", &caPriority) != 1)
{
fprintf(stderr, "'%s' is not a valid CA priority "
"- ignored. ('caget -h' for help.)\n", optarg);
caPriority = DEFAULT_CA_PRIORITY;
}
if (caPriority > CA_PRIORITY_MAX) caPriority = CA_PRIORITY_MAX;
break;
case 's': /* Select string dbr for floating type data */
floatAsString = 1;
break;
+12 -2
View File
@@ -37,8 +37,9 @@ void usage (void)
"Channel Access options:\n"
" -w <sec>: Wait time, specifies CA timeout, default is %f second(s)\n"
" -s <level>: Call ca_client_status with the specified interest level\n"
" -p <prio>: CA priority (0-%u, default 0=lowest)\n"
"\nExample: cainfo my_channel another_channel\n\n"
, DEFAULT_TIMEOUT);
, DEFAULT_TIMEOUT, CA_PRIORITY_MAX);
}
@@ -133,7 +134,7 @@ int main (int argc, char *argv[])
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); /* Set stdout to line buffering */
while ((opt = getopt(argc, argv, ":nhw:s:")) != -1) {
while ((opt = getopt(argc, argv, ":nhw:s:p:")) != -1) {
switch (opt) {
case 'h': /* Print usage */
usage();
@@ -154,6 +155,15 @@ int main (int argc, char *argv[])
statLevel = 0;
}
break;
case 'p': /* CA priority */
if (sscanf(optarg,"%u", &caPriority) != 1)
{
fprintf(stderr, "'%s' is not a valid CA priority "
"- ignored. ('caget -h' for help.)\n", optarg);
caPriority = DEFAULT_CA_PRIORITY;
}
if (caPriority > CA_PRIORITY_MAX) caPriority = CA_PRIORITY_MAX;
break;
case '?':
fprintf(stderr,
"Unrecognized option: '-%c'. ('caget -h' for help.)\n",
+12 -2
View File
@@ -44,6 +44,7 @@ void usage (void)
" -w <sec>: Wait time, specifies CA timeout, default is %f second(s)\n"
" -m <mask>: Specify CA event mask to use, with <mask> being any combination of\n"
" 'v' (value), 'a' (alarm), 'l' (log). Default: va\n"
" -p <prio>: CA priority (0-%u, default 0=lowest)\n"
"Timestamps:\n"
" Default: Print absolute timestamps (as reported by CA server)\n"
" -t <key>: Specify timestamp source(s) and type, with <key> containing\n"
@@ -71,7 +72,7 @@ void usage (void)
" -0b: Print as binary number\n"
"\nExample: camonitor -f8 my_channel another_channel\n"
" (doubles are printed as %%f with precision of 8)\n\n"
, DEFAULT_TIMEOUT);
, DEFAULT_TIMEOUT, CA_PRIORITY_MAX);
}
@@ -208,7 +209,7 @@ int main (int argc, char *argv[])
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); /* Set stdout to line buffering */
while ((opt = getopt(argc, argv, ":nhm:se:f:g:#:d:0:w:t:")) != -1) {
while ((opt = getopt(argc, argv, ":nhm:se:f:g:#:d:0:w:t:p:")) != -1) {
switch (opt) {
case 'h': /* Print usage */
usage();
@@ -252,6 +253,15 @@ int main (int argc, char *argv[])
reqElems = 0;
}
break;
case 'p': /* CA priority */
if (sscanf(optarg,"%u", &caPriority) != 1)
{
fprintf(stderr, "'%s' is not a valid CA priority "
"- ignored. ('caget -h' for help.)\n", optarg);
caPriority = DEFAULT_CA_PRIORITY;
}
if (caPriority > CA_PRIORITY_MAX) caPriority = CA_PRIORITY_MAX;
break;
case 'm': /* Select CA event mask */
eventMask = 0;
{
+12 -2
View File
@@ -57,6 +57,7 @@ void usage (void)
"Channel Access options:\n"
" -w <sec>: Wait time, specifies CA timeout, default is %f second(s)\n"
" -c: Asynchronous put (use ca_put_callback and wait for completion)\n"
" -p <prio>: CA priority (0-%u, default 0=lowest)\n"
"Format options:\n"
" -t: Terse mode - print only sucessfully written value, without name\n"
" -l: Long mode \"name timestamp value stat sevr\" (read PVs as DBR_TIME_xxx)\n"
@@ -69,7 +70,7 @@ void usage (void)
" Value format: number of requested values, then list of values\n"
"\nExample: caput my_channel 1.2\n"
" (puts 1.2 to my_channel)\n\n"
, DEFAULT_TIMEOUT);
, DEFAULT_TIMEOUT, CA_PRIORITY_MAX);
}
@@ -252,7 +253,7 @@ int main (int argc, char *argv[])
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); /* Set stdout to line buffering */
putenv("POSIXLY_CORRECT="); /* Behave correct on GNU getopt systems */
while ((opt = getopt(argc, argv, ":cnlhats#:w:")) != -1) {
while ((opt = getopt(argc, argv, ":cnlhats#:w:p:")) != -1) {
switch (opt) {
case 'h': /* Print usage */
usage();
@@ -293,6 +294,15 @@ int main (int argc, char *argv[])
count = 0;
}
break;
case 'p': /* CA priority */
if (sscanf(optarg,"%u", &caPriority) != 1)
{
fprintf(stderr, "'%s' is not a valid CA priority "
"- ignored. ('caget -h' for help.)\n", optarg);
caPriority = DEFAULT_CA_PRIORITY;
}
if (caPriority > CA_PRIORITY_MAX) caPriority = CA_PRIORITY_MAX;
break;
case '?':
fprintf(stderr,
"Unrecognized option: '-%c'. ('caput -h' for help.)\n",
+2 -1
View File
@@ -46,6 +46,7 @@ char timeFormatStr[30] = "%Y-%m-%d %H:%M:%S.%06f"; /* Time format string */
int enumAsNr = 0; /* used for -n option - get DBF_ENUM as number */
double caTimeout = 1.0; /* wait time default (see -w option) */
capri caPriority = DEFAULT_CA_PRIORITY; /* CA Priority */
#define TIMETEXTLEN 28 /* Length of timestamp text buffer */
@@ -528,7 +529,7 @@ int create_pvs (pv* pvs, int nPvs, caCh *pCB)
result = ca_create_channel (pvs[n].name,
pCB,
&pvs[n],
CA_PRIORITY,
caPriority,
&pvs[n].chid);
if (result != ECA_NORMAL) {
fprintf(stderr, "CA error %s occurred while trying "
+2 -2
View File
@@ -44,7 +44,7 @@
* being >=0 */
#define CA_PRIORITY 50 /* CA priority */
#define DEFAULT_CA_PRIORITY 0 /* Default CA priority */
#define DEFAULT_TIMEOUT 1.0 /* Default CA timeout */
@@ -79,7 +79,7 @@ extern IntFormatT outType; /* Flag used for -0.. output format option */
extern int enumAsNr; /* Used for -n option (get DBF_ENUM as number) */
extern double caTimeout; /* Wait time default (see -w option) */
extern char dblFormatStr[]; /* Format string to print doubles (see -e -f option) */
extern capri caPriority; /* CA priority */
extern char *val2str (const void *v, unsigned type, int index);
extern char *dbr2str (const void *value, unsigned type);