IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2011-04-14 01:24:50 (12 years 11 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | c86ce307e22c9ba6e71972622483096ea9c34def |
Message: | 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 |
Files: |
tools/atrf-path/atrf-path.c (3 diffs) tools/atrf-path/gui.c (3 diffs) tools/atrf-path/gui.h (1 diff) |
Change Details
tools/atrf-path/atrf-path.c | ||
---|---|---|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | static void do_sweeps(const struct sweep *sweep, int sweeps) | |
172 | static int do_sweeps(const struct sweep *sweep, int sweeps) | |
173 | 173 | { |
174 | 174 | struct sample res[N_CHAN*2]; /* 2 offsets per channel */ |
175 | int decision = 0, fail, pass; | |
175 | 176 | int i; |
176 | 177 | |
178 | /* | |
179 | * The pass/fail logic here goes as follows: | |
180 | * | |
181 | * Pass if and only if all sweeps pass. | |
182 | * Fail if and only if all sweeps are below the minimum. | |
183 | * Make no decision if any sweeps were above the maximum or if there | |
184 | * was a mixture of pass and fail. | |
185 | */ | |
186 | ||
177 | 187 | for (i = 0; i != sweeps; i++) { |
178 | 188 | if (i) |
179 | 189 | putchar('\n'); |
180 | do_sweep(sweep, res); | |
190 | fail = do_sweep(sweep, res); | |
181 | 191 | print_sweep(sweep, res); |
192 | pass = fail < 0 ? -1 : fail > 0 ? 0 : 1; | |
193 | if (!i) | |
194 | decision = pass; | |
195 | else { | |
196 | if (pass != decision) | |
197 | decision = 0; | |
198 | } | |
182 | 199 | } |
200 | return decision; | |
183 | 201 | } |
184 | 202 | |
185 | 203 | |
... | ... | |
307 | 325 | int sweeps = 1; |
308 | 326 | unsigned long tmp; |
309 | 327 | char *end; |
310 | int c; | |
328 | int c, decision; | |
311 | 329 | |
312 | 330 | while ((c = getopt(argc, argv, "gp:P:t:T:")) != EOF) |
313 | 331 | switch (c) { |
... | ... | |
384 | 402 | init_rx(sweep.rx, sweep.trim_rx); |
385 | 403 | init_tx(sweep.tx, sweep.trim_tx, sweep.power); |
386 | 404 | if (graphical) |
387 | gui(&sweep, sweeps); | |
405 | decision = gui(&sweep, sweeps); | |
388 | 406 | else |
389 | do_sweeps(&sweep, sweeps); | |
407 | decision = do_sweeps(&sweep, sweeps); | |
408 | ||
409 | switch (decision) { | |
410 | case -1: | |
411 | printf("#FAIL\n"); | |
412 | break; | |
413 | case 0: | |
414 | break; | |
415 | case 1: | |
416 | printf("#PASS\n"); | |
417 | break; | |
418 | default: | |
419 | abort(); | |
420 | } | |
390 | 421 | |
391 | 422 | atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF); |
392 | 423 | atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF); |
tools/atrf-path/gui.c | ||
---|---|---|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | void gui(const struct sweep *sweep, int sweeps) | |
172 | int gui(const struct sweep *sweep, int sweeps) | |
173 | 173 | { |
174 | 174 | SDL_Surface *surf; |
175 | 175 | SDL_Event event; |
176 | 176 | int cycle; |
177 | int fail; | |
177 | int fail = 0; | |
178 | 178 | |
179 | 179 | if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
180 | 180 | fprintf(stderr, "SDL_init: %s\n", SDL_GetError()); |
... | ... | |
191 | 191 | for (cycle = 0; cycle != sweeps || !sweeps; cycle++) { |
192 | 192 | struct sample res[N_CHAN*2]; |
193 | 193 | |
194 | /* | |
195 | * Pass/fail logic: | |
196 | * | |
197 | * Quit exit at any time, without making a pass/fail decision | |
198 | * Pass exit if the current result is "pass" | |
199 | * ignored if the current result is "over"/"under" | |
200 | * Fail exit if the current result is "under" | |
201 | * ignored if the current result is "pass" | |
202 | * ignored if the current result is "over", because this | |
203 | * indicates an invalid measurement, not a defective | |
204 | * device | |
205 | */ | |
206 | ||
194 | 207 | while (SDL_PollEvent(&event)) |
195 | if (event.type == SDL_KEYDOWN || | |
196 | event.type == SDL_QUIT) | |
197 | return; | |
208 | switch (event.type) { | |
209 | case SDL_KEYDOWN: | |
210 | switch (event.key.keysym.sym) { | |
211 | case SDLK_f: | |
212 | if (cycle && fail < 0) | |
213 | return -1; | |
214 | break; | |
215 | case SDLK_p: | |
216 | if (cycle && !fail) | |
217 | return 1; | |
218 | break; | |
219 | case SDLK_q: | |
220 | return 0; | |
221 | default: | |
222 | break; | |
223 | } | |
224 | break; | |
225 | case SDL_QUIT: | |
226 | return 0; | |
227 | default: | |
228 | break; | |
229 | } | |
230 | ||
198 | 231 | tstart(); |
199 | 232 | fail = do_sweep(sweep, res); |
200 | 233 | tstop(); |
... | ... | |
211 | 244 | SDL_UnlockSurface(surf); |
212 | 245 | SDL_UpdateRect(surf, 0, 0, 0, 0); |
213 | 246 | } |
247 | ||
248 | return 0; | |
214 | 249 | } |
tools/atrf-path/gui.h | ||
---|---|---|
18 | 18 | #include "sweep.h" |
19 | 19 | |
20 | 20 | |
21 | /* | |
22 | * gui returns one of the following values: | |
23 | * | |
24 | * -1 fail | |
25 | * 0 no decision taken | |
26 | * 1 pass | |
27 | */ | |
28 | ||
21 | 29 | #ifdef HAVE_GFX |
22 | void gui(const struct sweep *sweep, int sweeps); | |
30 | int gui(const struct sweep *sweep, int sweeps); | |
23 | 31 | #else |
24 | #define gui(sweep, sweeps) abort() | |
32 | #define gui(sweep, sweeps) ({ abort(); 0; }) | |
25 | 33 | #endif |
26 | 34 | |
27 | 35 | #endif /* !GUI_H */ |