Project

General

Profile

Revision 1029

Switched wl_init and wl_set_com_port in test.c (again?)

View differences:

trunk/code/projects/mapping/server/test.c
40 40
    
41 41
    char c;
42 42
    int robot = atoi(argv[1]);
43
	char port[14];	/* port that XBee is on */
43
    char port[14];	/* port that XBee is on */
44 44

  
45
	/* USB port to use is second cmd-line argument */
46
	strcpy(port, "/dev/ttyUSB");
47
	strcat(port, argv[2]);
45
    /* USB port to use is second cmd-line argument */
46
    strcpy(port, "/dev/ttyUSB");
47
    strcat(port, argv[2]);
48 48

  
49 49
    printf("Beginning: robot=%d\r\n", robot);
50
    wl_set_com_port(port);
50 51
    wl_init();
51
	wl_set_com_port(port);
52
	wl_set_channel(CHAN);
53
	printf("Wireless initialized.\r\n");
54
	wl_register_packet_group(&cntlHandler);
55
	wl_register_packet_group(&receiveHandler);
52
    wl_set_channel(CHAN);
53
    printf("Wireless initialized.\r\n");
54
    wl_register_packet_group(&cntlHandler);
55
    wl_register_packet_group(&receiveHandler);
56 56
    printf("Packet groups initialized.\r\n");
57 57
    fflush(stdout);
58 58
    
59
        file = fopen("input.txt", "w");
60
        if (file == NULL) {
61
            printf("fopen error\n");
62
            return 1;
63
        }
59
    file = fopen("input.txt", "w");
60
    if (file == NULL) {
61
	printf("fopen error\n");
62
	return 1;
63
    }
64 64

  
65
        WINDOW* win = initscr();
66
        nodelay(win, TRUE);
67
        while (1) {
68
            wl_do();
69
            c = getch();
70
            if(c != ERR) {
71
                printf("%c\r\n", c);
72
                fflush(stdout);
73
                if (c=='0')
74
                    break;
75
                switch (c) {
76
                    case 'w':
77
                        send_packet(CNTL_FORWARD, robot);
78
                        break;
79
                    case 's':
80
                        send_packet(CNTL_BACK, robot);
81
                        break;
82
                    case 'a':
83
                        send_packet(CNTL_LEFT, robot);
84
                        break;
85
                    case 'd':
86
                        send_packet(CNTL_RIGHT, robot);
87
                        break;
88
                    case 'q':
89
                        send_packet(CNTL_LEFT_CURVE, robot);
90
                        break;
91
                    case 'e':
92
                        send_packet(CNTL_RIGHT_CURVE, robot);
93
                        break;
94
                    case 'x':
95
                        send_packet(CNTL_STOP, robot);
96
                        break;
97
                    case ']':
98
                        send_packet(CNTL_VEL_UP, robot);
99
                        break;
100
                    case '[':
101
                        send_packet(CNTL_VEL_DOWN, robot);
102
                        break;
103
                    default:
104
                        //send_packet(CNTL_STOP, robot);
105
                        break;
106
                }
107
            }
108
    	}
109
    	fclose(file);
110
    	delwin(win);
111
    	endwin();
112
    	refresh();
113
	return 0;
65
    WINDOW* win = initscr();
66
    nodelay(win, TRUE);
67
    while (1) {
68
	wl_do();
69
	c = getch();
70
	if(c != ERR) {
71
	    printf("%c\r\n", c);
72
	    fflush(stdout);
73
	    if (c=='0')
74
		break;
75
	    switch (c) {
76
		case 'w':
77
		    send_packet(CNTL_FORWARD, robot);
78
		    break;
79
		case 's':
80
		    send_packet(CNTL_BACK, robot);
81
		    break;
82
		case 'a':
83
		    send_packet(CNTL_LEFT, robot);
84
		    break;
85
		case 'd':
86
		    send_packet(CNTL_RIGHT, robot);
87
		    break;
88
		case 'q':
89
		    send_packet(CNTL_LEFT_CURVE, robot);
90
		    break;
91
		case 'e':
92
		    send_packet(CNTL_RIGHT_CURVE, robot);
93
		    break;
94
		case 'x':
95
		    send_packet(CNTL_STOP, robot);
96
		    break;
97
		case ']':
98
		    send_packet(CNTL_VEL_UP, robot);
99
		    break;
100
		case '[':
101
		    send_packet(CNTL_VEL_DOWN, robot);
102
		    break;
103
		default:
104
		    //send_packet(CNTL_STOP, robot);
105
		    break;
106
	    }
107
	}
108
    }
109
    fclose(file);
110
    delwin(win);
111
    endwin();
112
    refresh();
113
    return 0;
114 114
}
115 115

  
116 116
void send_packet (char type, int dst_robot) {

Also available in: Unified diff