Revision 1456

branches/colonetmk2/code/projects/libwireless/lib/wl_token_ring.c (revision 1456)
35 35
#include <wl_token_ring.h>
36 36

  
37 37
#include <stdlib.h>
38
#include <stdio.h>
39 38

  
40 39
#include <wl_defs.h>
41 40
#include <wireless.h>
......
107 106
// the amount of time a robot has had its BOM on for
108 107
static int bom_on_count = 0;
109 108

  
110
#ifndef ROBOT
109
#if (!(defined ROBOT)) || (defined FIREFLY)
111 110
static void do_nothing(void) {}
112
static int get_nothing(void) {return -1;}
111
static SensorReading get_nothing(void) { SensorReading ret = { READING_UNKNOWN, READING_UNKNOWN }; return ret;}
112
#else
113
static SensorReading default_get_bom(void) { int dist, dir; bom_refresh(BOM_ALL); dir = bom_get_max10(&dist); SensorReading ret = { dir, dist}; return ret; }
113 114
#endif
114 115

  
115 116
#ifdef ROBOT
116 117
#ifndef FIREFLY
117 118
static void (*bom_on_function) (void) = bom_on;
118 119
static void (*bom_off_function) (void) = bom_off;
119
static int (*get_max_bom_function) (void) = get_max_bom;
120
static SensorReading (*get_max_bom_function) (void) = default_get_bom;
120 121
#else
121 122
static void (*bom_on_function) (void) = do_nothing;
122 123
static void (*bom_off_function) (void) = do_nothing;
123
static int (*get_max_bom_function) (void) = get_nothing;
124
static SensorReading (*get_max_bom_function) (void) = get_nothing;
124 125
#endif
125 126
#else
126 127
static void (*bom_on_function) (void) = do_nothing;
127 128
static void (*bom_off_function) (void) = do_nothing;
128
static int (*get_max_bom_function) (void) = get_nothing;
129
static SensorReading (*get_max_bom_function) (void) = get_nothing;
129 130
#endif
130 131

  
131 132
static PacketGroupHandler wl_token_ring_handler =
......
211 212
 * measurement of the maximum BOM reading is needed.
212 213
 **/
213 214
void wl_token_ring_set_bom_functions(void (*on_function) (void),
214
	void (*off_function) (void), int (*max_bom_function) (void))
215
	void (*off_function) (void), SensorReading (*max_bom_function) (void))
