Project

General

Profile

Revision 1152

Added self test and communications test

View differences:

trunk/code/projects/diagnostic_station/station/test_comm.h
1
#ifndef _test_comm_h
2
#define _test_comm_h
3

  
4
#include <dragonfly_lib.h>
5

  
6
bool test_comm (void);
7

  
8

  
9

  
10
#endif
trunk/code/projects/diagnostic_station/station/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);
trunk/code/projects/diagnostic_station/station/self_test.c
1
#include "test_bom.h"
2
#include "global.h"
3

  
4
void self_test ()
5
{
6
	usb_puts("Doing self test" NL);
7
	
8
	// FIXME implement
9
	// move all movable parts a bit, and flahsh the lights
10
	
11
	usb_puts("Self test finished" NL);
12
}
trunk/code/projects/diagnostic_station/station/test_comm.c
1
#include "test_comm.h"
2
#include "global.h"
3

  
4
/** Returns whether we have communication **/
5
bool test_comm ()
6
{
7
	usb_puts("Testing communications" NL);
8

  
9
	// FIXME implement
10

  
11
	bool success=true;
12

  
13
	if (success)
14
		usb_puts("Communication test succeeded" NL);
15
	else
16
		usb_puts("Communication test failed" NL);
17

  
18
	return success;
19
}
trunk/code/projects/diagnostic_station/station/self_test.h
1
#ifndef _self_test_h
2
#define _self_test_h
3

  
4
#include <dragonfly_lib.h>
5

  
6
void self_test ();
7

  
8

  
9

  
10
#endif

Also available in: Unified diff