Date:2013-01-06 17:24:56 (11 years 2 months ago)
Author:Werner Almesberger
Commit:5fadbce41d709f5324aea6c65814aa9eca56419e
Message:ubbctl/ubbctl.c: new option -c for continuous display

Files: ubbctl/ubbctl.c (3 diffs)

Change Details

ubbctl/ubbctl.c
5656        }
5757        printf("%d", pin);
5858    }
59    printf("\n");
6059}
6160
6261
...... 
121120static void usage(const char *name)
122121{
123122        fprintf(stderr,
124"usage: %s\n"
123"usage: %s [-c]\n"
125124" %s name=value|action ...\n\n"
125" -c continously update the pin status (until user interrupts)\n\n"
126126"Names: nPWR, CMD, CLK, DAT0, DAT1, DAT2, DAT3\n"
127127"Values: F, 0, 1, Z, R\n"
128128"Actions: ON, OFF\n"
...... 
133133
134134int main(int argc, char **argv)
135135{
136    int continuous = 0;
136137    int c, i;
137138
138    while ((c = getopt(argc, argv, "")) != EOF)
139    while ((c = getopt(argc, argv, "c")) != EOF)
139140        switch (c) {
141        case 'c':
142            continuous = 1;
143            break;
140144        default:
141145            usage(*argv);
142146        }
143147
148    if (argc != optind && continuous)
149        usage(*argv);
150
144151    for (i = optind; i != argc; i++)
145152        if (!setup_pin(argv[i], 0))
146153            usage(*argv);
147154
148155    ubb_open(UBB_ALL);
149156    if (argc == optind) {
150        show_pins();
157        if (continuous) {
158            while (1) {
159                show_pins();
160                printf("%*s\r", sizeof(pins)/sizeof(*pins)*2,
161                    "");
162                fflush(stdout);
163                usleep(200*1000);
164            }
165        } else {
166            show_pins();
167            putchar('\n');
168        }
151169    } else {
152170        for (i = optind; i != argc; i++)
153171            setup_pin(argv[i], 1);

Archive Download the corresponding diff file

Branches:
master



interactive