215 216
{
216 217
	bom_on_function = on_function;
217 218
	bom_off_function = off_function;
......
344 345
 * @return a BOM reading from robot source to robot dest,
345 346
 * in the range 0-15, or -1 if it is unknown
346 347
 **/
347
int wl_token_get_sensor_reading(int source, int dest)
348
SensorReading * wl_token_get_sensor_reading(int source, int dest)
348 349
{
349 350
	if (wl_token_is_robot_in_ring(dest) &&
350 351
			(source == wl_get_xbee_id() || wl_token_is_robot_in_ring(source))) {
351 352
		return sensor_matrix_get_reading(source, dest);
352 353
	}
353 354

  
354
	return -1;
355
	return NULL;
355 356
}
356 357

  
357 358
/**
......
364 365
 **/
365 366
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
366 367
// it reduces code size or not should be done to be sure.
367
int wl_token_get_my_sensor_reading(int dest)
368
SensorReading * wl_token_get_my_sensor_reading(int dest)
368 369
{
369 370
	return wl_token_get_sensor_reading(wl_get_xbee_id(), dest);
370 371
}
......
530 531
{
531 532
	int i, j;
532 533
	char nextRobot;
534
	SensorReading r;
533 535

  
534 536
	bom_on_count = -1;
535 537
	deathDelay = -1;
......
549 551
		}
550 552

  
551 553
		//set the sensor information we receive
552
		if (j < sensorDataLength / 2 && sensorData[2 * j] == i)
554
		if (j < sensorDataLength / 2 && sensorData[3 * j] == i)
553 555
		{
554 556
			//the robot we were going to accept has already been accepted
555 557
			if (accepted == i)
......
557 559
				accepted = -1;
558 560
				WL_DEBUG_PRINT("Someone accepted the robot we did.\r\n");
559 561
			}
560
			sensor_matrix_set_reading(source, i,
561
						sensorData[2 * j + 1]);
562
			r.dir = sensorData[3 * j + 1];
563
			r.dist = sensorData[3 * j + 2];
564
			sensor_matrix_set_reading(source, i, r);
562 565
			if (!sensor_matrix_get_in_ring(i))
563 566
			{
564 567
				WL_DEBUG_PRINT("Robot ");
......
669 672
{
670 673
	char nextRobot = 0xFF;
671 674
	int i = wl_get_xbee_id() + 1;
672
	char buf[2 * sensor_matrix_get_size()];
675
	char buf[3 * sensor_matrix_get_size()];
673 676
	if (accepted == -1)
674 677
	{
675 678
		while (1)
......
708 711
	for (i = 0; i < sensor_matrix_get_size(); i++) {
709 712
		if (sensor_matrix_get_in_ring(i) && i != wl_get_xbee_id())
710 713
		{
711
			buf[2*j] = i;
712
			buf[2*j + 1] = sensor_matrix_get_reading(wl_get_xbee_id(), i);
714
			SensorReading *r = sensor_matrix_get_reading(wl_get_xbee_id(), i);
715
			buf[3*j] = i;
716
			buf[3*j + 1] = r->dir;
717
			buf[3*j + 2] = r->dist;
713 718
			j++;
714 719
		}
715 720
	}
716 721

  
717
	int packetSize = 2 * j * sizeof(char);
722
	int packetSize = 3 * j * sizeof(char);
718 723
	WL_DEBUG_PRINT("Passing the token to robot ");
719 724
	WL_DEBUG_PRINT_INT(nextRobot);
720 725
	WL_DEBUG_PRINT(".\r\n");
......
738 743
 **/
739 744
static void wl_token_bom_on_receive(int source)
740 745
{
741
	int max, dist;
746
	SensorReading r;
742 747

  
743 748
	WL_DEBUG_PRINT("Robot ");
744 749
	WL_DEBUG_PRINT_INT(source);
......
746 751

  
747 752
	bom_on_count = 0;
748 753

  
749
	max = get_max_bom_function();
754
	r = get_max_bom_function();
750 755
	sensor_matrix_set_reading(wl_get_xbee_id(),
751
		source, max);
756
		source, r);
752 757

  
753 758
	WL_DEBUG_PRINT("Max: ");
754
	WL_DEBUG_PRINT_INT(max);
755
	WL_DEBUG_PRINT("\tVar: ");
756
	WL_DEBUG_PRINT_INT(dist);
759
	WL_DEBUG_PRINT_INT(r.dir);
760
	WL_DEBUG_PRINT("\tDist: ");
761
	WL_DEBUG_PRINT_INT(r.dist);
757 762
	WL_DEBUG_PRINT("\n\n");
758 763
}
759 764

  
branches/colonetmk2/code/projects/libwireless/lib/sensor_matrix.h (revision 1456)
49 49
#define MAXIMUM_XBEE_ID		0x10
50 50
#define READING_UNKNOWN		0xFF
51 51

  
52
typedef struct
53
{
54
	/* direction of max reading */
55
	unsigned char dir;
56
	/* estimated distance */
57
	unsigned char dist;
58
} SensorReading;
59

  
52 60
/**
53 61
 * @struct SensorMatrix
54 62
 *
......
75 83
	 * The matrix. Each row represents the readings of one
76 84
	 * robot.
77 85
	 **/
78
	unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
86
	SensorReading matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
79 87
#endif
80 88
} SensorMatrix;
81 89

  
82 90
/**@brief Create a sensor matrix **/
83 91
void sensor_matrix_create(void);
84 92
/**@brief Set a reading in a sensor matrix **/
85
void sensor_matrix_set_reading(int observer, int robot, int reading);
93
void sensor_matrix_set_reading(int observer, int robot, SensorReading reading);
86 94
/**@brief Get a reading in a sensor matrix **/
87
int sensor_matrix_get_reading(int observer, int robot);
95
SensorReading * sensor_matrix_get_reading(int observer, int robot);
88 96
/**@brief Set whether the robot is in the token ring **/
89 97
void sensor_matrix_set_in_ring(int robot, int in);
90 98
/**@brief Get whether the robot is in the sensor ring **/
branches/colonetmk2/code/projects/libwireless/lib/wl_basic.c (revision 1456)
7 7
 * @author Christopher Mar, Colony Project, CMU Robotics Club
8 8
 **/
9 9

  
10
#include <wireless.h>
11 10
#include "wl_basic.h"
12 11

  
13 12
/**
branches/colonetmk2/code/projects/libwireless/lib/xbee.c (revision 1456)
42 42
#include <pthread.h>
43 43
#include <errno.h>
44 44
#include <termios.h>
45
#include <stdio.h>
46
#include <stdlib.h>
45 47

  
46 48
#else
47 49

  
......
51 53

  
52 54
#endif
53 55

  
54
#include <stdio.h>
55
#include <stdlib.h>
56 56
#include <string.h>
57 57

  
58 58
#define XBEE_FRAME_START 0x7E
branches/colonetmk2/code/projects/libwireless/lib/wl_token_ring.h (revision 1456)
35 35
#ifndef WL_TOKEN_RING_H
36 36
#define WL_TOKEN_RING_H
37 37

  
38
#include "sensor_matrix.h"
39

  
38 40
/**
39 41
 * @defgroup tokenring Token Ring
40 42
 * @brief Wireless library token ring implementation
......
52 54
void wl_token_ring_unregister(void);
53 55
/**@brief Set the functions called to turn the bom on and off.**/
54 56
void wl_token_ring_set_bom_functions(void (*on_function) (void), void (*off_function) (void),
55
  int (*max_bom_function) (void));
57
  SensorReading (*max_bom_function) (void));
56 58

  
57 59
/**@brief Join the token ring **/
58 60
int wl_token_ring_join(void);
......
72 74
int wl_token_iterator_next(void);
73 75

  
74 76
/**@brief Return the latest BOM reading between two robots **/
75
int wl_token_get_sensor_reading(int source, int dest);
77
SensorReading * wl_token_get_sensor_reading(int source, int dest);
76 78
/**@brief Return the latest BOM reading between us and another robot **/
77
int wl_token_get_my_sensor_reading(int dest);
79
SensorReading * wl_token_get_my_sensor_reading(int dest);
78 80
/**@brief Return the number of robots in the sensor matrix.*/
79 81
int wl_token_get_num_robots(void);
80 82
/**@brief Return the number of non-null elements in the sensor matrix*/
branches/colonetmk2/code/projects/libwireless/lib/wl_error_group.c (revision 1456)
33 33
 **/
34 34

  
35 35
#include "wl_error_group.h"
36
#include "wireless.h"
37
#include "wl_defs.h"
36 38

  
37
#include <wireless.h>
38
#include <wl_defs.h>
39
#include <stdio.h>
40 39
#include <string.h>
41 40

  
42 41

  
42

  
43 43
void wl_error_response_receive(int frame, int received);
44 44
void wl_error_handle_receive(char type, int source, unsigned char* packet,
45 45
							int length);
branches/colonetmk2/code/projects/libwireless/lib/sensor_matrix.c (revision 1456)
32 32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33 33
 **/
34 34

  
35
#include <stdlib.h>
36
#include <stdio.h>
37
#include <wl_defs.h>
38

  
35
#include "wl_defs.h"
39 36
#include "sensor_matrix.h"
40 37

  
41 38
// the global sensor matrix
......
57 54
		m.joined[i] = 0;
58 55
#ifndef BAYBOARD
59 56
		for (j = 0; j < MAXIMUM_XBEE_ID; j++)
60
			m.matrix[i][j] = READING_UNKNOWN;
57
			m.matrix[i][j].dir = READING_UNKNOWN;
61 58
#endif
62 59
	}
63 60
}
......
69 66
 * @param robot the id of the robot who the reading is for
70 67
 * @param reading the BOM reading from observer to robot
71 68
 */
