mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-26 13:59:42 +02:00
atrf-path: added pass/fail indication (in the GUI, accept the result with P/F)
- atrf-path.c (do_sweeps): return a pass/fail/undecided value - gui.h (gui), gui.c (gui): return a pass/fail/undecided value - gui.c (gui): return pass/fail when P or F is pressed; exit unconditionally if Q is pressed - atrf-path.c (main): according to the decision of "gui" or "do_sweeps", print "#PASS", "#FAIL", or nothing
This commit is contained in:
parent
fbc7aee55f
commit
c86ce307e2
@ -169,17 +169,35 @@ static void print_sweep(const struct sweep *sweep, const struct sample *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void do_sweeps(const struct sweep *sweep, int sweeps)
|
static int do_sweeps(const struct sweep *sweep, int sweeps)
|
||||||
{
|
{
|
||||||
struct sample res[N_CHAN*2]; /* 2 offsets per channel */
|
struct sample res[N_CHAN*2]; /* 2 offsets per channel */
|
||||||
|
int decision = 0, fail, pass;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The pass/fail logic here goes as follows:
|
||||||
|
*
|
||||||
|
* Pass if and only if all sweeps pass.
|
||||||
|
* Fail if and only if all sweeps are below the minimum.
|
||||||
|
* Make no decision if any sweeps were above the maximum or if there
|
||||||
|
* was a mixture of pass and fail.
|
||||||
|
*/
|
||||||
|
|
||||||
for (i = 0; i != sweeps; i++) {
|
for (i = 0; i != sweeps; i++) {
|
||||||
if (i)
|
if (i)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
do_sweep(sweep, res);
|
fail = do_sweep(sweep, res);
|
||||||
print_sweep(sweep, res);
|
print_sweep(sweep, res);
|
||||||
|
pass = fail < 0 ? -1 : fail > 0 ? 0 : 1;
|
||||||
|
if (!i)
|
||||||
|
decision = pass;
|
||||||
|
else {
|
||||||
|
if (pass != decision)
|
||||||
|
decision = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return decision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -307,7 +325,7 @@ int main(int argc, char **argv)
|
|||||||
int sweeps = 1;
|
int sweeps = 1;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c, decision;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "gp:P:t:T:")) != EOF)
|
while ((c = getopt(argc, argv, "gp:P:t:T:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -384,9 +402,22 @@ int main(int argc, char **argv)
|
|||||||
init_rx(sweep.rx, sweep.trim_rx);
|
init_rx(sweep.rx, sweep.trim_rx);
|
||||||
init_tx(sweep.tx, sweep.trim_tx, sweep.power);
|
init_tx(sweep.tx, sweep.trim_tx, sweep.power);
|
||||||
if (graphical)
|
if (graphical)
|
||||||
gui(&sweep, sweeps);
|
decision = gui(&sweep, sweeps);
|
||||||
else
|
else
|
||||||
do_sweeps(&sweep, sweeps);
|
decision = do_sweeps(&sweep, sweeps);
|
||||||
|
|
||||||
|
switch (decision) {
|
||||||
|
case -1:
|
||||||
|
printf("#FAIL\n");
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
printf("#PASS\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
||||||
atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
||||||
|
@ -169,12 +169,12 @@ static void tstop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gui(const struct sweep *sweep, int sweeps)
|
int gui(const struct sweep *sweep, int sweeps)
|
||||||
{
|
{
|
||||||
SDL_Surface *surf;
|
SDL_Surface *surf;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int cycle;
|
int cycle;
|
||||||
int fail;
|
int fail = 0;
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "SDL_init: %s\n", SDL_GetError());
|
fprintf(stderr, "SDL_init: %s\n", SDL_GetError());
|
||||||
@ -191,10 +191,43 @@ void gui(const struct sweep *sweep, int sweeps)
|
|||||||
for (cycle = 0; cycle != sweeps || !sweeps; cycle++) {
|
for (cycle = 0; cycle != sweeps || !sweeps; cycle++) {
|
||||||
struct sample res[N_CHAN*2];
|
struct sample res[N_CHAN*2];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass/fail logic:
|
||||||
|
*
|
||||||
|
* Quit exit at any time, without making a pass/fail decision
|
||||||
|
* Pass exit if the current result is "pass"
|
||||||
|
* ignored if the current result is "over"/"under"
|
||||||
|
* Fail exit if the current result is "under"
|
||||||
|
* ignored if the current result is "pass"
|
||||||
|
* ignored if the current result is "over", because this
|
||||||
|
* indicates an invalid measurement, not a defective
|
||||||
|
* device
|
||||||
|
*/
|
||||||
|
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
if (event.type == SDL_KEYDOWN ||
|
switch (event.type) {
|
||||||
event.type == SDL_QUIT)
|
case SDL_KEYDOWN:
|
||||||
return;
|
switch (event.key.keysym.sym) {
|
||||||
|
case SDLK_f:
|
||||||
|
if (cycle && fail < 0)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case SDLK_p:
|
||||||
|
if (cycle && !fail)
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case SDLK_q:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_QUIT:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tstart();
|
tstart();
|
||||||
fail = do_sweep(sweep, res);
|
fail = do_sweep(sweep, res);
|
||||||
tstop();
|
tstop();
|
||||||
@ -211,4 +244,6 @@ void gui(const struct sweep *sweep, int sweeps)
|
|||||||
SDL_UnlockSurface(surf);
|
SDL_UnlockSurface(surf);
|
||||||
SDL_UpdateRect(surf, 0, 0, 0, 0);
|
SDL_UpdateRect(surf, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,18 @@
|
|||||||
#include "sweep.h"
|
#include "sweep.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gui returns one of the following values:
|
||||||
|
*
|
||||||
|
* -1 fail
|
||||||
|
* 0 no decision taken
|
||||||
|
* 1 pass
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_GFX
|
#ifdef HAVE_GFX
|
||||||
void gui(const struct sweep *sweep, int sweeps);
|
int gui(const struct sweep *sweep, int sweeps);
|
||||||
#else
|
#else
|
||||||
#define gui(sweep, sweeps) abort()
|
#define gui(sweep, sweeps) ({ abort(); 0; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !GUI_H */
|
#endif /* !GUI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user