Revision 1447
fixed testbench, now it works!
also fixed hunter prey reference to allow packet type of 42, but there is still a bug in the reference WRT the latest spec because it waits indefinitely for an ACK
main.c | ||
---|---|---|
116 | 116 |
|
117 | 117 |
if(robotState==ROBOT_TAGGED) { |
118 | 118 |
usb_puts("tagged, waiting to send ACK\n"); |
119 |
delay_ms(TAG_PAUSE); |
|
119 |
//delay_ms(TAG_PAUSE);
|
|
120 | 120 |
move(0,0); |
121 | 121 |
usb_puts("sending ACK to "); |
122 | 122 |
usb_puti(tagger); |
123 | 123 |
usb_putc('\n'); |
124 | 124 |
packet[0] = HUNTER_PREY_ACTION_ACK; |
125 | 125 |
packet[1] = tagger; |
126 |
wl_basic_send_global_packet (0, &packet, 2);
|
|
126 |
wl_basic_send_global_packet (42, &packet, 2);
|
|
127 | 127 |
usb_puts("sent\n"); |
128 | 128 |
robotState = ROBOT_HUNTER; //no longer prey |
129 | 129 |
} |
... | ... | |
184 | 184 |
|
185 | 185 |
|
186 | 186 |
|
187 |
if(hunter_prey_tagged(angle, frontRange)) { |
|
187 |
if(hunter_prey_tagged(angle, frontRange) || button1_read()) {
|
|
188 | 188 |
orb_set_color(YELLOW); |
189 | 189 |
color1 = YELLOW; |
190 | 190 |
color2 = YELLOW; |
... | ... | |
192 | 192 |
tagAck = 0; |
193 | 193 |
packet[0] = HUNTER_PREY_ACTION_TAG; |
194 | 194 |
packet[1] = id; |
195 |
wl_basic_send_global_packet (0, &packet, 2);
|
|
195 |
wl_basic_send_global_packet (42, &packet, 2);
|
|
196 | 196 |
move(0,0); |
197 | 197 |
while(!tagAck) |
198 | 198 |
wl_do(); |
... | ... | |
222 | 222 |
void packet_receive(char type, int source, unsigned char* packet, int length) |
223 | 223 |
{ |
224 | 224 |
|
225 |
if(type==0 && length>=2){
|
|
225 |
if(type==42 && length>=2){
|
|
226 | 226 |
if(packet[0] == HUNTER_PREY_ACTION_TAG) { |
227 | 227 |
if(robotState == ROBOT_PREY) { |
228 | 228 |
robotState = ROBOT_TAGGED; |
Also available in: Unified diff