72
void sensor_matrix_set_reading(int observer, int robot, int reading)
69
void sensor_matrix_set_reading(int observer, int robot, SensorReading reading)
73 70
{
74 71
#ifndef BAYBOARD
75 72
	if (robot >= MAXIMUM_XBEE_ID || observer >= MAXIMUM_XBEE_ID)
......
78 75
		return;
79 76
	}
80 77

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

  
......
90 87
 *
91 88
 * @return the observer's BOM reading for robot
92 89
 **/
93
int sensor_matrix_get_reading(int observer, int robot)
90
SensorReading * sensor_matrix_get_reading(int observer, int robot)
94 91
{
95 92
#ifndef BAYBOARD
96 93
	if (observer >= MAXIMUM_XBEE_ID || robot >= MAXIMUM_XBEE_ID)
97
		return -1;
94
		return NULL;
98 95

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

  
branches/colonetmk2/code/projects/libwireless/lib/wireless.c (revision 1456)
34 34

  
35 35
#include "wireless.h"
36 36
#include "xbee.h"
37
#include <stdlib.h>
37

  
38
#include <stddef.h>
39

  
40
#ifdef WL_DEBUG
38 41
#include <stdio.h>
42
#endif
39 43

  
40 44
#include "wl_defs.h"
41 45

  
......
461 465
	else
462 466
	{
463 467
		WL_DEBUG_PRINT("Unexpected packet received from XBee.\r\n");
468
		#ifdef WL_DEBUG
469
		#ifndef ROBOT
464 470
		printf("0x%2X\n", wl_buf[0]);
465 471
		printf("%c%c%d\n", wl_buf[2], wl_buf[3], wl_buf[4]);
472
		#endif
473
		#endif
466 474
	}
467 475
}
468 476

  
branches/colonetmk2/code/projects/swarm/BOMPosRender/.classpath (revision 1456)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
branches/colonetmk2/code/projects/swarm/BOMPosRender/.project (revision 1456)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>BOMPosRender</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
branches/colonetmk2/code/projects/swarm/BOMPosRender/src/BOMPosServer.java (revision 1456)
1
import java.awt.*;
2
import java.io.*;
3
import java.net.*;
4
import java.util.Arrays;
5
import java.util.Scanner;
6
import java.util.Vector;
7

  
8
import javax.swing.JApplet;
9

  
10
public class BOMPosServer extends JApplet implements Runnable {
11
	private static final long serialVersionUID = 0L;
12
	
13
	private boolean running;
14
	
15
	class Client implements Runnable {
16
		final Socket socket;
17
		Scanner stream;
18
		
19
		public Client(Socket s) throws IOException
20
		{
21
			this.socket = s;
22
			this.stream = new Scanner(this.socket.getInputStream());
23
			new Thread(this).run();
24
		}
25
		
26
		public void close()
27
		{
28
			try {
29
				socket.close();
30
			} catch (IOException e) {
31
				e.printStackTrace();
32
			}
33
		}
34
		
35
		public void run()
36
		{
37
			System.out.println("Client connected");
38
			try {
39
				SensorReading[] readings = new SensorReading[16];
40
				int robot = -1;
41
				int source, dest = -1;
42
				while(this.socket.isConnected())
43
				{
44
					while(!"st".equals(stream.next()))
45
						System.out.println("bad token");
46
					source = stream.nextInt();
47
					int destp = stream.nextInt();
48
					if (dest >= destp || robot != source)
49
					{
50
						if (robot > 0)
51
						{
52
							updateMap(robot, readings);
53
							BOMPosServer.this.repaint();
54
						}
55
						Arrays.fill(readings, null);
56
						robot = source;
57
					}
58
					dest = destp;
59
					float dir = stream.nextInt()*2.0f*(float)Math.PI/160.0f;
60
					int dist = stream.nextInt();
61
					//System.out.print(source + " " + dest + " " + dir + " " + dist + "\n");
62
					if (dir > Math.PI*2)
63
						readings[dest] = null;
64
					else
65
						readings[dest] = new SensorReading(dir, dist);
66
					BOMPosServer.this.readings[source][dest] = readings[dest];
67
				}
68
			} catch (Exception e) {
69
				e.printStackTrace();
70
				try {
71
					this.socket.close();
72
				} catch (IOException ex) {}
73
			}
74
			System.out.println("Client exit");
75
		}
76
	}
77
	
78
	ServerSocket server;
79
	Vector<Client> clients;
80
	
81
	@Override
82
	public void run() {
83
		try {
84
			/*while(!server.isClosed())
85
			{
86
				Socket s = server.accept();
87
				clients.add(new Client(s));
88
			}*/
89
			while (running)
90
			{
91
				new Client(new Socket("localhost", 2000)).run();
92
			}
93
		} catch (IOException e) {
94
			e.printStackTrace();
95
		}
96
		/*positions[0].th = 0;
97
		float a = 0.0f;
98
		while(running)
99
		{
100
			repaint();
101
			readings[0][1] = new SensorReading(a, 2);
102
			a += Math.PI/20;
103
			try {
104
				Thread.sleep(50);
105
			} catch (InterruptedException e) {}
106
		}*/
107
	}
108
	
109
	@Override
110
	public void init() {
111
		setSize(400, 400);
112
		
113
		clients = new Vector<Client>();
114
		
115
		/*try {
116
			server = new ServerSocket(2000);
117
		} catch (IOException e) {
118
			e.printStackTrace();
119
		}*/
120
		
121
		running = true;
122
		
123
		new Thread(this).start();
124
	}
125
	
126
	@Override
127
	public void stop() {
128
		for(Client c : clients) {
129
			c.close();
130
		}
131
	}
132
	
133
	@Override
134
	public void paint(Graphics g)
135
	{
136
		g.clearRect(0, 0, getWidth(), getHeight());
137
		
138
		for(int i=0; i<16; i++)
139
		{
140
			if (Float.isNaN(positions[i].th)) continue;
141
			//System.out.println(i + ": (" + positions[i].x + "," + positions[i].y + ") " + positions[i].th);
142
			drawBot(g, i);
143
		}
144
	}
145

  
146
	private void drawBot(Graphics g, int i) {
147
		int x = 3*positions[i].x + getWidth()/2;
148
		int y = -3*positions[i].y + getHeight()/2;
149
		g.drawOval(x-8, y-8, 16, 16);
150
		g.drawString(String.valueOf(i), x-4, y+4);
151
		for(int j=0; j<16; j++)
152
		{
153
			if (readings[i][j]==null) continue;
154
			float ang = readings[i][j].dir + positions[i].th;
155
			g.drawString(String.valueOf(j), x+(int)(12*Math.cos(ang)-4), y-(int)(14*Math.sin(ang)-5));
156
		}
157
		if (!Float.isNaN(positions[i].th))
158
		{
159
			g.drawLine(x, y, (int)(x + 8*Math.cos(positions[i].th)), (int)(y - 8*Math.sin(positions[i].th)));
160
		}
161
	}
162
	
163
	public int get_num_robots()
164
	{
165
		return 3;
166
	}
167
	
168
	static class SensorReading
169
	{
170
		public float dir;
171
		public int dist;
172
		
173
		public SensorReading(float dir, int dist)
174
		{
175
			this.dir = dir;
176
			this.dist = dist;
177
		}
178
	}
179
	
180
	SensorReading[][] readings = new SensorReading[16][16];
181
	
182
	static class R2
183
	{
184
		public int x;
185
		public int y;
186
		public float th;
187
		
188
		public R2(int x, int y, float th)
189
		{
190
			this.x = x;
191
			this.y = y;
192
			this.th = th;
193
		}
194
	}
195
	
196
	static R2[] positions;
197
	static {
198
		positions = new R2[16];
199
		for(int i=0; i<16; i++)
200
			positions[i] = new R2(0, 0, Float.NaN);
201
	}
202
	
203
	public void updateMap(int robot, SensorReading[] readings)
204
	{
205
		float a = 0.0f;
206
		int count = 0;
207
		for(int target=0; target<16; target++)
208
		{
209
			if (readings[target] == null) continue;
210
			
211
			a += (Math.atan2(positions[target].y - positions[robot].y, positions[target].x - positions[robot].x) - readings[target].dir + 4*Math.PI) % (2*Math.PI);
212
			count++;
213
		}
214
		if (count > 0)
215
		{
216
			a /= count;
217
		}
218
		positions[robot].th = /*robot==1 ? 0 :*/ a;
219
		
220
		for(int target=0; target<16; target++)
221
		{
222
			if (readings[target] == null) continue;
223
			if (readings[target].dist < 2) continue;
224
			if (readings[target].dist > 200) continue;
225
			/*System.out.println(target + " " + readings[target].dist + " " + readings[target].dir + " (" +
226
								readings[target].dist*Math.cos(readings[target].dir) + "," + readings[target].dist*Math.sin(readings[target].dir) + ")");*/
227
			int scale = 2 * get_num_robots(); // readings[target].dist/5;
228
			positions[target].x = ( (scale-1)*positions[target].x + (int)(readings[target].dist*Math.cos(positions[robot].th + readings[target].dir)) )/scale;
229
			positions[target].y = ( (scale-1)*positions[target].y + (int)(readings[target].dist*Math.sin(positions[robot].th + readings[target].dir)) )/scale;
230
		}
231
		
232
		System.out.println(robot + ": (" + positions[robot].x + "," + positions[robot].y + ") " + positions[robot].th);
233
	}
234
}
branches/colonetmk2/code/projects/swarm/BOMPosRender/bin/java.policy.applet (revision 1456)
1
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
2
/* DO NOT EDIT */
3

  
4
grant {
5
  permission java.security.AllPermission;
6
};
7

  
branches/colonetmk2/code/projects/swarm/BOMPosRender/bom algo 1 save.txt (revision 1456)
1
		for(int source=0; source<16; source++)
2
		{
3
			for(int dest=0; dest<source; dest++)
4
			{
5
				if (sensors[source][dest]==null)
6
				{
7
					if (sensors[dest][source]!=null)
8
					{
9
						sensors[source][dest] = new SensorReading(Float.NaN, sensors[dest][source].dist); 
10
					}
11
				}
12
				else if (sensors[dest][source]==null)
13
				{
14
					sensors[dest][source] = new SensorReading(Float.NaN, sensors[source][dest].dist);
15
				}
16
				else
17
				{
18
					int avgdist = (sensors[source][dest].dist + sensors[dest][source].dist)/2;
19
					sensors[source][dest].dist = avgdist;
20
					sensors[dest][source].dist = avgdist;
21
				}
22
			}
23
		}
24
		
25
		boolean firstbot = true;
26
		
27
		for(int i=0; i<16; i++)
28
		{
29
			for(int j=0; j<i; j++)
30
			{
31
				if (sensors[i][j]==null) continue;
32
				if (positions[j]!=null) continue;
33
				if (firstbot)
34
				{
35
					firstbot = false;
36
					positions[i] = new R2(0, 0, 0);
37
				}
38
				if (positions[i]==null) continue;
39
				if (Float.isNaN(positions[i].th)) continue;
40
				positions[j] = new R2((int)  (positions[i].x + sensors[i][j].dist*Math.cos(positions[i].th + sensors[i][j].dir)),
41
									 (int)  (positions[i].y + sensors[i][j].dist*Math.sin(positions[i].th + sensors[i][j].dir)),
42
									 (float)(/*robostat[i].th + sensors[i][j].dir +*/ sensors[j][i].dir /*- Math.PI*/));
43
			}
44
		}
45
		
46
		/*for(int i=0; i<16; i++)
47
		{
48
			for(int j=0; j<16; j++)
49
			{
50
				for(int k=0; k<16; k++)
51
				{
52
					if (sensors[i][j]!=null &&
53
						sensors[i][k]!=null &&
54
						sensors[j][k]!=null)
55
					{
56
						
57
					}
58
				}
59
			}
60
		}*/
