Project

General

Profile

Revision 120

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

View differences:

wireless.c
6 6
#include "wl_defs.h"
7 7

  
8 8
#ifndef ROBOT
9
#include <time.h>
9
#include <sys/time.h>
10 10
#include <signal.h>
11 11
#else
12 12
#include <time.h>
......
34 34
PacketGroupHandler* wl_packet_groups[WL_MAX_PACKET_GROUPS];
35 35

  
36 36
#ifndef ROBOT
37
timer_t wl_timeout_timer;
38 37

  
39 38
//called when we time out, or receive interrupt
40 39
void sig_handler(int signo)
......
73 72
	rtc_init(HALF_SECOND, &wl_do_timeout); 
74 73
	#endif
75 74
	#else
76
	//create a timer to trigger every half second
77
	struct sigevent evp;
78
	evp.sigev_signo = SIGALRM;
79
	evp.sigev_notify = SIGEV_SIGNAL;
80
	if (timer_create(CLOCK_REALTIME, &evp, &wl_timeout_timer) == -1)
81
	{ 
75
  
76
	//create our timer
77
	struct itimerval timer_val;
78
	struct timeval interval;
79
	interval.tv_sec = 0;
80
	interval.tv_usec = 500000;
81
	struct timeval first_time;
82
	first_time.tv_sec = 0;
83
	first_time.tv_usec = 500000;
84
	timer_val.it_interval = interval;
85
	timer_val.it_value = first_time;
86
	if(setitimer(ITIMER_REAL,&timer_val,NULL)==-1)
87
	{
82 88
		WL_DEBUG_PRINT("Error creating a timer.\r\n"); 
89
		perror("Failure's cause");
83 90
		exit(1); 
84 91
	}
92

  
93
	//create signal handler
85 94
	struct sigaction wl_sig_act;
86 95
	wl_sig_act.sa_handler = (void *)sig_handler;
87 96
	wl_sig_act.sa_flags = 0;
88 97
	sigemptyset(&wl_sig_act.sa_mask);
89 98
	sigaction(SIGALRM, &wl_sig_act, 0);
90 99
	sigaction(SIGINT, &wl_sig_act, 0);
91
	struct itimerspec wl_timeout_time;
92
	wl_timeout_time.it_interval.tv_sec = 0;
93
	wl_timeout_time.it_interval.tv_nsec = 500000000;
94
	wl_timeout_time.it_value.tv_sec = 0;
95
	wl_timeout_time.it_value.tv_nsec = 500000000;
96
	timer_settime(wl_timeout_timer, 0,
97
                        &wl_timeout_time, NULL);
98 100
	#endif
99 101
}
100 102

  
......
103 105
 **/
104 106
void wl_terminate()
105 107
{
106
	#ifndef ROBOT
107
	timer_delete(wl_timeout_timer);
108
	#endif
109
	
110 108
	int i;
111 109
	for (i = 0; i < WL_MAX_PACKET_GROUPS; i++)
112 110
		if (wl_packet_groups[i] != NULL &&
......
350 348
		{
351 349
			WL_DEBUG_PRINT("No response received.\r\n");
352 350
			if (wl_buf[2] == 2)
351
			{
353 352
				WL_DEBUG_PRINT("CCA Failure\r\n");
353
			}
354 354
			if (wl_buf[2] == 3)
355
			{
355 356
				WL_DEBUG_PRINT("Purged\r\n");
357
			}
356 358
		}
357 359
		
358 360
		if (wl_packet_groups[group] != NULL &&

Also available in: Unified diff