Project

General

Profile

Revision 1451

Added by Brad Neuman over 11 years ago

added wait for keypress after each test

View differences:

main.c
26 26
#include "hunter_prey.h"
27 27
#include <time.h>
28 28

  
29
#define CHANNEL 0xF // channel for wireless communication
29
#define CHANNEL 12 //0xF // channel for wireless communication
30 30
#define TYPE 42	// packet type for wireless communication
31 31
#define ROBOTID 255 // make up a robot id because the PC doesn't have one
32 32

  
33

  
34
void waitKey() {
35
  unsigned char buf[10];
36

  
37
  //read from stdin
38
   while(read(0, buf, 10)==10) {
39
     printf("!");
40
     fflush(stdout);
41
   }
42

  
43
  while(getchar()==-1);
44
}
45

  
33 46
int main(int argc, char *argv[])
34 47
{
35 48
    char send_buffer[2];    // holds data to send
......
79 92
	printf("FAILED\n");
80 93

  
81 94

  
82
    sleep(10);
95
    waitKey();
83 96

  
84 97
    // Send a TAG, receive an ACK
85 98
    printf("Send TAG, wait for ACK... ");
......
104 117
    // Check ACK for presence and correctness
105 118
    if (!packet_data || data_length < 2 ||
106 119
	    packet_data[0] != HUNTER_PREY_ACTION_ACK ||
107
	    packet_data[1] != ROBOTID)
120
        packet_data[1] != ROBOTID) {
108 121
      printf("FAILED, packet=%p, len=%d\n", packet_data, data_length);
122
      if(data_length >= 2) {
123
	printf("\tpacket = [%c, %d]\n",packet_data[0], packet_data[1]);
124
      }
125
    }
109 126
    else
110 127
	printf("PASSED\n");
111 128

  
129
    waitKey();
130

  
112 131
    // Receive a TAG, send a delayed ACK
113 132
    printf("Receive a TAG, send a delayed ACK... ");
114 133
    fflush(stdout);
......
148 167
	printf("FAILED\n");
149 168

  
150 169

  
170
    waitKey();
171

  
151 172
    printf("sending courtesy tag...");
152 173
    fflush(stdout);
153 174
    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
......
166 187
    else
167 188
	printf("done\n");
168 189

  
190
    waitKey();
169 191

  
170 192
    // Receive a TAG, never send an ACK
171 193
    printf("Receive TAG, never send ACK... ");
......
189 211
    else
190 212
	printf("FAILED\n");
191 213

  
214
    waitKey();
215

  
192 216
    // Receive TAG, send ACK to incorrect robot
193 217
    printf("Receive TAG, send ACK to incorrect robot... ");
194 218
    fflush(stdout);
......
208 232
    else
209 233
	printf("FAILED\n");
210 234

  
235
    waitKey();
236

  
211 237
    // Simulate TAG from robot A to B, ACK from robot B to A
212 238
    printf("Send TAG from robot A to B, ACK from B to A... ");
213 239
    fflush(stdout);

Also available in: Unified diff