Project

General

Profile

Revision 1152

Added self test and communications test

View differences:

main.c
3 3
#include "global.h"
4 4
#include "station_hardware.h"
5 5

  
6
#include "test_comm.h"
6 7
#include "test_bom.h"
7 8
#include "test_rangefinders.h"
8 9
#include "test_encoders.h"
9 10
#include "test_motors.h"
10 11

  
12
bool communication_ok=false;
11 13

  
14
bool require_comm (void)
15
{
16
	if (!communication_ok)
17
		communication_ok=test_comm ();
18

  
19
	if (!communication_ok)
20
		usb_puts ("Communications required. Stop." NL);
21

  
22
	return communication_ok;
23
}
24

  
12 25
void test_all (void)
13 26
{
14 27
	test_bom (true, true);
......
26 39

  
27 40
		usb_puts (NL);
28 41
		usb_puts ("Diagnostic station interactive mode" NL);
29
		usb_puts ("Test (a)ll, (b)om, (r)angefinders, (e)ncoders, (m)otors" NL);
42
		usb_puts ("Test (s)elf, (a)ll, (c)omm, (b)om, (r)angefinders, (e)ncoders, (m)otors" NL);
30 43

  
31 44
		char choice = usb_getc ();
32 45
		switch (choice) {
33
			case 'a': case 'A': test_all ();           break;
34
			case 'b': case 'B': test_bom (true, true); break;
35
			case 'r': case 'R': test_rangefinders ();  break;
36
			case 'e': case 'E': test_encoders ();      break;
37
			case 'm': case 'M': test_motors ();        break;
46
			case 'c': case 'C': test_comm ();                               break;
47
			case 'a': case 'A': if (require_comm ()) test_all ();           break;
48
			case 'b': case 'B': if (require_comm ()) test_bom (true, true); break;
49
			case 'r': case 'R': if (require_comm ()) test_rangefinders ();  break;
50
			case 'e': case 'E': if (require_comm ()) test_encoders ();      break;
51
			case 'm': case 'M': if (require_comm ()) test_motors ();        break;
52
			case 's': case 'S': self_test ();                               break;
38 53
			default: break; // ignore it
39 54
//				usb_puts("Received invalid input ");
40 55
//				usb_putc(choice);

Also available in: Unified diff