Project

General

Profile

Revision 1192

added infrastructure for robot to send data to station

View differences:

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
}

Also available in: Unified diff