Oneliner: add checking dds_get_x_status
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
e06959abb6
commit
d11066bf84
2 changed files with 123 additions and 57 deletions
|
@ -213,7 +213,7 @@ static dds_return_t check_status_change_fields_are_0 (int ll, dds_entity_t ent)
|
|||
const char *d = lldesc[ll].desc;
|
||||
void *status = malloc (lldesc[ll].size);
|
||||
dds_return_t ret;
|
||||
if ((ret = get_status (ll, ent, status)) <= 0)
|
||||
if ((ret = get_status (ll, ent, status)) < 0)
|
||||
{
|
||||
free (status);
|
||||
return ret;
|
||||
|
@ -1362,6 +1362,23 @@ static int checkstatus (struct oneliner_ctx *ctx, int ll, int ent, struct onelin
|
|||
{
|
||||
const void *p = advance (status, &off, *d);
|
||||
int i;
|
||||
if (peektok (argl, NULL) == '*')
|
||||
{
|
||||
(void) nexttok (argl, NULL);
|
||||
switch (*d)
|
||||
{
|
||||
case 'n': printf ("%s%"PRIu32, sep, *(uint32_t *)p); break;
|
||||
case 'c': printf ("%s%"PRId32, sep, *(int32_t *)p); break;
|
||||
case 'P': printf ("%s%"PRIu32, sep, *(uint32_t *)p); break;
|
||||
case 'R': printf ("%s%d", sep, (int) *(dds_sample_rejected_status_kind *)p); break;
|
||||
case 'I': break; // instance handle is too complicated
|
||||
case 'E': printf ("%s%"PRIx64, sep, *(dds_instance_handle_t *)p); break;
|
||||
default: return DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
printf (" *"); fflush (stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (*d)
|
||||
{
|
||||
case 'n':
|
||||
|
@ -1421,6 +1438,7 @@ static int checkstatus (struct oneliner_ctx *ctx, int ll, int ent, struct onelin
|
|||
default:
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
sep = ", ";
|
||||
if (*d != 'I')
|
||||
field++;
|
||||
|
@ -1729,6 +1747,43 @@ static void dosetflags (struct oneliner_ctx *ctx)
|
|||
dds_entity_unpin (xwr);
|
||||
}
|
||||
|
||||
static void docheckstatus (struct oneliner_ctx *ctx)
|
||||
{
|
||||
const int ll = parse_listener (ctx);
|
||||
if (ll < 0)
|
||||
error (ctx, "checkstatus: requires listener name");
|
||||
if (lldesc[ll].cb_status_off == 0)
|
||||
error (ctx, "checkstatus: listener %s has no status", lldesc[ll].name);
|
||||
struct oneliner_lex l1 = ctx->l;
|
||||
if (*ctx->l.inp != '(')
|
||||
error (ctx, "checkstatus: missing arguments");
|
||||
int tok;
|
||||
while ((tok = nexttok (&ctx->l, NULL)) != EOF && tok != ')')
|
||||
;
|
||||
const int ent = parse_entity (ctx);
|
||||
if (ent < 0)
|
||||
error (ctx, "check listener: requires an entity");
|
||||
if (ctx->es[ent] == 0)
|
||||
make_entity (ctx, ent, NULL);
|
||||
entname_t name;
|
||||
printf ("status(%s %s): ", lldesc[ll].name, getentname (&name, ent));
|
||||
|
||||
void *status = malloc (lldesc[ll].size);
|
||||
dds_return_t ret;
|
||||
if ((ret = get_status (ll, ctx->es[ent], status)) < 0)
|
||||
{
|
||||
free (status);
|
||||
error_dds (ctx, ret, "get_status failed");
|
||||
}
|
||||
if (checkstatus (ctx, ll, ent, &l1, status) <= 0)
|
||||
{
|
||||
free (status);
|
||||
longjmp (ctx->jb, 1);
|
||||
}
|
||||
free (status);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
static void dispatchcmd (struct oneliner_ctx *ctx)
|
||||
{
|
||||
static const struct {
|
||||
|
@ -1737,6 +1792,7 @@ static void dispatchcmd (struct oneliner_ctx *ctx)
|
|||
} cs[] = {
|
||||
{ "-", dodelete },
|
||||
{ "?", dowait },
|
||||
{ "status", docheckstatus },
|
||||
{ "wr", dowr },
|
||||
{ "wrdisp", dowrdisp },
|
||||
{ "disp", dodisp },
|
||||
|
|
|
@ -144,6 +144,10 @@
|
|||
* "i" for instances, "spi" for samples per instance)
|
||||
* sm see pm
|
||||
*
|
||||
* A * can be substituted for any argument to indicate the value
|
||||
* doesn't matter. (The value does get printed, so it can be a
|
||||
* handy way to get quickly check the actual value in some cases).
|
||||
*
|
||||
* | ?!LISTENER
|
||||
*
|
||||
* (Not listener) tests that LISTENER has not been invoked since
|
||||
|
@ -171,6 +175,12 @@
|
|||
* h suppress periodic heartbeats
|
||||
* d drop outgoing data
|
||||
*
|
||||
* | status LISTENER(ARGS) ENTITY-NAME
|
||||
*
|
||||
* Compare the result of dds_get_L_status against ARGS for the
|
||||
* specified entity, where L is corresponds to the event named by
|
||||
* LISTENER. "da" and "dor" events are not allowed.
|
||||
*
|
||||
* WRITE-LIKE ::= wr write
|
||||
* | wrdisp write-dispose
|
||||
* | disp dispose
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue