Project

General

Profile

Revision 1192

added infrastructure for robot to send data to station

View differences:

trunk/code/projects/diagnostic_station/station/comm_robot.c
4 4
#include "comm_robot.h"
5 5
#include "../common/comm_station_robot.h"
6 6

  
7
char new_data = 0;
8
char finished = 0;
9
char data_received[10];
10

  
7 11
// A packet that is followed by a "done" packet from the robot.
8 12
static void send_command_packet (char type, char *data, int len)
9 13
{
......
18 22
}
19 23

  
20 24
// A packet that is followed by a data packet from the robot
21
//static void send_request_packet
22
//{
23
//
24
//}
25
static void send_request_packet(char type, char *data, int len)
26
{
27
	wl_Send_global_packet (station_robot_group, type, data, len, 0);
28
	while(!new_data){
29
		wl_do();
30
	}
31
	new_data = 0;
32
}
25 33

  
26 34

  
27 35

  
......
82 90
	send_command_packet (station_robot_set_bom, data, 2);
83 91
}
84 92

  
85
//void robot_read_encoders ()
86
//{
87
//	send_request_packet (station_robot_read_enocders, NULL, 0);
88
//}
93
char* robot_read_encoders ()
94
{
95
	send_request_packet (station_robot_read_enocders, NULL, 0);
96
	return data_received;
97
}
98

  
99
void robot_station_receive(char type, int source, unsigned char* packet, int length)
100
{
101
	switch (type)
102
	{
103
		case robot_station_finished:    new_data = 1;    break;
104
		case robot_station_data_encoders:   new_data = 1;   break;
105
	}
106
}
trunk/code/projects/diagnostic_station/station/comm_robot.h
5 5
void robot_set_motors (uint8_t direction1, uint8_t speed1, uint8_t direction2, uint8_t speed2);
6 6
void robot_set_motors_off (void);
7 7
void robot_set_bom (uint16_t bitmask);
8
void robot_read_encoders (void);
8
char* robot_read_encoders (void);
9
void robot_station_receive(char type, int source, unsigned char* packet, int length);
9 10

  
10 11

  
11 12

  
trunk/code/projects/diagnostic_station/station/main.c
55 55

  
56 56
}
57 57

  
58

  
59
int main_evan (void)
60
{
61
#include <dragonfly_lib.h>
62
#include <wireless.h>
63

  
64
    dragonfly_init(0);
65

  
66
    usb_init ();
67

  
68
	usb_puts(NL NL NL);
69
	usb_puts("# Diagnostic station version " version_string " starting" NL);
70

  
71
    orb_init_pwm ();
72
	hardware_init ();
73
	comm_server_init ();
74

  
75
	orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
76
	xbee_init ();
77
	wl_init();
78
	orb2_set (255, 0, 0); usb_puts("# Done" NL);
79

  
80
	PacketGroupHandler receive_handler = {robot_station_group, NULL, NULL, &robot_station_receive, NULL};
81
	wl_register_packet_group(&receive_handler);
82

  
83
	// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
84
	if (button1_read ())
85
			test_all ();
86

  
87
	// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
88
	if (button2_read ())
89
		interactive_main ();
90
	else
91
	{
92
		// Set the orbs to green/yellow
93
		orbs_set (0,255,0, 255,127,0);
94

  
95
		server_main ();
96
	}
97

  
98
	while (1);
99
}
100

  
58 101
int main_default (void)
59 102
{
60 103
#include <dragonfly_lib.h>
......
92 135
	}
93 136

  
94 137
	while (1);
95
}
138
}

Also available in: Unified diff