Project

General

Profile

Revision 1089

Can now move robots with the GUI, deletion built into GUI but doesn't work in the backend.

View differences:

robot.c
86 86

  
87 87
void robots_pause(void)
88 88
{
89
	pausing = 1;
89
	pausing++;
90 90
	while (!paused) usleep(10000);
91 91
}
92 92

  
93 93
void robots_resume(void)
94 94
{
95
	pausing = 0;
95
	pausing--;
96
	if (pausing < 0)
97
		fprintf(stderr, "More resuming than pausing....\n");
96 98
}
97 99

  
98 100
/**
......
143 145
		if((pid = fork()) < 0)
144 146
		{
145 147
			//Free Shared Memory Region
148
			//TODO: this doesn't work
146 149
			if (!shmdt(r->shared))
147 150
				fprintf(stderr, "Failed to free shared memory.\n");
148 151

  
......
214 217
	if (id < 0 || id >= robots_size)
215 218
		return -1;
216 219
	r = &robots[id];
217
	if (r->id == 0)
220
	if (r->id == -1)
218 221
		return -1;
219

  
222
	
223
	// TODO: this doesn't work
220 224
    if (!shmdt(r->shared))
221 225
	{
222 226
		fprintf(stderr, "Failed to free shared memory.\n");
223
		return -1;
227
		//return -1;
224 228
	}
225 229
	if (!shmctl(r->sharedMemID, IPC_RMID, NULL))
226 230
	{
227 231
		fprintf(stderr, "Failed to free shared memory.\n");
232
		//return -1;
233
	}
234
	if (kill(r->pid, SIGKILL))
235
	{
236
		fprintf(stderr, "Failed to kill robot process.\n");
228 237
		return -1;
229 238
	}
230 239

  
......
266 275
	return &(robots[iterator_pos]);
267 276
}
268 277

  
278
Robot* robot_get(int id)
279
{
280
	if (id >= 0 && id < robots_size)
281
		return &(robots[id]);
282
	else
283
		return NULL;
284
}
285

  
269 286
void sig_chld_handler(int sig)
270 287
{
271 288
  int ret,stat;

Also available in: Unified diff