branches/colonetmk2/code/projects/swarm/test.cpp (revision 1456)
1
#include <colonet_wireless.h>
2
#include <wireless.h>
3
#include <stdio.h>
4
#include <string.h>
5
#include <stdlib.h>
6
#include <signal.h>
7
#include <unistd.h>
8

  
9
#include <pthread.h>
10

  
11
#define SWARM_PACKET_GROUP_ID 0x8
12

  
13
static PacketGroupHandler colonet_pgh;
14
static void colonet_handle_receive(char type, int wl_source, unsigned char* packet, int length);
15

  
16
void cleanup(int a)
17
{
18
    a = a;
19

  
20
    wl_terminate();
21
    printf("todo - close wl port\n");
22

  
23
    exit(0);
24
}
25

  
26
int main(int argc, char* argv[])
27
{
28
    struct sigaction act;
29
    memset(&act, 0, sizeof(struct sigaction));
30
    act.sa_handler = cleanup;
31

  
32
    if (argc < 2) return -1;
33

  
34
    //register a signal handler to be called when we get a SIGINT signal (killing the server by cntrl+c would generate this)
35
    sigaction(SIGINT, &act, NULL);
36

  
37
    char *wireless_port = argv[1];
38

  
39
    //initialize the wireless library giving it the port and the log file name
40
    if (colonet_wl_init(wireless_port) != 0) {
41
        printf("colonet_wl_init failed.\n");
42
        return -1;
43
    }
44

  
45
    colonet_pgh.groupCode = SWARM_PACKET_GROUP_ID;
46
    colonet_pgh.timeout_handler = NULL;
47
    colonet_pgh.handle_response = NULL;
48
    colonet_pgh.handle_receive = colonet_handle_receive;
49
    colonet_pgh.unregister = NULL;
50
    wl_register_packet_group(&colonet_pgh);
51

  
52
    //call the function that will start the thread that will listen for wireless messages
53
    if (colonet_wl_run_listener_thread()) {
54
        printf("colonet_wl_run_listener_thread failed.\n");
55
        return -1;
56
    }
57

  
58
    unsigned char i, j;
59
    int numRobots = 1;
60
    //int* robots = (int *)malloc(0);
61
    int robots[] = {13};
62

  
63
    for(i=0; ; i++)
64
    {
65
        if (i==0)
66
        {
67
            //numRobots = colonet_get_num_robots();
68
            //robots = (int *)realloc(robots, sizeof(int) * numRobots);
69
            //colonet_get_xbee_ids(robots);
70
        }
71

  
72
        /*for (j=0; j < numRobots; j++)
73
        {
74
            usleep(1000);
75
            
76
            printf("\rSending %d to %d    ", i, robots[j]);
77

  
78
            char packet[] = { i, i, i, i };
79
            wl_send_robot_to_robot_packet(SWARM_PACKET_GROUP_ID, 0, packet, sizeof(char) * 4, robots[j], 0);
80
        }*/
81

  
82
        pthread_yield();
83
    }
84

  
85
    //colonet_wl_join();
86
    printf("Exiting normally\n");
87

  
88
    return 0;
89
}
90

  
91
unsigned char count[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
92

  
93
static void colonet_handle_receive(char type, int wl_source, unsigned char* packet, int length)
94
{
95
    type = type;
96
    
97
    if (length != 17)
98
    {
99
        printf("Bad packet length from %d\n", wl_source);
100
        return;
101
    }
102

  
103
    for (int i = 0; i < length; i++)
104
    {
105
        /*if (packet[i] != i)
106
        {
107
            printf("Corrupted packet from %d\n", wl_source);
108
            break;
109
        }*/
110
        printf("%d ", packet[i]);
111
    }
112
    printf("\n");
113

  
114
    if (packet[16]!=++count[wl_source])
115
        printf("Bad packet number from %d (%d, should be %d)\n", wl_source, packet[16], count[wl_source]);
116

  
117
    if (packet[16] == 0)
118
    {
119
        printf("Packet 0 received from %d\n", wl_source);
120
    }
121

  
122
    count[wl_source] = packet[16];
123

  
124
    fflush(stdout);
125
}
branches/colonetmk2/code/projects/swarm/colonet_wireless.cpp (revision 1456)
1
/** @file colonet_wireless.c
2
 *
3
 * @brief Implementation of server-side colonet wireless library
4
 *
5
 * @author Eugene Marinelli
6
 */
7

  
8
/********************************* Includes **********************************/
9
#include <stdio.h>
10
#include <string.h>
11
#include <stdlib.h>
12
#include <unistd.h>
13
#include <pthread.h>
14
#include <signal.h>
15

  
16
#include <wireless.h> // Colonet wireless library.
17
#include <wl_token_ring.h>
18

  
19
#include <colonet_wireless.h>
20

  
21
/******************************* Definitions *********************************/
22

  
23
//Enable debug printouts
24
//#define DEBUG 1
25

  
26
#ifdef DEBUG
27
#define dbg_printf(...) printf(__VA_ARGS__)
28
#define dbg_fprintf(...) fprintf(__VA_ARGS__)
29
#else
30
#define dbg_printf(...)
31
#define dbg_fprintf(...)
32
#endif
33

  
34
static pthread_t listener_thread;
35
static char wl_port[40];
36

  
37
/************************* Internal prototypes *******************************/
38
static void* listen(void* args);
39

  
40
/**************************** Public functions *******************************/
41
/**
42
 * @brief Initializes the wireless library
43
 *
44
 * @param wl_port_ The port to listen for wireless messages on
45
 *
46
 * @return 0 on success, negative error code on failure
47
 */
48
int colonet_wl_init(char* wl_port_) {
49
  strncpy(wl_port, wl_port_, 40);
50

  
51
  wl_set_com_port(wl_port);
52

  
53
  fprintf(stderr, "Calling wl_init(%s)...\n", wl_port);
54
  if (wl_init() != 0) {
55
    fprintf(stderr, "wl_init failed.\n");
56
    return -1;
57
  }
58

  
59
  fprintf(stderr, "Setting channel\n");
60
  wl_set_channel(0xF);
61
  wl_set_pan(0x3332);
62

  
63
  /*wl_token_ring_register();
64

  
65
  fprintf(stderr, "Joining token ring...\n");
66
  if (wl_token_ring_join() != 0) {
67
    fprintf(stderr, "Failed to join token ring.\n");
68
    return -1;
69
  }
70
  fprintf(stderr, "Joined token ring.\n");*/
71

  
72
  return 0;
73
}
74

  
75
/**
76
 * @brief This function will kill the thread that is listening for wireless messages
77
 */
78
void colonet_wl_kill_listener_thread() {
79
  pthread_kill(listener_thread, 9);
80
}
81

  
82
void colonet_wl_join() {
83
  pthread_join(listener_thread, NULL);
84
}
85

  
86
/**
87
 * @brief This function spawns a thread to listen for wireless messages
88
 *
89
 * @return 0 on success, negative error code on failure
90
 */
91
int colonet_wl_run_listener_thread() {
92
  dbg_printf("Spawning listener thread...\n");
93

  
94
  if (pthread_create(&listener_thread, NULL, listen, NULL)) {
95
    perror("pthread_create");
96
    return -1;
97
  }
98

  
99
  return 0;
100
}
101

  
102
/**
103
 * @brief Used to get the number of robots in the token ring
104
 *
105
 * @return The result of wl_token_get_num_robots()
106
 */
107
int colonet_get_num_robots(void) {
108
  return wl_token_get_num_robots();
109
}
110

  
111
/**
112
 * @brief Gets a list of the xbee ids of the ones in the token ring
113
 *
114
 * @param numrobots A pointer to the variable where you want the number of robots to be stored
115
 *
116
 * @return A dynamically allocated piece of memory that contains the list of xbee ids.
117
 *   The function calling this function must free this memory when done with it.
118
 */
119
void colonet_get_xbee_ids(int ids[]) {
120
  wl_token_iterator_begin();
121

  
122
  int i = 0;
123
  while (wl_token_iterator_has_next()) {
124
    ids[i++] = wl_token_iterator_next();
125
  }
126
}
127

  
128
/**
129
 * @brief Gets the sensor matrix from the wireless library
130
 *
131
 * @param numrobots A pointer to the variable where you want the number of robots to be stored
132
 * @param ids_ A pointer to a pointer that you want to point to the list of xbee ids.  This memory is dynamically
133
 * allocated and should be freed by the calling process when it is done with it
134
 *
135
 * @return The 2d matrix reprsenting the sensor matrix.  This memory is dynamically allocated and should be freed by
136
 * the calling process when it is done with it
137
 */
138
void colonet_get_sensor_matrix(int* ids, SensorReading*** m) {
139
  int num_robots = colonet_get_num_robots();
140
  colonet_get_xbee_ids(ids);
141

  
142
  for (int i = 0; i < num_robots; i++) {
143
    for (int j = 0; j < num_robots; j++) {
144
      m[i][j] = wl_token_get_sensor_reading(ids[i], ids[j]);
145
    }
146
  }
147
}
148

  
149
/** @brief Analogous to the "SIGNAL" or "ISR" function on the robots.
150
 * Listens for bytes on the wireless port and constructs packets based on them.
151
 * Not part of the ColonetWireless class since a function pointer must be
152
 * passed in starting the thread that runs it (tricky or impossible if it's
153
 * a class function).
154
 *
155
 * @param args Pointer to arguments.  Can be safely casted to ListenerArgs type
156
 * @return NULL
157
 */
158
static void* listen(void* args) {
159
  args = args; //TODO: These are just here to get rid of compiler warnings.
160

  
161
  fprintf(stderr, "Called listen.\n");
162

  
163
  while (1) {
164
    wl_do();
165

  
166
    //this sleep is here so the thread this runs in doesn't hog the cpu
167
    pthread_yield();
168
  }
169

  
170
  fprintf(stderr, "Listen is returning.\n");
171

  
172
  wl_terminate();
173
  return NULL;
174
}
175

  
0 176

  
branches/colonetmk2/code/projects/swarm/main.c (revision 1456)
1
#include <wireless.h>
2
#include <wl_token_ring.h>
3

  
4
#include <stdio.h>
5
#include <string.h>
6
#include <unistd.h>
7

  
8
#include <sys/socket.h>
9
#include <arpa/inet.h>
10

  
11
#include <sys/ioctl.h>
12

  
13
typedef struct {
14
    int x;
15
    int y;
16
    char c;
17
} arrow_t;
18

  
19
arrow_t arrows[16] = {
20
                    { 8, 2, '-'  }, // 0
21
                    { 8, 1, '/'  }, // 1
22
                    { 7, 0, '/'  }, // 2
23
                    { 5, 0, '/'  }, // 3
24
                    { 4, 0, '|'  }, // 4
25
                    { 3, 0, '\\' }, // 5
26
                    { 1, 0, '\\' }, // 6
27
                    { 0, 1, '\\' }, // 7
28
                    { 0, 2, '-'  }, // 8
29
                    { 0, 3, '/'  }, // 9
30
                    { 1, 4, '/'  }, // 10
31
                    { 3, 4, '/' }, // 11
32
                    { 4, 4, '|'  }, // 12
33
                    { 5, 4, '\\'  }, // 13
34
                    { 7, 4, '\\'  }, // 14
35
                    { 8, 3, '\\'  }, // 15
36
                  };
37
                    
38

  
39
char mobot[5][10] = {"   ___   ",
40
                     "  /   \\  ",
41
                     " |     | ",
42
                     "  \\___/  ",
43
                     "         "};
44
char mobot_m[5][10];
45

  
46
int main(int argc, char *argv[])
47
{
48
    int robots[16];
49
    SensorReading * sensors[16][16];
50
    int i,j;
51
	char sbuf[32];
52

  
53
	int sockfd, new_fd;  // listen on sock_fd, new connection on new_fd
54
	struct sockaddr_in serv_addr, their_addr;
55
	int rv;
56

  
57
    /*for(i=0; i<16; i++)
58
    {
59
        memcpy(mobot_m, mobot, 50*sizeof(char));
60
        arrow_t *arrow = &arrows[i];
61
        mobot_m[arrow->y][arrow->x] = arrow->c;
62
        printf("%d\n", i);
63
        for(j=0; j<5; j++)
64
        {
65
            printf("%s\n", mobot_m[j]);
66
        }
67
    }
68
    return 0;*/
69

  
70
    wl_set_com_port(argv[1]);
71

  
72
    if (wl_init() != 0) {
73
      fprintf(stderr, "wl_init failed.\n");
74
      return -1;
75
    }
76

  
77
    wl_set_channel(0xF);
78

  
79
    printf("wireless on\r\n");
80

  
81
    wl_token_ring_register();
82
    wl_token_ring_join();
83

  
84
    printf("wireless initialized\r\n");
85

  
86
	memset(&serv_addr, 0, sizeof serv_addr);
87
	serv_addr.sin_family = AF_INET;
88
	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
89
	serv_addr.sin_port = htons(2000);
90

  
91
	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
92
		perror("server: socket");
93
		return 1;
94
	}
95

  
96
	if ((rv = bind(sockfd, (struct sockaddr *)&serv_addr, sizeof serv_addr)) < 0)  {
97
		perror("bind");
98
		close(sockfd);
99
		return 2;
100
	}
101

  
102
	if (listen(sockfd, 0) == -1) {
103
		perror("listen");
104
		return 1;
105
	}
106

  
107
	printf("server: waiting for connections...\n");
108

  
109
	while(1) {  // main accept() loop
110
		socklen_t sin_size = sizeof their_addr;
111

  
112
		wl_do();
113

  
114
		new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
115
		if (new_fd == -1) {
116
			perror("accept");
117
			continue;
118
		}
119

  
120
		printf("server: got connection\n");
121

  
122
		while (1)
123
		{
124
		    int num_robots = 0;
125

  
126
		    wl_do();
127

  
128
		    wl_token_iterator_begin();
129
		    while(wl_token_iterator_has_next())
130
		    {
131
		        robots[num_robots++] = wl_token_iterator_next();
132
		    }
133
		    for(i=0; i < num_robots; i++)
134
		    {
135
		        if (robots[i]==wl_get_xbee_id()) continue;
136
		        memcpy(mobot_m, mobot, 50*sizeof(char));
137
		        for(j=0; j < num_robots; j++)
138
		        {
139
		            if (i==j) continue;
140
		            //if (robots[j]==wl_get_xbee_id()) continue;
141
		            sensors[robots[i]][robots[j]] = wl_token_get_sensor_reading(robots[i], robots[j]);
142
		            printf("%d -> %d:  %d @ %d\n", robots[i], robots[j], sensors[robots[i]][robots[j]]->dir, sensors[robots[i]][robots[j]]->dist);
143
		            //if (sensors[robots[i]][robots[j]]->dir>160) continue;
144
					sprintf(sbuf, "st %d %d %d %d\n", robots[i], robots[j], sensors[robots[i]][robots[j]]->dir, sensors[robots[i]][robots[j]]->dist);
145
					if (send(new_fd, sbuf, strlen(sbuf), MSG_NOSIGNAL) < 0)
146
					{
147
						fprintf(stderr, "Error sending data\n");
148
						goto close_sock;
149
					}
150
		            arrow_t *arrow = &arrows[sensors[robots[i]][robots[j]]->dir/10];
151
		            mobot_m[arrow->y][arrow->x] = arrow->c;
152
		        }
153
		        /*for(j=0; j<5; j++)
154
		        {
155
		            printf("%s\n", mobot_m[j]);
156
		        }
157
		        printf("\n");*/
158
		    }
159
		    printf("\n");
160

  
161
		    usleep(130000);
162
		}
163
close_sock:
164
		close(new_fd);
165

  
166
		break;
167
	}
168
}
0 169

  
branches/colonetmk2/code/projects/swarm/robot/main.map (revision 1456)
1
Archive member included because of file (symbol)
2

  
3
../../../../code/projects/libwireless/lib/libwireless.a(wireless.o)
4
                              main.o (wl_do)
