Revision 334
Added battery request functionaltiy. It works, but is kind of a hack. I will be cleaning it up so the format is the same as other requests.
trunk/code/projects/colonet/lib/colonet_dragonfly/colonet_dragonfly.c | ||
---|---|---|
167 | 167 |
|
168 | 168 |
// Battery |
169 | 169 |
case BATTERY: |
170 |
usb_puts("Got battery request."); |
|
171 |
wl_send_robot_to_robot_global_packet(colonet_pgh.groupCode, BATTERY, |
|
172 |
"34", 2, 0xA, 0); |
|
173 |
usb_puts("Sent.\n"); |
|
170 |
usb_puts("Got battery request.\n"); |
|
171 |
int xbeeDongleID = 0xA; // too bad this is hard-coded. |
|
172 |
char data[20]; |
|
173 |
data[0] = 0; // client ID specified in bytes 0-3 |
|
174 |
data[1] = 0; |
|
175 |
data[2] = 0; |
|
176 |
data[3] = 0; |
|
177 |
data[4] = 0; // ??? |
|
178 |
data[5] = RESPONSE_TO_CLIENT_REQUEST; |
|
179 |
data[6] = ' '; |
|
180 |
data[7] = BATTERY; |
|
181 |
data[8] = ' '; |
|
182 |
data[9] = (char) wl_get_xbee_id(); // robot number (self) |
|
183 |
data[10] = ' '; |
|
184 |
data[11] = (char) battery8(); // battery reading |
|
185 |
data[12] = '\0'; |
|
186 |
|
|
187 |
wl_send_robot_to_robot_global_packet(colonet_pgh.groupCode, COLONET_RESPONSE, |
|
188 |
data, 13, xbeeDongleID, 0); |
|
189 |
usb_puts("lol \n"); |
|
190 |
|
|
174 | 191 |
break; |
175 | 192 |
|
176 | 193 |
case ORB_INIT: |
trunk/code/projects/colonet/ColonetServer/ConnectionPool.cpp | ||
---|---|---|
196 | 196 |
return ERROR_NOT_ENOUGH_ROOM; |
197 | 197 |
} |
198 | 198 |
|
199 |
printf("Connection pool: attempting to write [%s], length %i to index %i.\n", message, length, pool_index); |
|
200 |
|
|
199 | 201 |
memcpy(write_buffer[pool_index], message, length); |
200 | 202 |
write_buffer_size[pool_index] += length; |
201 | 203 |
|
trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp | ||
---|---|---|
145 | 145 |
if (type == COLONET_RESPONSE) { |
146 | 146 |
printf("response\n"); |
147 | 147 |
|
148 |
/* |
|
149 |
//Eugene's code |
|
148 | 150 |
char buffer[WRITE_BUFFER_SIZE]; |
149 | 151 |
|
150 | 152 |
int value = (int)(data[0]); |
151 | 153 |
snprintf(buffer, WRITE_BUFFER_SIZE, "%d\n", value); |
152 | 154 |
|
153 | 155 |
int buflen = strlen(buffer); |
156 |
*/ |
|
157 |
|
|
158 |
//Greg's code |
|
159 |
char * buffer = (char *) &(data[5]); |
|
160 |
int buflen = strlen(buffer); |
|
161 |
buffer[buflen] = '\n'; |
|
162 |
buflen++; |
|
163 |
|
|
154 | 164 |
if (connection_pool.write_to_client(dest, buffer, buflen) == ERROR_INVALID_CLIENT_ID) { |
155 | 165 |
printf("The robot wanted to pass the data to a client not in the pool.\n"); |
156 | 166 |
return -1; |
trunk/code/projects/colonet/utilities/robot_slave/robot_slave.c | ||
---|---|---|
21 | 21 |
colonet_init(); |
22 | 22 |
|
23 | 23 |
|
24 |
orb_set_color(YELLOW); |
|
24 |
//orb_set_color(YELLOW); |
|
25 |
orb_set_color(GREEN); |
|
25 | 26 |
usb_puts("test!\n"); |
26 | 27 |
|
27 | 28 |
while(1) { |
trunk/code/projects/colonet/utilities/robot_slave/Makefile | ||
---|---|---|
3 | 3 |
# |
4 | 4 |
|
5 | 5 |
# Relative path to the root directory (containing lib directory) |
6 |
ifndef COLONYROOT |
|
6 |
#ifndef COLONYROOT
|
|
7 | 7 |
COLONYROOT = ../../../../../ |
8 |
endif |
|
8 |
#endif
|
|
9 | 9 |
|
10 | 10 |
# Target file name (without extension). |
11 | 11 |
TARGET = robot_slave |
Also available in: Unified diff