Revision 1437
updated xbee test - fixed xbee_init issue
test_xbee.c | ||
---|---|---|
7 | 7 |
|
8 | 8 |
extern int xbee_send_read_at_command(char* command); |
9 | 9 |
extern int xbee_get_packet(unsigned char* dest); |
10 |
extern void xbee_terminate(void); |
|
10 | 11 |
|
11 | 12 |
/* |
12 | 13 |
* This function tests the xbee, returning the results to teraterm |
... | ... | |
14 | 15 |
* |
15 | 16 |
*/ |
16 | 17 |
|
17 |
static init = 0; |
|
18 |
|
|
19 | 18 |
int testxbee(void) { |
20 | 19 |
|
21 | 20 |
unsigned char buf[100]; |
... | ... | |
24 | 23 |
usb_init(); |
25 | 24 |
usb_puts("usb turned on, test starting:\r\n"); |
26 | 25 |
|
27 |
if(!init) { |
|
28 |
// initialize xbee only once |
|
29 |
if (xbee_lib_init() != 0) { |
|
30 |
usb_puts("xbee_lib_init() failed\r\n"); |
|
31 |
return -1; |
|
32 |
} else { |
|
33 |
usb_puts("xbee_lib__init successful\r\n"); |
|
34 |
init = 1; |
|
35 |
} |
|
26 |
if (xbee_lib_init() != 0) { |
|
27 |
usb_puts("xbee_lib_init() failed\r\n"); |
|
28 |
return -1; |
|
29 |
} else { |
|
30 |
usb_puts("xbee_lib__init successful\r\n"); |
|
36 | 31 |
} |
37 |
|
|
32 |
|
|
38 | 33 |
usb_puts("\r\n\n"); |
39 | 34 |
delay_ms(1000); |
40 | 35 |
|
... | ... | |
49 | 44 |
break; // got a response |
50 | 45 |
} |
51 | 46 |
} |
47 |
|
|
48 |
xbee_terminate(); |
|
52 | 49 |
usb_puts("testxbee done\r\n\r\n"); |
53 |
|
|
50 |
|
|
54 | 51 |
return 0; |
55 | 52 |
} |
Also available in: Unified diff