Project

General

Profile

Revision 120

Seems to work until we get to seeking, where there may be issues with the motors.

View differences:

wl_charging_station.c
2 2

  
3 3
#include <wireless.h>
4 4
#include <wl_defs.h>
5
#include <stdio.h>
6
#include <string.h>
5
#include <serial.h>
7 6

  
8 7
#include "charging_defs.h"
9 8
#include "charging.h"
10 9

  
10
#define NULL 0
11

  
11 12
//Possible states for the robot
12 13
/** The robot is not attempting to recharging. **/
13 14
#define NOT_RECHARGING 0
......
51 52
		wl_charging_response_handler, wl_charging_handle_receive,
52 53
		wl_charging_cleanup};
53 54

  
54
//timing
55
//timer ticks between polls
56
#define VERIFY_DELAY 8
57
#define VERIFY_FREQUENCY 4
58 55

  
59 56
//frames
60 57
#define STATION_AVAILABLE_FRAME 1
......
183 180
		int c = charging_get_verify_count(robot);
184 181
		if (c <= 0)
185 182
		{
183
			STATION_DEBUG_PRINT("Robot ");
184
			STATION_DEBUG_PUTI(robot);
185
			STATION_DEBUG_PRINT(" has timed out.");
186
		
186 187
			charging_cancel(robot);
187 188
			continue;
188 189
		}
189 190
	
190 191
		if (c % VERIFY_FREQUENCY == 0 && c != VERIFY_DELAY)
192
		{
193
			STATION_DEBUG_PRINT("Verification sent to robot ");
194
			STATION_DEBUG_PUTI(robot);
195
			STATION_DEBUG_PRINT(".\n");
191 196
			wl_charging_send_verify(robot);
197
		}
192 198
		
193 199
		charging_set_verify_count(robot, c - 1);
194 200
	}
......
306 312
{
307 313
	int state = charging_get_robot_state(source);
308 314

  
315
	STATION_DEBUG_PRINT("Received verify request from robot ");
316
	STATION_DEBUG_PUTI(source);
317
	STATION_DEBUG_PRINT(".\n");
318

  
309 319
	switch (state)
310 320
	{
311 321
		case STATE_SEEKING:
......
315 325
			wl_charging_send_docked(source);
316 326
			break;
317 327
		case STATE_NOT_CHARGING:
318
			STATION_DEBUG_PRINT("Received verify from unknown robot.\n");
328
			STATION_DEBUG_PRINT("Received verify from unknown robot ");
329
			STATION_DEBUG_PUTI(source);
330
			STATION_DEBUG_PRINT(".\n");
319 331
			wl_charging_send_cancel(source);
320 332
			break;
321 333
		default:
......
334 346
{
335 347
	int state = charging_get_robot_state(source);
336 348

  
349
	STATION_DEBUG_PRINT("Robot ");
350
	STATION_DEBUG_PUTI(source);
351
	STATION_DEBUG_PRINT(" has cancelled charging.\n");
352

  
337 353
	if (state == STATE_NOT_CHARGING)
338 354
	{
339 355
		STATION_DEBUG_PRINT("Received cancel from unknown robot.\n");
......
355 371
{
356 372
	int state = charging_get_robot_state(source);
357 373

  
374
	STATION_DEBUG_PRINT("Robot ");
375
	STATION_DEBUG_PUTI(source);
376
	STATION_DEBUG_PRINT(" has confirmed it is seeking.\n");
377

  
358 378
	if (state == STATE_NOT_CHARGING)
359 379
	{
360 380
		STATION_DEBUG_PRINT("Received seeking from unknown robot.\n");
......
386 406
void wl_charging_docked(int source)
387 407
{
388 408
	int state = charging_get_robot_state(source);
409
	
410
	STATION_DEBUG_PRINT("Robot ");
411
	STATION_DEBUG_PUTI(source);
412
	STATION_DEBUG_PRINT(" has confirmed it is docked.\n");
413
	
389 414
	if (state == STATE_NOT_CHARGING)
390 415
	{
391 416
		STATION_DEBUG_PRINT("Received docked from unknown robot.\n");

Also available in: Unified diff