Change Details
ubbctl/ubbctl.c |
56 | 56 | } |
57 | 57 | printf("%d", pin); |
58 | 58 | } |
59 | | printf("\n"); |
60 | 59 | } |
61 | 60 | |
62 | 61 | |
... | ... | |
121 | 120 | static void usage(const char *name) |
122 | 121 | { |
123 | 122 | fprintf(stderr, |
124 | | "usage: %s\n" |
| 123 | "usage: %s [-c]\n" |
125 | 124 | " %s name=value|action ...\n\n" |
| 125 | " -c continously update the pin status (until user interrupts)\n\n" |
126 | 126 | "Names: nPWR, CMD, CLK, DAT0, DAT1, DAT2, DAT3\n" |
127 | 127 | "Values: F, 0, 1, Z, R\n" |
128 | 128 | "Actions: ON, OFF\n" |
... | ... | |
133 | 133 | |
134 | 134 | int main(int argc, char **argv) |
135 | 135 | { |
| 136 | int continuous = 0; |
136 | 137 | int c, i; |
137 | 138 | |
138 | | while ((c = getopt(argc, argv, "")) != EOF) |
| 139 | while ((c = getopt(argc, argv, "c")) != EOF) |
139 | 140 | switch (c) { |
| 141 | case 'c': |
| 142 | continuous = 1; |
| 143 | break; |
140 | 144 | default: |
141 | 145 | usage(*argv); |
142 | 146 | } |
143 | 147 | |
| 148 | if (argc != optind && continuous) |
| 149 | usage(*argv); |
| 150 | |
144 | 151 | for (i = optind; i != argc; i++) |
145 | 152 | if (!setup_pin(argv[i], 0)) |
146 | 153 | usage(*argv); |
147 | 154 | |
148 | 155 | ubb_open(UBB_ALL); |
149 | 156 | 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 | } |
151 | 169 | } else { |
152 | 170 | for (i = optind; i != argc; i++) |
153 | 171 | setup_pin(argv[i], 1); |
Download the corresponding diff file