Revision 858
bom/token ring test complete
updated testeeprom #include to make it compile
testtokenring.c | ||
---|---|---|
5 | 5 |
|
6 | 6 |
/** |
7 | 7 |
* Tests the token ring and BOM |
8 |
* |
|
8 |
* - prints table of bom values for every robot in token ring |
|
9 |
* - takes several seconds to initialize token ring |
|
9 | 10 |
*/ |
10 | 11 |
|
11 | 12 |
#define MAX_ROBOTS 16 |
... | ... | |
13 | 14 |
// set a list of integers to 0 |
14 | 15 |
void clearRobots(int* list) { |
15 | 16 |
for(int i=0;i<MAX_ROBOTS;i++) |
16 |
list = 0; |
|
17 |
list[i] = 0;
|
|
17 | 18 |
} |
18 | 19 |
|
19 | 20 |
int testtokenring(void) { |
21 |
// initialize everything |
|
20 | 22 |
dragonfly_init(ALL_ON); |
21 | 23 |
usb_init(); |
22 | 24 |
usb_puts("usb turned on\r\n"); |
... | ... | |
33 | 35 |
int i=0; |
34 | 36 |
while(1) { |
35 | 37 |
wl_do(); |
36 |
if (i%100==0) { |
|
38 |
// only print table every 200 loops |
|
39 |
if (i%200==0) { |
|
37 | 40 |
// get token ring size values |
38 | 41 |
usb_puts("\r\nnumber of robots in token ring:"); |
39 | 42 |
usb_puti(wl_token_get_robots_in_ring()); |
... | ... | |
49 | 52 |
if (tmp < 0) |
50 | 53 |
break; |
51 | 54 |
robotList[tmp] = 1; |
52 |
usb_puti(tmp); |
|
53 |
usb_puts(","); |
|
54 | 55 |
numRobots++; |
55 | 56 |
} |
56 | 57 |
if (numRobots < 1) { |
... | ... | |
62 | 63 |
|
63 | 64 |
// print table of bom readings between robots |
64 | 65 |
usb_puts("\r\ns \\ d"); |
66 |
// print header |
|
65 | 67 |
for(int j=0;j<MAX_ROBOTS;j++) |
66 | 68 |
if (robotList[j]) { |
67 | 69 |
usb_puts("\t|"); |
... | ... | |
70 | 72 |
usb_puti(j); |
71 | 73 |
} |
72 | 74 |
usb_puts("\r\n"); |
75 |
// print body |
|
73 | 76 |
for(int l=0;l<MAX_ROBOTS;l++) |
74 | 77 |
if (robotList[l]) { |
75 | 78 |
if (l == wl_get_xbee_id()) |
76 | 79 |
usb_puts("*"); // indicate that this is the current bot |
77 |
usb_puti(l); |
|
80 |
usb_puti(l); // print label col
|
|
78 | 81 |
for(int k=0;k<MAX_ROBOTS;k++) |
79 | 82 |
if (robotList[k]) { |
80 | 83 |
usb_puts("\t|"); |
81 | 84 |
if (k != l) { |
82 | 85 |
int bom = wl_token_get_sensor_reading(l,k); |
83 | 86 |
if (bom >= 0 && bom <= 15) |
84 |
usb_puti(bom); |
|
87 |
usb_puti(bom); // print bom value
|
|
85 | 88 |
} |
86 | 89 |
} |
87 | 90 |
usb_puts("\r\n"); |
Also available in: Unified diff