Project

General

Profile

Revision 966

Small changes - new file just waits for packets to buffer
for matlab, so the robots will decide when to send their
data in this version.

View differences:

receive.c
1
/* This version of receive initializes
2
 * the token ring and then requests and
3
 * receives data in a different packet group
4
 * unsynchronized with the token ring.
5
 */
6

  
1 7
#include <stdio.h>
2 8
#include <stdlib.h>
3 9
#include <mex.h>
......
36 42
int head_index; /*Points to the oldest data in the buffers.*/
37 43

  
38 44
void* buffer_data(void* arg);
45
void init_wireless(void);
39 46

  
40 47
void mexFunction(int nlhs, mxArray* ret[], int nrhs, const mxArray* args[]){
41 48
	
......
122 129
	pthread_rwlock_unlock(&buffer_lock);
123 130
}
124 131

  
132
void init_wireless(void){
133
	/*General communication initialization.	*/
134
	wl_set_com_port(WL_COM_PORT);	
135
	wl_init();
136
	wl_set_channel(WL_CHANNEL);
137
	wl_register_packet_group(&requestHandler);
138

  
139
	/*Token ring / sensor network initialization.*/
140
	wl_token_ring_register();	
141
}
142

  
125 143
/*
126 144
 * buffer_data continuously runs through the robots and
127 145
 * waits for them to respond.
......
131 149

  
132 150
	pthread_detach(pthread_self());
133 151
	
134
	/*General communication initialization.	*/
135
	wl_set_com_port(WL_COM_PORT);	
136
	wl_init();
137
	wl_set_channel(WL_CHANNEL);
138
	wl_register_packet_group(&requestHandler);
139

  
140
	/*Token ring / sensor network initialization.*/
141
	wl_token_ring_register();	
152
	init_wireless();
142 153
	
143 154
	/*Continuously iterate over all the robots - buffering data.*/
144 155
	

Also available in: Unified diff