Revision 196
Updated token ring.
wl_token_ring.c | ||
---|---|---|
70 | 70 |
//current robot to check in the iterator |
71 | 71 |
int iteratorCount = 0; |
72 | 72 |
|
73 |
// the amount of time a robot has had its BOM on for |
|
74 |
int bom_on_count = 0; |
|
75 |
|
|
73 | 76 |
void do_nothing(void) {} |
74 | 77 |
int get_nothing(void) {return -1;} |
75 | 78 |
|
... | ... | |
204 | 207 |
deathDelay--; |
205 | 208 |
if (joinDelay >= 0) |
206 | 209 |
joinDelay--; |
210 |
if (bom_on_count >= 0) |
|
211 |
bom_on_count++; |
|
207 | 212 |
} |
208 | 213 |
|
209 | 214 |
/** |
... | ... | |
318 | 323 |
void wl_token_pass_receive(int source, char nextRobot, unsigned char* sensorData, int sensorDataLength) |
319 | 324 |
{ |
320 | 325 |
int i, j; |
326 |
|
|
327 |
// this prevents two tokens from being passed around at a time |
|
328 |
if (source != wl_token_next_robot && bom_on_count <= DEATH_DELAY / 2) |
|
329 |
{ |
|
330 |
WL_DEBUG_PRINT("Received token pass when a robot should not have died yet.\n"); |
|
331 |
WL_DEBUG_PRINT("There are probably two tokens going around, packet ignored.\n"); |
|
332 |
return; |
|
333 |
} |
|
334 |
|
|
335 |
bom_on_count = -1; |
|
321 | 336 |
deathDelay = -1; |
322 |
|
|
323 | 337 |
WL_DEBUG_PRINT("Received the token from robot"); |
324 | 338 |
WL_DEBUG_PRINT_INT(source); |
325 | 339 |
WL_DEBUG_PRINT(", next robot is "); |
... | ... | |
492 | 506 |
WL_DEBUG_PRINT("Robot "); |
493 | 507 |
WL_DEBUG_PRINT_INT(source); |
494 | 508 |
WL_DEBUG_PRINT(" has flashed its bom.\r\n"); |
509 |
|
|
510 |
bom_on_count = 0; |
|
495 | 511 |
|
496 | 512 |
sensor_matrix_set_reading(sensorMatrix, wl_get_xbee_id(), |
497 | 513 |
source, get_max_bom_function()); |
Also available in: Unified diff