5
../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o)
6
                              main.o (wl_token_ring_join)
7
../../../../code/projects/libwireless/lib/libwireless.a(xbee.o)
8
                              ../../../../code/projects/libwireless/lib/libwireless.a(wireless.o) (xbee_get_packet)
9
../../../../code/projects/libwireless/lib/libwireless.a(sensor_matrix.o)
10
                              ../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o) (sensor_matrix_create)
11
../../../../code/projects/libdragonfly/libdragonfly.a(bom.o)
12
                              ../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o) (bom_get_max10)
13
../../../../code/projects/libdragonfly/libdragonfly.a(dio.o)
14
                              ../../../../code/projects/libdragonfly/libdragonfly.a(bom.o) (digital_output)
15
../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o)
16
                              main.o (dragonfly_init)
17
../../../../code/projects/libdragonfly/libdragonfly.a(eeprom.o)
18
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (get_bom_type)
19
../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
20
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (encoders_init)
21
../../../../code/projects/libdragonfly/libdragonfly.a(lcd.o)
22
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (lcd_init)
23
../../../../code/projects/libdragonfly/libdragonfly.a(lights.o)
24
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (orb_init)
25
../../../../code/projects/libdragonfly/libdragonfly.a(motor.o)
26
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (motors_init)
27
../../../../code/projects/libdragonfly/libdragonfly.a(rangefinder.o)
28
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (range_init)
29
../../../../code/projects/libdragonfly/libdragonfly.a(serial.o)
30
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (usb_init)
31
../../../../code/projects/libdragonfly/libdragonfly.a(spi.o)
32
                              ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o) (spi_init)
