mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-30 17:46:15 +02:00
ubb-patgen/ubb-patgen.c: new option -p to force interpretation as pattern
In the unlikely event that we have a file with the same name.
This commit is contained in:
parent
69aba6ae19
commit
d60ef14022
@ -489,10 +489,11 @@ static void usage(const char *name)
|
|||||||
"usage: %s\n"
|
"usage: %s\n"
|
||||||
" %s [-q] -f freq_hz\n"
|
" %s [-q] -f freq_hz\n"
|
||||||
" %s [-q] [-f freq_hz] -c [active_s]\n"
|
" %s [-q] [-f freq_hz] -c [active_s]\n"
|
||||||
" %s [-q] [-f freq_hz] [-C] file|pattern\n\n"
|
" %s [-q] [-f freq_hz] [-C] [-p] file|pattern\n\n"
|
||||||
" -c output bus clock on CLK without sending a pattern\n"
|
" -c output bus clock on CLK without sending a pattern\n"
|
||||||
" -C temporarily output bus clock on CLK (for debugging)\n"
|
" -C temporarily output bus clock on CLK (for debugging)\n"
|
||||||
" -f freq_hz set bus clock to the specified frequency (default: 1 MHz)\n"
|
" -f freq_hz set bus clock to the specified frequency (default: 1 MHz)\n"
|
||||||
|
" -p force interpretation of argument as pattern (and not file)\n"
|
||||||
" -q quiet. Don't pretty-print frequencies; don't report clock\n"
|
" -q quiet. Don't pretty-print frequencies; don't report clock\n"
|
||||||
" differences.\n\n"
|
" differences.\n\n"
|
||||||
" active_s keep running that many seconds after setting the clock\n"
|
" active_s keep running that many seconds after setting the clock\n"
|
||||||
@ -515,14 +516,14 @@ int main(int argc, char **argv)
|
|||||||
struct mmcclk clk;
|
struct mmcclk clk;
|
||||||
int bus_hz = 0, clk_only = 0, clkout = 0, bus_rel = 0;
|
int bus_hz = 0, clk_only = 0, clkout = 0, bus_rel = 0;
|
||||||
const char *pattern = NULL;
|
const char *pattern = NULL;
|
||||||
int quiet = 0;
|
int quiet = 0, force_pattern = 0;
|
||||||
double active_s = 0;
|
double active_s = 0;
|
||||||
struct timespec active_ns;
|
struct timespec active_ns;
|
||||||
int keep_clk = 1;
|
int keep_clk = 1;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "cCf:q")) != EOF)
|
while ((c = getopt(argc, argv, "cCf:pq")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'f':
|
case 'f':
|
||||||
if (!frequency(optarg, &bus_hz, &bus_rel))
|
if (!frequency(optarg, &bus_hz, &bus_rel))
|
||||||
@ -534,6 +535,9 @@ int main(int argc, char **argv)
|
|||||||
case 'C':
|
case 'C':
|
||||||
clkout = 1;
|
clkout = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
force_pattern = 1;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
quiet = 1;
|
quiet = 1;
|
||||||
break;
|
break;
|
||||||
@ -548,7 +552,7 @@ int main(int argc, char **argv)
|
|||||||
case 0:
|
case 0:
|
||||||
if (clk_only)
|
if (clk_only)
|
||||||
break;
|
break;
|
||||||
if (clkout)
|
if (clkout || force_pattern)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
|
|
||||||
ubb_open(UBB_ALL);
|
ubb_open(UBB_ALL);
|
||||||
@ -565,6 +569,8 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
if (clk_only) {
|
if (clk_only) {
|
||||||
|
if (force_pattern)
|
||||||
|
usage(*argv);
|
||||||
active_s = strtod(argv[argc-1], &end);
|
active_s = strtod(argv[argc-1], &end);
|
||||||
if (*end)
|
if (*end)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
@ -579,7 +585,7 @@ int main(int argc, char **argv)
|
|||||||
usage(*argv);
|
usage(*argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pattern)
|
if (pattern && !force_pattern)
|
||||||
pattern = load_pattern(pattern);
|
pattern = load_pattern(pattern);
|
||||||
|
|
||||||
ubb_open(UBB_ALL);
|
ubb_open(UBB_ALL);
|
||||||
|
Loading…
Reference in New Issue
Block a user