Commit d3bfae2a authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Federico Vaga

tools/zio-dump: be grep-friendly and not over-verbose

Changes attribute print-out to only show attributes that are
defined (using the mask).  Show them as both decimal and hex.

All lines are grep-friendly, as the used to be. You can grep for
"Ctrl:" or "Data:" or specific attributes.

Example (with "-a"):

   Ctrl: version 0.7, trigger user, dev zloop-0000, cset 1, chan 1
   Ctrl: seq 18, n 16, size 1, bits 8, flags 01000001 (little-endian)
   Ctrl: stamp 1351773544.171337188 (0)
   Ctrl: trigger-std-mask: 0x0002
   Ctrl: trigger-std-1   0x00000010        16
   Data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

For those who, sometimes, want to see all attributes, even when the
mask is zero, there is the "-A" option.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent c930ac62
......@@ -19,41 +19,37 @@ unsigned char buf[1024*1024];
char *prgname;
int do_print_attr;
void print_attributes(struct zio_control *ctrl)
void print_attr_set(char *name, int nattr, uint32_t mask, uint32_t *val)
{
int all = (do_print_attr == 2);
int i;
printf("Device attributes:\n");
printf(" Standard: 0x%04x\n ",
ctrl->attr_channel.std_mask);
for (i = 0; i < 16; ++i) {
if (i == 8)
printf("\n ");
printf ("0x%x ", ctrl->attr_channel.std_val[i]);
}
printf("\n Extened: 0x%08x\n ",
ctrl->attr_channel.ext_mask);
for (i = 0; i < 32; ++i) {
if (i == 8 || i == 16 || i == 24)
printf("\n ");
printf ("0x%x ", ctrl->attr_channel.ext_val[i]);
}
printf("\nTrigger attributes:\n");
printf(" Standard: 0x%04x\n ",
ctrl->attr_trigger.std_mask);
for (i = 0; i < 16; ++i) {
if (i == 8)
printf("\n ");
printf ("0x%x ", ctrl->attr_trigger.std_val[i]);
}
printf("\n Extened: 0x%08x \n ",
ctrl->attr_trigger.ext_mask);
for (i = 0; i < 32; ++i) {
if (i == 8 || i == 16 || i == 24)
printf("\n ");
printf ("0x%x ", ctrl->attr_trigger.ext_val[i]);
if (!(all || mask))
return;
if (nattr == 16)
printf("Ctrl: %s-mask: 0x%04x\n", name, mask);
else
printf("Ctrl: %s-mask: 0x%04x\n", name, mask);
for (i = 0; i < nattr; ++i) {
if (!(all || (mask & (1 << i))))
continue;
printf ("Ctrl: %s-%-2i 0x%08x %9i\n",
name, i, val[i], val[i]);
}
printf("\n");
}
void print_attributes(struct zio_control *ctrl)
{
print_attr_set("device-std", 16, ctrl->attr_channel.std_mask,
ctrl->attr_channel.std_val);
print_attr_set("device-ext", 32, ctrl->attr_channel.ext_mask,
ctrl->attr_channel.ext_val);
print_attr_set("trigger-std", 16, ctrl->attr_trigger.std_mask,
ctrl->attr_trigger.std_val);
print_attr_set("trigger-ext", 32, ctrl->attr_trigger.ext_mask,
ctrl->attr_trigger.ext_val);
}
void read_channel(int cfd, int dfd, FILE *log)
......@@ -176,6 +172,11 @@ int main(int argc, char **argv)
argv++;
argc--;
}
if (argc > 1 && !strcmp(argv[1], "-A")) {
do_print_attr = 2;
argv++;
argc--;
}
if (argc < 3 || (argc & 1) != 1) {
fprintf(stderr, "%s: Wrong number of arguments\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment