Project

General

Profile

Revision 963

Minor modifications and fixes. Haven't gotten it to work yet.

View differences:

test.c
5 5
#include <dragonfly_lib.h>
6 6
#include <wireless.h>
7 7
#include <encoders.h>
8
#include "odometry.h"
8 9

  
9
#define MAP_RECEIVE_GROUP 17
10 10
#define MAP_REQUEST_GROUP 23
11 11

  
12
#define POINT_RAW 1 // packet type for map data points w/ raw encoder data
13
#define POINT_ODO 2 // packet type for map data points w/ odometry data
12
#define DATA_POINT 2 
13
#define DATA_REQUEST 3
14 14

  
15
#define WL_CNTL_GROUP 4
16

  
17 15
int state;
18 16
int velocity;
19 17
char buf[100];
20 18

  
21 19
void respond(char type, int source, unsigned char* packet, int length);
22 20

  
23
PacketGroupHandler receiveHandler = {MAP_REQUEST_GROUP, 
24
	NULL, NULL, NULL, NULL};
25

  
26
PacketGroupHandler requestHandler = {MAP_RECEIVE_GROUP, 
21
PacketGroupHandler requestHandler = {MAP_REQUEST_GROUP, 
27 22
	NULL, NULL, respond, NULL};
28 23

  
29 24
int main(void)
30 25
{
31 26
    /* initialize components and join the token ring */
32
    dragonfly_init(ALL_ON);
27
    dragonfly_init(ORB | RANGE | BOM | COMM);
33 28
    odometry_init();
34 29
    
35 30
	wl_init();
36 31
    wl_set_channel(0xE);
37
    wl_register_packet_group(&receiveHandler);
38 32
    wl_register_packet_group(&requestHandler);
39 33
    
40 34
    wl_token_ring_register();
......
50 44
}
51 45

  
52 46
void respond(char type, int source, unsigned char* packet, int length) {
53
    sprintf(buf, "received packet: %d\n", type);
54
    usb_puts(buf);
47
   	if(type==DATA_REQUEST){ 
48
		sprintf(buf, "received packet: %d\n", type);
49
    	usb_puts(buf);
55 50
	
56
	int store[9];
57
	store[0] = 0;
58
    store[1] = 0;
59
    *((double*)(store + 2)) = 5.0;
60
    store[4] = 125;	// IR1 range
61
	store[5] = 125;	// IR2 range
62
	store[6] = 125;	// IR3 range
63
	store[7] = 125;	// IR4 range
64
	store[8] = 125;	// IR5 range
51
		int store[9];
52
		store[0] = 0;
53
    	store[1] = 0;
54
    	*((double*)(store + 2)) = 5.0;
55
    	store[4] = 125;	// IR1 range
56
		store[5] = 125;	// IR2 range
57
		store[6] = 125;	// IR3 range
58
		store[7] = 125;	// IR4 range
59
		store[8] = 125;	// IR5 range
65 60

  
66
	wl_send_robot_to_robot_global_packet(MAP_RECEIVE_GROUP, 
67
		POINT_ODO, &store, 0, source, 0);
68
    
61
		wl_send_robot_to_robot_global_packet(MAP_REQUEST_GROUP, 
62
			DATA_POINT, &store, 0, source, 0);
63
	}
69 64
}
70 65

  
71 66

  

Also available in: Unified diff