1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-09-30 01:41:59 +03:00

atrf-path: the GUI is now activated with -g; also changed arguments in GUI mode

- atrf-path.c (usage, main): new option -g to invoke the GUI
- atrf-path.c (usage, main): in GUI mode, the number of sweeps is optional
  (default: infinite)
- atrf-path.c (main), gui.h (gui), gui.c (gui): exit after the specified
  number of sweeps
This commit is contained in:
Werner Almesberger 2011-04-13 09:31:57 -03:00
parent cee0296579
commit 436c9faed5
3 changed files with 35 additions and 10 deletions

View File

@ -139,10 +139,26 @@ static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
"%16s driver_rx[:arg] [sweeps [samples]]\n\n"
"%16s driver_rx[:arg] [sweeps [samples]]\n"
#ifdef HAVE_GFX
"%6s %s -g [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
"%16s driver_rx[:arg] [[sweeps] samples]\n"
#endif
"\n"
#ifdef HAVE_GFX
" -g display results graphically\n"
#endif
" -p power transmit power, 0 to 15 (default %d)\n"
" -t trim trim capacitor, 0 to 15 (default %d)\n"
, name, "", DEFAULT_POWER, DEFAULT_TRIM);
, name, "",
#ifdef HAVE_GFX
"", name, "",
#endif
DEFAULT_POWER, DEFAULT_TRIM);
exit(1);
}
@ -155,14 +171,19 @@ int main(int argc, char **argv)
.trim_rx = DEFAULT_TRIM,
.samples = 1,
};
int graphical = 0;
int power = DEFAULT_POWER;
int sweeps = 1;
unsigned long tmp;
char *end;
int c;
while ((c = getopt(argc, argv, "p:t:")) != EOF)
while ((c = getopt(argc, argv, "gp:t:")) != EOF)
switch (c) {
case'g':
graphical = 1;
sweeps = 0;
break;
case 'p':
tmp = strtoul(optarg, &end, 0);
if (*end || tmp > 15)
@ -195,6 +216,10 @@ int main(int argc, char **argv)
sweeps = strtoul(argv[optind+2], &end, 0);
if (*end)
usage(*argv);
if (graphical && argc-optind == 3) {
sweep.samples = sweeps;
sweeps = 0;
}
/* fall through */
case 2:
tx_drv = argv[optind];
@ -212,10 +237,10 @@ int main(int argc, char **argv)
return 1;
sweep.power = 15-power;
if (sweeps) /* @@@ hack */
do_sweeps(&sweep, sweeps);
if (graphical)
gui(&sweep, sweeps);
else
gui(&sweep);
do_sweeps(&sweep, sweeps);
atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);

View File

@ -109,7 +109,7 @@ static void tstop(void)
}
void gui(const struct sweep *sweep)
void gui(const struct sweep *sweep, int sweeps)
{
SDL_Surface *surf;
SDL_Event event;
@ -127,7 +127,7 @@ void gui(const struct sweep *sweep)
exit(1);
}
while (1) {
while (cycle != sweeps || !sweeps) {
struct sample res[N_CHAN*2];
while (SDL_PollEvent(&event))

View File

@ -19,9 +19,9 @@
#ifdef HAVE_GFX
void gui(const struct sweep *sweep);
void gui(const struct sweep *sweep, int sweeps);
#else
#define gui(sweep) abort()
#define gui(sweep, sweeps) abort()
#endif
#endif /* !GUI_H */