Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / lib / colonet_wireless / colonet_wireless_test.cpp @ 11

History | View | Annotate | Download (1.89 KB)

1
/* Eugene Marinelli
2
 * 11/2/06
3
 *
4
 * colonet_wireless_test - tests the colonet_wireless library
5
 */
6

    
7
#include <iostream>
8
#include <signal.h>
9

    
10
#include "colonet_wireless.h"
11

    
12
int msg_handler(ColonetPacket* pkt)
13
{
14
  printf("Handler!\n");
15

    
16
  fprintf(stderr, 
17
          "token_src:%d\n"
18
          "token_dest:%d\n"
19
          "msg_dest:%d\n"
20
          "msg_type:%d\n"
21
          "msg_code:%d\n"
22
          "num_robots:%d\n",
23
          pkt->token_src, pkt->token_dest, pkt->msg_dest, pkt->msg_type,
24
          pkt->msg_code, pkt->num_robots);
25
  
26
  printf("data: ");
27

    
28
  for(int i = 0; i < PACKET_DATA_LEN; i++){
29
    printf("%d ", pkt->data[i]);
30
  }
31
  
32
  printf("\n\n");
33

    
34
  return 0;
35
}
36

    
37
int main()
38
{
39
  ColonetWireless* cw = new ColonetWireless(SERIAL_PORT, msg_handler, NULL, 
40
                                            true, false);
41

    
42
  /*
43
  unsigned char orbdata[3] = {0xFF, 0xFF, 0xFF};
44
  unsigned char motordata[4] = {0, 1, 0, 0xFF};
45
  unsigned char motordata2[4] = {0, 0, 0, 0xFF};
46
  unsigned char buzzerdata[5] = {0x01};
47
  */
48

    
49
  unsigned char data[10];
50
  unsigned char msgcode;
51

    
52
  //cw->send(GLOBAL_DEST, 0, 0, "eugene");
53

    
54
  //cw->send(GLOBAL_DEST, COLONET_COMMAND, ORB_SET, orbdata);
55
  //cw->send(GLOBAL_DEST, COLONET_COMMAND, MOTOR1_SET, motordata);
56

    
57
  //cw->send(GLOBAL_DEST, COLONET_COMMAND, BUZZER_INIT, (unsigned char*)"");
58
  //cw->send(GLOBAL_DEST, COLONET_COMMAND, BUZZER_SET_VAL, buzzerdata);
59

    
60
  cw->run_listener_thread();
61

    
62
  printf("spawned thread\n");
63

    
64
  while(1){
65
    printf("Code: ");
66
    scanf("%x", (int*)&msgcode);
67

    
68
    for (int i = 0; i < 5; i++) {
69
      printf("Byte %d: ", i);
70
      scanf("%x", (int*)&(data[i]));
71
    }
72

    
73
    cw->send(GLOBAL_DEST, COLONET_COMMAND, msgcode, data);
74

    
75
    /*
76
    cw->send(GLOBAL_DEST, COLONET_COMMAND, ORB_SET, orbdata);
77
    cw->send(GLOBAL_DEST, COLONET_COMMAND, MOTOR1_SET, motordata);
78
    cw->send(GLOBAL_DEST, COLONET_COMMAND, MOTOR2_SET, motordata2);
79

80
    sleep(3);
81
    */
82
  }
83

    
84
  return 0;
85
}