33
../../../../code/projects/libdragonfly/libdragonfly.a(time.o)
34
                              ../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o) (delay_ms)
35
../../../../code/projects/libdragonfly/libdragonfly.a(analog.o)
36
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (analog_init)
37
../../../../code/projects/libdragonfly/libdragonfly.a(buzzer.o)
38
                              ../../../../code/projects/libdragonfly/libdragonfly.a(dragonfly_lib.o) (buzzer_init)
39
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divmodhi4.o)
40
                              ../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o) (__divmodhi4)
41
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divmodsi4.o)
42
                              ../../../../code/projects/libdragonfly/libdragonfly.a(buzzer.o) (__divmodsi4)
43
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_exit.o)
44
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/crtm128.o (exit)
45
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_clear_bss.o)
46
                              main.o (__do_clear_bss)
47
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_ashldi3.o)
48
                              ../../../../code/projects/libdragonfly/libdragonfly.a(bom.o) (__ashldi3)
49
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divdi3.o)
50
                              ../../../../code/projects/libdragonfly/libdragonfly.a(bom.o) (__divdi3)
51
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_moddi3.o)
52
                              ../../../../code/projects/libdragonfly/libdragonfly.a(bom.o) (__moddi3)
53
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_mulsi3.o)
54
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divdi3.o) (__mulsi3)
55
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_udivmodhi4.o)
56
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divmodhi4.o) (__udivmodhi4)
57
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_udivmodsi4.o)
58
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divmodsi4.o) (__udivmodsi4)
59
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_prologue.o)
60
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divdi3.o) (__prologue_saves__)
61
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_epilogue.o)
62
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divdi3.o) (__epilogue_restores__)
63
/usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_clz.o)
64
                              /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a(_divdi3.o) (__clz_tab)
