Project

General

Profile

Revision 1623

update to test cases in trunk

View differences:

trunk/code/projects/unit_tests/test_xbee.c
1 1
#include <dragonfly_lib.h>
2
#include <xbee.h>
2
#include <wl_defs.h>
3
#include "xbee.h"
3 4

  
4 5
#define ROBOT
5 6
#define WL_DEBUG
6
#define WL_DEBUG_PRINT( s ) usb_puts( S )
7
#define WL_DEBUG_PRINT_HEX(s) usb_puth8(s)
7 8

  
8
extern int xbee_send_read_at_command(char* command);
9
extern int xbee_get_packet(unsigned char* dest);
10
extern void xbee_terminate(void);
11

  
12 9
/*
13 10
 * This function tests the xbee, returning the results to teraterm
14 11
 *
15 12
 * 
16 13
 */
17 14
 
15
 
18 16
int testxbee(void) {
19 17

  
20 18
  unsigned char buf[100];
......
22 20
	
23 21
	usb_init();
24 22
	usb_puts("usb turned on, test starting:\r\n");
23
  xbee_init();
25 24
  
26
  if (xbee_lib_init() != 0) {
27
    usb_puts("xbee_lib_init() failed\r\n");
25
  int ret = xbee_lib_init();
26
  
27
  if (ret != 0) {
28
    usb_puts("xbee_init() failed\r\n");
29
    usb_puti(ret);
30
    usb_puts("|\r\n");
28 31
    return -1;
29 32
  } else {
30
    usb_puts("xbee_lib__init successful\r\n");
33
    usb_puts("xbee_init successful\r\n");
31 34
  }
32 35
 
33 36
	usb_puts("\r\n\n");
34 37
	delay_ms(1000);
38
  
39
  // check registers
40
  WL_DEBUG_PRINT("receive interrupt flag(80)=");
41
  WL_DEBUG_PRINT_HEX(UCSR1B&(1<<RXCIE1));
42
  WL_DEBUG_PRINT("|\r\nreceive flag(10)=");
43
  WL_DEBUG_PRINT_HEX(UCSR1B&(1<<RXEN1));
44
  WL_DEBUG_PRINT("|\r\ntransmit flag(08)=");
45
  WL_DEBUG_PRINT_HEX(UCSR1B&(1<<TXEN1));
46
  WL_DEBUG_PRINT("|\r\ncharacter size(06)=");
47
  WL_DEBUG_PRINT_HEX(UCSR1C&((1<<UCSZ10)|(1<<UCSZ11)));
48
  WL_DEBUG_PRINT("|\r\ncharacter size2(00)=");
49
  WL_DEBUG_PRINT_HEX((UCSR1B&(1<<UCSZ12))|(0<<UCSZ12));
50
  WL_DEBUG_PRINT("|\r\n");
51
    
35 52
	
36 53
	// try getting xbee address
37
  xbee_send_read_at_command("MY");
54
  /*xbee_send_read_at_command("MY");
38 55
  while(i++ < 10000) {
39 56
    if(xbee_get_packet(buf) == 3) {
40 57
      usb_puts("got response from xbee\r\n");
......
43 60
      //usb_puts("|end\r\n");
44 61
      break; // got a response
45 62
    }
63
  }*/
64
  
65
  // try setting channel
66
  /*xbee_set_channel(0x0F);
67
  while(i++ < 10000) {
68
    if(xbee_get_packet(buf) == 3) {
69
      usb_puts("got response from xbee\r\n");
70
      break; // got a response
71
    }
46 72
  }
47 73
  
74
  xbee_send_read_at_command("CH");
75
  while(i++ < 10000) {
76
    if(xbee_get_packet(buf) == 3) {
77
      usb_puts("got response from xbee\r\n");
78
      break; // got a response
79
    }
80
  }
81
  
82
  usb_puts("\r\nxbee set channel works\r\n\r\n");
83
  
84
  wl_set_channel(0x16);
85
  while(i++ < 10000) {
86
    if(xbee_get_packet(buf) == 3) {
87
      usb_puts("got response from xbee\r\n");
88
      break; // got a response
89
    }
90
  }
91
  
92
  xbee_send_read_at_command("CH");
93
  while(i++ < 10000) {
94
    if(xbee_get_packet(buf) == 3) {
95
      usb_puts("got response from xbee\r\n");
96
      break; // got a response
97
    }
98
  }  
99
  
100
  usb_puts("\r\nwireless set channel works\r\n");*/
101
  
102
  // scan all xbees in network
103
  /*xbee_send_read_at_command("ND");
104
  i=0;
105
  while(i < 1000) {
106
    if(xbee_get_packet(buf) == 3) {
107
      usb_puts("got response from xbee\r\n");
108
      i++;
109
    }
110
  }*/
111
  
112
  // end of tests
48 113
  xbee_terminate();
114
  /*if (xbee_terminate() != 0) {
115
    usb_puts("xbee_terminate error\r\n");
116
  } else {
117
    usb_puts("xbee_terminate success\r\n");
118
  }*/
49 119
  usb_puts("testxbee done\r\n\r\n");
50 120
    
51 121
	return 0;
52
}
122
}
trunk/code/projects/unit_tests/xbee.c
887 887
		WL_DEBUG_PRINT(".\r\n");
888 888
		return;
889 889
	}
890
  
891
  if (command[0] == 'N' && command[1] == 'D')
892
	{
893
		xbee_channel = xbee_pending_channel;
894
		WL_DEBUG_PRINT("extra=");
895
    WL_DEBUG_PRINT(extra);
896
		WL_DEBUG_PRINT("\r\n");
897
		return;
898
	}
890 899

  
891 900
	if (command[0] == 'M' && command[1] == 'Y' && extraLen != 0)
892 901
	{
trunk/code/projects/unit_tests/main.c
15 15
    // RUN_TEST(testlcd);
16 16
    //RUN_TEST(testlights);
17 17
    //RUN_TEST(testmotors);
18
    RUN_TEST(testrangefinder);
18
    //RUN_TEST(testrangefinder);
19 19
    // RUN_TEST(testtokenring);
20 20
    // RUN_TEST(testwireless);
21
    //RUN_TEST(testxbee);
21
    RUN_TEST(testxbee);
22 22
    delay_ms(1000);
23 23
  }
24 24

  
trunk/code/projects/unit_tests/test_inits.c
2 2

  
3 3
int testinits(void) {
4 4

  
5
  if(usb_init())
5
  /*if(usb_init())
6 6
    return -1;
7 7

  
8 8
  usb_puts("usb\n");
......
81 81
  usb_puts("encoders\n");
82 82

  
83 83

  
84
  usb_puts("init test passed!\n");
84
  usb_puts("init test passed!\n");*/
85 85

  
86 86
  return 0;
87 87

  

Also available in: Unified diff