Project

General

Profile

Revision 1032

Having trouble with wireless (I think) hopefully this will work by friday.

View differences:

receive.c
12 12
#include "../../libwireless/lib/wireless.h"
13 13
#include "../../libwireless/lib/wl_token_ring.h"
14 14

  
15
#define WL_COM_PORT "/dev/ttyUSB0" 
15
#define WL_COM_PORT "/dev/ttyUSB1" 
16 16
#define WL_CHANNEL 0xE
17 17

  
18 18
#define MAP_REQUEST_GROUP 23
19 19

  
20 20
#define DATA_POINT 2 /* packet type for map data points w/ odometry data*/
21 21
#define DATA_REQUEST 3
22
#define DATA_INIT 4 /*Just to give the robot a target.*/
22
#define DATA_SERVER_REPLY 4 /*Just to give the robot a target.*/
23
#define DATA_SERVER_IDENTIFY 5
23 24

  
24 25
#define BUFFER_SIZE 1000
25 26
#define BUFFER_EMPTY -1
......
109 110
			theta = mxGetPr(ret[2]);
110 111
			robot = mxGetPr(ret[3]);
111 112

  
112
			for(index = head_index; index <= tail_index; index = (index + 1)%1024){
113
			for(index = head_index; index <= tail_index; index = (index + 1)%BUFFER_SIZE){
113 114
				point[i][0] = (double)coordinate_buffer[index][0];	
114 115
				point[i][1] = (double)coordinate_buffer[index][1];	
115 116
				
......
142 143
 * number of the server.
143 144
 */
144 145
void* run_wireless(void* arg){
145
	int robot_num, num_robots,time_out, i;	
146

  
147 146
	pthread_detach(pthread_self());
148 147
	
149 148
	init_wireless();
......
206 205
		}
207 206
		pthread_rwlock_unlock(&buffer_lock);
208 207
	}
209
	if(type == DATA_INIT){
210
		wl_send_global_packet(MAP_REQUEST_GROUP, DATA_INIT, NULL, 0, 0);
208
	else if(type == DATA_SERVER_IDENTIFY){
209
		wl_send_global_packet(MAP_REQUEST_GROUP, DATA_SERVER_REPLY, NULL, 0, 0);
211 210
		printf("Announcing self as server\n");
212 211
	}
213 212
}

Also available in: Unified diff