Project

General

Profile

Revision 201

Stuff!

View differences:

test_main.c
9 9
void bom_handler(BomNode* head);
10 10
void encoder_handler(unsigned char* data);
11 11

  
12
char bom_responded_flag;
13
char ir_responded_flag;
14
char encoder_responded_flag;
12
unsigned char bom_responded_flag;
13
unsigned char ir_responded_flag;
14
unsigned char encoder_responded_flag;
15 15

  
16 16
int main(void){
17
  wl_set_com_port("/dev/cu.usbserial-A1000Qu6");
17 18
  wl_init();
18
  wl_token_ring_register(); 
19
  wl_token_ring_register();
19 20
  data_requests_init(bom_handler,IR_handler,encoder_handler);
21
  
20 22
  int robot_id;
21 23
  bom_responded_flag = 0;
22 24
  ir_responded_flag = 0;
23 25
  encoder_responded_flag = 0;
26
  int test_count; 
24 27
  while(1){
28
      wl_do();
29
      printf(".");
25 30
      wl_token_iterator_begin();
26
      printf("This far.\n");
27 31
      while(wl_token_iterator_has_next()){
28 32
        robot_id = wl_token_iterator_next();
29 33

  
......
35 39
        while(!bom_responded_flag){
36 40
          delay_ms(50);
37 41
        }
38
*/        
42
*/       
43
        printf("Sending a request to %i\n",robot_id);
39 44
        request_IR_data(robot_id);
40
        while(!ir_responded_flag){
41
          usleep(50000);
45
        test_count=0;
46
        while(!(ir_responded_flag)&&(test_count++<20)){
47
          wl_do();
48
          printf("Waiting on %i..\n",robot_id);
49
          usleep(500000);
42 50
        }
43 51
/*       
44 52
        request_encoder_data(robot_id);
......
47 55
        }
48 56
*/
49 57
      }
58
      usleep(500000);
50 59
  }
51 60
}
52 61

  
53 62
void IR_handler(unsigned char* data){
54
  char i;
63
  char i = 0;
64
  printf("IR Callback occurred.\n");
55 65
  for(i=0;i<5;i++){
56
    printf("IR %i is %u\n\n",i,data[i]);
66
    printf("IR %i is %i\n",i+1,(int)data[i]);
57 67
  }
58 68
  ir_responded_flag=1;
59 69
}

Also available in: Unified diff