65
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(rand.o)
66
                              ../../../../code/projects/libwireless/lib/libwireless.a(wl_token_ring.o) (rand)
67
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(memcpy_P.o)
68
                              ../../../../code/projects/libdragonfly/libdragonfly.a(serial.o) (memcpy_P)
69
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(printf.o)
70
                              ../../../../code/projects/libwireless/lib/libwireless.a(wireless.o) (printf)
71
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(vfprintf_std.o)
72
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(printf.o) (vfprintf)
73
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(strnlen_P.o)
74
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(vfprintf_std.o) (strnlen_P)
75
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(strnlen.o)
76
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(vfprintf_std.o) (strnlen)
77
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(fputc.o)
78
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(vfprintf_std.o) (fputc)
79
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(iob.o)
80
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(printf.o) (__iob)
81
/usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(ultoa_invert.o)
82
                              /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(vfprintf_std.o) (__ultoa_invert)
83

  
84
Allocating common symbols
85
Common symbol       size              file
86

  
87
pwm_buffer          0x27              ../../../../code/projects/libdragonfly/libdragonfly.a(lights.o)
88
orb_values          0x6               ../../../../code/projects/libdragonfly/libdragonfly.a(lights.o)
89
data_ready          0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
90
usb_fd              0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(serial.o)
91
right_data          0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
92
left_data_buf       0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
93
left_data_array     0x5c              ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
94
left_data_idx       0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
95
right_dx            0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
96
timecount           0x4               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
97
encoder_buf_index   0x1               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
98
right_data_array    0x5c              ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
99
left_dx             0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
100
right_data_idx      0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
101
right_data_buf      0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
102
xbee_fd             0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(serial.o)
103
arrival_buf         0x80              ../../../../code/projects/libwireless/lib/libwireless.a(xbee.o)
104
left_data           0x2               ../../../../code/projects/libdragonfly/libdragonfly.a(encoders.o)
105
an_val              0x21              ../../../../code/projects/libdragonfly/libdragonfly.a(analog.o)
106
m                   0x212             ../../../../code/projects/libwireless/lib/libwireless.a(sensor_matrix.o)
107
__iob               0x6               /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a(iob.o)
108

  
109
Memory Configuration
110

  
111
Name             Origin             Length             Attributes
112
text             0x0000000000000000 0x0000000000020000 xr
113
data             0x0000000000800060 0x000000000000ffa0 rw !x
114
eeprom           0x0000000000810000 0x0000000000010000 rw !x
115
fuse             0x0000000000820000 0x0000000000000400 rw !x
116
lock             0x0000000000830000 0x0000000000000400 rw !x
117
signature        0x0000000000840000 0x0000000000000400 rw !x
118
*default*        0x0000000000000000 0xffffffffffffffff
119

  
120
Linker script and memory map
121

  
122
Address of section .data set to 0x800100
123
LOAD /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/crtm128.o
124
LOAD main.o
125
LOAD /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libm.a
126
LOAD ../../../../code/projects/libwireless/lib/libwireless.a
127
LOAD ../../../../code/projects/libdragonfly/libdragonfly.a
128
LOAD /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a
129
LOAD /usr/lib/gcc/avr/4.3.2/../../../avr/lib/avr51/libc.a
130
LOAD /usr/lib/gcc/avr/4.3.2/avr51/libgcc.a
131

  
132
.hash
133
 *(.hash)
134

  
135
.dynsym
136
 *(.dynsym)
137

  
138
.dynstr
139
 *(.dynstr)
140

  
141
.gnu.version
142
 *(.gnu.version)
143

  
144
.gnu.version_d
145
 *(.gnu.version_d)
146

  
147
.gnu.version_r
148
 *(.gnu.version_r)
149

  
150
.rel.init
151
 *(.rel.init)
152

  
153
.rela.init
154
 *(.rela.init)
155

  
156
.rel.text
157
 *(.rel.text)
158
 *(.rel.text.*)
159
 *(.rel.gnu.linkonce.t*)
160

  
161
.rela.text
162
 *(.rela.text)
163
 *(.rela.text.*)
164
 *(.rela.gnu.linkonce.t*)
165

  
166
.rel.fini
167
 *(.rel.fini)
168

  
169
.rela.fini
170
 *(.rela.fini)
171

  
172
.rel.rodata
173
 *(.rel.rodata)
174
 *(.rel.rodata.*)
175
 *(.rel.gnu.linkonce.r*)
176

  
177
.rela.rodata
178
 *(.rela.rodata)
179
 *(.rela.rodata.*)
180
 *(.rela.gnu.linkonce.r*)
181

  
182
.rel.data
183
 *(.rel.data)
184
 *(.rel.data.*)
185
 *(.rel.gnu.linkonce.d*)
186

  
187
.rela.data
188
 *(.rela.data)
189
 *(.rela.data.*)
190
 *(.rela.gnu.linkonce.d*)
191

  
192
.rel.ctors
193
 *(.rel.ctors)
194

  
195
.rela.ctors
196
 *(.rela.ctors)
197

  
198
.rel.dtors
199
 *(.rel.dtors)
200

  
201
.rela.dtors
202
 *(.rela.dtors)
203

  
204
.rel.got
205
 *(.rel.got)
206

  
207
.rela.got
208
 *(.rela.got)
209

  
210
.rel.bss
211
 *(.rel.bss)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff