Enable execution of single selftest

tinySA-v0.2
erikkaashoek 6 years ago
parent 330aa3c6ec
commit 1b7d416e63

@ -567,6 +567,7 @@ typedef struct setting
float trigger_level; float trigger_level;
int trigger; int trigger;
int linearity_step; int linearity_step;
int test_argument;
uint32_t checksum; uint32_t checksum;
}setting_t; }setting_t;

@ -146,11 +146,15 @@ VNA_SHELL_FUNCTION(cmd_y)
VNA_SHELL_FUNCTION(cmd_selftest) VNA_SHELL_FUNCTION(cmd_selftest)
{ {
if (argc != 1) { if (argc < 1 || argc > 2) {
shell_printf("usage: selftest (1-3)\r\n"); shell_printf("usage: selftest (1-3) [arg]\r\n");
return; return;
} }
setting.test = my_atoi(argv[0]); setting.test = my_atoi(argv[0]);
if (argc == 1)
setting.test_argument = 0;
else
setting.test_argument = my_atoi(argv[1]);
sweep_mode = SWEEP_SELFTEST; sweep_mode = SWEEP_SELFTEST;
} }

@ -1850,14 +1850,19 @@ int validate_peak_below(int i, float margin) {
int validate_below(int tc, int from, int to) { int validate_below(int tc, int from, int to) {
int status = TS_PASS; int status = TS_PASS;
float sum = 0;
int sum_count = 0;
for (int j = from; j < to; j++) { for (int j = from; j < to; j++) {
if (actual_t[j] > stored_t[j] - 5) sum += actual_t[j];
status = TS_CRITICAL; sum_count++;
else if (actual_t[j] > stored_t[j]) { if (actual_t[j] > stored_t[j]) {
status = TS_FAIL; status = TS_FAIL;
break; break;
} }
} }
sum = sum / sum_count;
if (sum > stored_t[from] - 5)
status = TS_CRITICAL;
if (status != TS_PASS) if (status != TS_PASS)
test_fail_cause[tc] = "Above "; test_fail_cause[tc] = "Above ";
return(status); return(status);
@ -2142,7 +2147,9 @@ void self_test(int test)
} }
show_test_info = TRUE; show_test_info = TRUE;
int i=0; int i=0;
while (test_case[i].kind != TC_END) { if (setting.test_argument > 0)
i=setting.test_argument-1;
do {
setting.frequency_IF = old_IF; setting.frequency_IF = old_IF;
test_prepare(i); test_prepare(i);
test_acquire(i); // Acquire test test_acquire(i); // Acquire test
@ -2151,7 +2158,7 @@ void self_test(int test)
wait_user(); wait_user();
} }
i++; i++;
} } while (test_case[i].kind != TC_END && setting.test_argument == 0 );
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(BRIGHT_COLOR_GREEN);
ili9341_drawstring_7x13("Self test complete", 50, 200); ili9341_drawstring_7x13("Self test complete", 50, 200);
ili9341_drawstring_7x13("Touch screen to continue", 50, 215); ili9341_drawstring_7x13("Touch screen to continue", 50, 215);

@ -543,6 +543,7 @@ static void menu_config_cb(int item, uint8_t data)
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
setting.test = 0; setting.test = 0;
setting.test_argument = 0;
sweep_mode = SWEEP_SELFTEST; sweep_mode = SWEEP_SELFTEST;
break; break;
case 4: case 4:

Loading…
Cancel
Save

Powered by TurnKey Linux.