Revision 1198
Added server communication parameter parsing
Misc. fixes
comm_robot.c | ||
---|---|---|
24 | 24 |
// A packet that is followed by a data packet from the robot |
25 | 25 |
static void send_request_packet(char type, char *data, int len) |
26 | 26 |
{ |
27 |
wl_Send_global_packet (station_robot_group, type, data, len, 0);
|
|
27 |
wl_send_global_packet (station_robot_group, type, data, len, 0);
|
|
28 | 28 |
while(!new_data){ |
29 | 29 |
wl_do(); |
30 | 30 |
} |
... | ... | |
92 | 92 |
|
93 | 93 |
char* robot_read_encoders () |
94 | 94 |
{ |
95 |
send_request_packet (station_robot_read_enocders, NULL, 0);
|
|
95 |
send_request_packet (station_robot_read_encoders, NULL, 0);
|
|
96 | 96 |
return data_received; |
97 | 97 |
} |
98 | 98 |
|
99 |
void receive_encoders(int* data, int length){ |
|
100 |
((int*)data_received)[0] = data[0]; |
|
101 |
((int*)data_received)[1] = data[1]; |
|
102 |
} |
|
103 |
|
|
99 | 104 |
void robot_station_receive(char type, int source, unsigned char* packet, int length) |
100 | 105 |
{ |
101 | 106 |
switch (type) |
102 | 107 |
{ |
103 |
case robot_station_finished: new_data = 1; break;
|
|
104 |
case robot_station_data_encoders: receive_encoders((int*)packet, length); break;
|
|
108 |
case robot_station_finished: new_data = 1; break;
|
|
109 |
case robot_station_data_encoders: receive_encoders((int*)packet, length); break;
|
|
105 | 110 |
} |
106 | 111 |
new_data = 1; |
107 | 112 |
} |
108 | 113 |
|
109 |
void receive_encoders(int* data; int length){ |
|
110 |
((int*)data_received)[0] = data[0]; |
|
111 |
((int*)data_received)[1] = data[1]; |
|
112 |
} |
|
114 |
|
|
115 |
void comm_robot_init () |
|
116 |
{ |
|
117 |
PacketGroupHandler receive_handler = {robot_station_group, NULL, NULL, &robot_station_receive, NULL}; |
|
118 |
wl_register_packet_group(&receive_handler); |
|
119 |
} |
Also available in: Unified diff