Revision 445
added case for client requesting robot positions
trunk/code/projects/colonet/lib/colonet_defs.h | ||
---|---|---|
144 | 144 |
|
145 | 145 |
#define MOVE_TO_ABSOLUTE_POSITION 0x53 |
146 | 146 |
#define ROBOT_REQUEST_POSITION_FROM_SERVER 0x54 |
147 |
#define SERVER_REPORT_POSITION_TO_ROBOT 0x54
|
|
147 |
#define SERVER_REPORT_POSITION_TO_ROBOT 0x55
|
|
148 | 148 |
|
149 |
#define CLIENT_REQUEST_ROBOT_POSITIONS 0x56 |
|
150 |
|
|
149 | 151 |
/* End low-level robot commands */ |
150 | 152 |
|
151 | 153 |
|
trunk/code/projects/colonet/ColonetServer/Command.cpp | ||
---|---|---|
112 | 112 |
return number_tokens; |
113 | 113 |
} |
114 | 114 |
|
115 |
|
|
116 | 115 |
/** |
117 | 116 |
* @brief checks a list of tokens to see if it's valid |
118 | 117 |
* |
... | ... | |
202 | 201 |
return -1; |
203 | 202 |
} |
204 | 203 |
|
205 |
if (second_token == REQUEST_BOM_MATRIX) { |
|
204 |
switch (second_token) { |
|
205 |
case REQUEST_BOM_MATRIX: |
|
206 | 206 |
if (parse_request_bom_matrix(pool_index)) { |
207 | 207 |
return -1; |
208 | 208 |
} |
209 |
} else if (second_token == REQUEST_XBEE_IDS) { |
|
209 |
break; |
|
210 |
|
|
211 |
case REQUEST_XBEE_IDS: |
|
210 | 212 |
if (parse_request_xbee_ids(pool_index)) { |
211 | 213 |
return -1; |
212 | 214 |
} |
213 |
} else { |
|
215 |
break; |
|
216 |
|
|
217 |
case CLIENT_REQUEST_ROBOT_POSITIONS: |
|
218 |
if (parse_request_robot_positions(pool_index)) { |
|
219 |
return -1; |
|
220 |
} |
|
221 |
break; |
|
222 |
|
|
223 |
default: |
|
214 | 224 |
char * my_current_message = "Hi, how are you?\n"; |
215 | 225 |
printf("Sending %s\n", my_current_message); |
216 | 226 |
connection_pool->write_to_client(pool_index, my_current_message, strlen(my_current_message)); |
227 |
break; |
|
217 | 228 |
} |
218 | 229 |
|
219 | 230 |
return 0; |
... | ... | |
261 | 272 |
return 0; |
262 | 273 |
} |
263 | 274 |
|
275 |
int Command::parse_request_robot_positions(int pool_index) { |
|
276 |
printf("TODO - parse_request_robot_positions\n"); |
|
277 |
return 0; |
|
278 |
} |
|
279 |
|
|
264 | 280 |
int Command::parse_request_xbee_ids(int pool_index) { |
265 | 281 |
char temp_xbee_id_buffer[MAX_RESPONSE_LEN]; |
266 | 282 |
char xbee_id_buffer[MAX_RESPONSE_LEN]; |
... | ... | |
268 | 284 |
int num_robots; |
269 | 285 |
int* xbee_ids = colonet_get_xbee_ids(&num_robots); |
270 | 286 |
|
271 |
|
|
272 |
|
|
273 | 287 |
printf("num_robots: %d\n", num_robots); |
274 | 288 |
printf("xbee_ids: "); |
275 | 289 |
for (int i = 0; i < num_robots; i++) { |
... | ... | |
277 | 291 |
} |
278 | 292 |
printf("\n"); |
279 | 293 |
|
280 |
|
|
281 |
|
|
282 | 294 |
if (!connection_pool) { |
283 | 295 |
return -1; |
284 | 296 |
} |
trunk/code/projects/colonet/ColonetServer/includes/Command.h | ||
---|---|---|
26 | 26 |
|
27 | 27 |
int parse_request_bom_matrix(int pool_index); |
28 | 28 |
int parse_request_xbee_ids(int pool_index); |
29 |
int parse_request_robot_positions(int pool_index); |
|
29 | 30 |
|
30 | 31 |
ConnectionPool * connection_pool; |
31 | 32 |
}; |
Also available in: Unified diff