Project

General

Profile

Revision 887

Updated trunk branch of wireless... Still won't work though because of Makefile.

View differences:

trunk/code/projects/libwireless/lib/sensor_matrix.h
64 64
	 **/
65 65
	int numJoined;
66 66
	/**
67
	 * The element representing a robot is true if that robot
68
	 * is in the token ring and false otherwise.
69
	 **/
70
	unsigned char joined[MAXIMUM_XBEE_ID];
71

  
72
	// on the bayboard, we don't include the matrix to save memory.
73
#ifndef BAYBOARD
74
	/**
67 75
	 * The matrix. Each row represents the readings of one
68 76
	 * robot.
69 77
	 **/
70 78
	unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
71
	/**
72
	 * The element representing a robot is true if that robot
73
	 * is in the token ring and false otherwise.
74
	 **/
75
	unsigned char joined[MAXIMUM_XBEE_ID];
79
#endif
76 80
} SensorMatrix;
77 81

  
78 82
/**@brief Create a sensor matrix **/
trunk/code/projects/libwireless/lib/xbee.c
83 83
static int xbee_enter_command_mode(void);
84 84
static int xbee_exit_command_mode(void);
85 85
static int xbee_enter_api_mode(void);
86
static int xbee_exit_api_mode(void);
87 86
static int xbee_wait_for_string(char* s, int len);
88 87
static int xbee_wait_for_ok(void);
89 88

  
......
213 212
#ifdef FIREFLY
214 213
	UCSR0B |= _BV(RXCIE) | _BV(RXEN);
215 214
#else
215
#ifdef BAYBOARD
216
	UCSR1B |= _BV(RXCIE1);
217
#else
216 218
	UCSR1B |= _BV(RXCIE);
217 219
#endif
220
#endif
218 221
	sei();
219 222
#else
220 223
	xbee_stream = open(xbee_com_port, O_RDWR);
......
730 733
				buffer_first = 0;
731 734
			// check if buffer is empty
732 735
			if (buffer_first == buffer_last) {
733
				return 0;
736
				return -1;
734 737
			}
735 738
		} while (arrival_buf[buffer_first++] != XBEE_FRAME_START);
736 739

  
......
762 765

  
763 766
		// check if buffer is empty
764 767
		if (buffer_first == buffer_last) {
765
			return 0;
768
			return -1;
766 769
		}
767 770
		xbee_buf[currentBufPos++] = arrival_buf[buffer_first++];
768 771
		if (buffer_first == XBEE_BUFFER_SIZE) {
......
780 783

  
781 784
	//we will take care of the packet
782 785
	if (xbee_handle_packet(xbee_buf + 3, len) != 0) {
783
		return 0;
786
		return -1;
784 787
	}
785 788

  
786 789
	if (dest == NULL) {
787
		return 0;
790
		return -1;
788 791
	}
789 792

  
790 793
	int i;
trunk/code/projects/libwireless/lib/Makefile
1 1
############################
2 2
### Update this Section ####
3 3
############################
4

  
5 4
COLONYROOT = ../../../..
6 5

  
7 6
# Target file name (without extension).
......
9 8
COLONET_TARGET = libwireless_colonet
10 9

  
11 10
############################
11
# don't touch this unless you know what you're doing.
12 12

  
13 13
CDEFS = 
14 14

  
......
179 179
	gcc *.c -Wall -Wshadow -Wextra -g -I. -c
180 180
	ar rcs $(TARGET).a $(OBJ)
181 181

  
182
# we should fine a better way to do this.....
183
bayboard:
184
	avr-gcc *.c -DBAYBOARD -mmcu=atmega164p -I. -DF_CPU=8000000UL -DROBOT -I../../../../code/lib/include/libbayboard \
185
			-L../../../../code/lib/bin/bayboard -Wall -Wshadow -Wextra -std=gnu99 -MD -MP -MF -c
186
	avr-ar rcs $(TARGET).a $(OBJ)
187

  
182 188
colonet:
183 189
	g++ -Wall -Wshadow -Wextra *.c -g -I. -c
184 190
	ar rcs $(COLONET_TARGET).a $(OBJ)
trunk/code/projects/libwireless/lib/sensor_matrix.c
55 55
	for (i = 0; i < MAXIMUM_XBEE_ID; i++)
56 56
	{
57 57
		m.joined[i] = 0;
58
#ifndef BAYBOARD
58 59
		for (j = 0; j < MAXIMUM_XBEE_ID; j++)
59 60
			m.matrix[i][j] = READING_UNKNOWN;
61
#endif
60 62
	}
61 63
}
62 64

  
......
69 71
 */
70 72
void sensor_matrix_set_reading(int observer, int robot, int reading)
71 73
{
74
#ifndef BAYBOARD
72 75
	if (robot >= MAXIMUM_XBEE_ID || observer >= MAXIMUM_XBEE_ID)
73 76
	{
74 77
		WL_DEBUG_PRINT("ID too large.");
......
76 79
	}
77 80

  
78 81
	m.matrix[observer][robot] = (unsigned char)reading;
82
#endif
79 83
}
80 84

  
81 85
/**
......
88 92
 **/
89 93
int sensor_matrix_get_reading(int observer, int robot)
90 94
{
95
#ifndef BAYBOARD
91 96
	if (observer >= MAXIMUM_XBEE_ID || robot >= MAXIMUM_XBEE_ID)
92 97
		return -1;
93 98

  
94 99
	return (int)m.matrix[observer][robot];
100
#else
101
	return -1;
102
#endif
95 103
}
96 104

  
97 105
/**
trunk/code/projects/libwireless/lib/wireless.c
40 40
#include "wl_defs.h"
41 41

  
42 42
#ifndef ROBOT
43
#include <sys/time.h>
44
#include <signal.h>
43
	#include <sys/time.h>
44
	#include <signal.h>
45 45
#else
46
#include <time.h>
47
#ifndef FIREFLY
48
#include <bom.h>
46
	#include <time.h>
47
	#include <bom.h>
49 48
#endif
50
#endif
51 49

  
52 50
/*Function Prototypes*/
53 51

  
......
117 115
#ifdef FIREFLY
118 116
	rtc_init(PRESCALE_DIV_256, 32, &timer_handler);
119 117
#else
118
	//TODO: FIX THIS
119
	#ifdef BAYBOARD
120
	rtc_init(10 * HALF_SECOND, &timer_handler);
121
	#else
120 122
	rtc_init(HALF_SECOND, &timer_handler);
123
	#endif
121 124
#endif
122 125
#else
123 126

  

Also available in: Unified diff