Revision 348
fixed some warnings in colonet robot code
trunk/code/projects/colonet/lib/colonet_wireless/colonet_wireless.cpp | ||
---|---|---|
43 | 43 |
static void* listen(void* args); |
44 | 44 |
static void timeout_handler(void); |
45 | 45 |
static void handle_response(int frame, int received); |
46 |
static void handle_receive(char type, int source, unsigned char* packet, |
|
47 |
int len); |
|
46 |
static void handle_receive(char type, int source, unsigned char* packet, int len); |
|
48 | 47 |
static void unregister(void); |
49 | 48 |
static int log_packet(unsigned char* packet, int len); |
50 | 49 |
|
51 |
|
|
52 | 50 |
/**************************** Public functions *******************************/ |
53 | 51 |
void colonet_wl_init(char* wl_port_, MsgHandlerFunction message_handler_, char* log_filename_) { |
54 | 52 |
if (log_filename_ != NULL) { |
55 |
printf("Log filename_=%p: %s\n", log_filename_, log_filename_); |
|
56 | 53 |
logging_enabled = true; |
57 | 54 |
strcpy(log_filename, log_filename_); |
58 | 55 |
} |
... | ... | |
164 | 161 |
static void handle_receive(char type, int source, unsigned char* packet, |
165 | 162 |
int len) { |
166 | 163 |
ColonetRobotServerPacket pkt; |
167 |
pkt.client_id = packet[0] | (packet[1]<<8) | (packet[2]<<16) | |
|
168 |
(packet[3]<<24); //little endian |
|
164 |
pkt.client_id = packet[0] | (packet[1]<<8) | (packet[2]<<16) | (packet[3]<<24); //little endian |
|
169 | 165 |
|
170 | 166 |
memcpy(pkt.data, packet + 5, PACKET_DATA_LEN); |
171 | 167 |
|
trunk/code/projects/colonet/lib/colonet_dragonfly/colonet_dragonfly.c | ||
---|---|---|
24 | 24 |
static UserHandler user_handlers[USER_DEFINED_MSG_TOTAL]; |
25 | 25 |
|
26 | 26 |
/* Internal function prototypes */ |
27 |
static void packet_string_to_struct(ColonetRobotServerPacket* dest_pkt, |
|
28 |
char* pkt_buf); |
|
27 |
static void packet_string_to_struct(ColonetRobotServerPacket* dest_pkt, unsigned char* pkt_buf); |
|
29 | 28 |
static unsigned int two_bytes_to_int(char high, char low); |
30 |
static void colonet_handle_receive(char type, int source, |
|
31 |
unsigned char* packet, int length); |
|
29 |
static void colonet_handle_receive(char type, int source, unsigned char* packet, int length); |
|
32 | 30 |
|
33 | 31 |
static PacketGroupHandler colonet_pgh; |
34 | 32 |
|
... | ... | |
56 | 54 |
* |
57 | 55 |
* @return -1 on error (invalid msgId), 0 on success |
58 | 56 |
*/ |
59 |
static void colonet_handle_receive(char type, int source, unsigned char* packet, |
|
60 |
int length) { |
|
57 |
static void colonet_handle_receive(char type, int source, unsigned char* packet, int length) { |
|
61 | 58 |
ColonetRobotServerPacket pkt; |
62 | 59 |
unsigned char* args; //up to 7 char args |
63 | 60 |
unsigned int int_args[3]; //up to 3 int (2-byte) args |
... | ... | |
170 | 167 |
// Battery |
171 | 168 |
case BATTERY: |
172 | 169 |
usb_puts("Got battery request.\n"); |
170 |
|
|
171 |
/* |
|
173 | 172 |
int xbeeDongleID = 0xA; // too bad this is hard-coded. |
174 | 173 |
char data[20]; |
175 | 174 |
data[0] = 0; // client ID specified in bytes 0-3 |
... | ... | |
186 | 185 |
data[11] = (char) battery8(); // battery reading |
187 | 186 |
data[12] = '\0'; |
188 | 187 |
|
189 |
wl_send_robot_to_robot_global_packet(colonet_pgh.groupCode, COLONET_RESPONSE, |
|
190 |
data, 13, xbeeDongleID, 0); |
|
188 |
wl_send_robot_to_robot_global_packet(colonet_pgh.groupCode, COLONET_RESPONSE, data, 13, xbeeDongleID, 0); |
|
191 | 189 |
usb_puts("lol \n"); |
192 |
|
|
190 |
*/ |
|
193 | 191 |
break; |
194 | 192 |
|
195 | 193 |
case ORB_INIT: |
... | ... | |
235 | 233 |
motors_off(); |
236 | 234 |
break; |
237 | 235 |
case MOVE: |
238 |
buf[40]; |
|
239 | 236 |
sprintf(buf, "calling move with: %d, %d\n", args[0], args[1]); |
240 | 237 |
usb_puts(buf); |
241 | 238 |
move(args[0], args[1]); |
... | ... | |
298 | 295 |
* Adds a user-defined message |
299 | 296 |
*/ |
300 | 297 |
int colonet_add_message(unsigned char msgId, void (*handler)(void)) { |
301 |
if(msgId < USER_DEFINED_MSG_ID_START || msgId > USER_DEFINED_MSG_ID_END){
|
|
298 |
if(msgId < USER_DEFINED_MSG_ID_START /* || msgId > USER_DEFINED_MSG_ID_END */){
|
|
302 | 299 |
return -1; |
303 | 300 |
} |
304 | 301 |
|
... | ... | |
309 | 306 |
return 0; |
310 | 307 |
} |
311 | 308 |
|
312 |
static void packet_string_to_struct(ColonetRobotServerPacket* dest_pkt, |
|
313 |
char* pkt_buf) { |
|
309 |
static void packet_string_to_struct(ColonetRobotServerPacket* dest_pkt, unsigned char* pkt_buf) { |
|
314 | 310 |
memcpy(dest_pkt, pkt_buf, sizeof(ColonetRobotServerPacket)); |
315 | 311 |
} |
316 | 312 |
|
trunk/code/projects/colonet/lib/colonet_dragonfly/Makefile | ||
---|---|---|
7 | 7 |
|
8 | 8 |
CC = avr-gcc |
9 | 9 |
CFLAGS = -Wall -Wshadow -Wextra -g -mmcu=$(MCU) |
10 |
INCLUDES = -I../../../xfly_lib -I../ -I../../../libwireless/lib -I../../../../lib/include/libdragonfly
|
|
10 |
INCLUDES = -I../ -I../../../libwireless/lib -I../../../../lib/include/libdragonfly |
|
11 | 11 |
|
12 | 12 |
all: colonet_dragonfly.o |
13 | 13 |
|
trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp | ||
---|---|---|
187 | 187 |
char* log_filename = NULL; |
188 | 188 |
|
189 | 189 |
if (optionsG.logging_enabled) { |
190 |
printf("Logging enabled.\n");
|
|
190 |
printf("Logging enabled. Log filename: %s\n", optionsG.log_filename);
|
|
191 | 191 |
log_filename = optionsG.log_filename; |
192 | 192 |
} else { |
193 | 193 |
printf("Logging disabled.\n"); |
194 | 194 |
} |
195 | 195 |
|
196 |
printf("log filename = %p\n", log_filename); |
|
197 |
|
|
198 | 196 |
colonet_wl_init(optionsG.wireless_port, wirelessMessageHandler, log_filename); |
199 | 197 |
|
200 | 198 |
if (colonet_wl_run_listener_thread()) { |
201 |
fprintf(stderr, "%s: colonet_wl_run_listener_thread failed.\n", |
|
202 |
__FUNCTION__); |
|
199 |
fprintf(stderr, "%s: colonet_wl_run_listener_thread failed.\n", __FUNCTION__); |
|
203 | 200 |
return -1; |
204 | 201 |
} |
205 | 202 |
|
... | ... | |
214 | 211 |
* @return 0 on success, negative error code on error |
215 | 212 |
*/ |
216 | 213 |
int ColonetServer::initialize_connection(int port) { |
217 |
printf("Initializing connection that will be used to listen for " |
|
218 |
"clients...\n"); |
|
214 |
printf("Initializing connection that will be used to listen for clients...\n"); |
|
219 | 215 |
int options = 1; |
220 | 216 |
struct sockaddr_in my_address; |
221 | 217 |
|
Also available in: Unified diff