Revision 620
Trying to debug wireless problems
colonet_wireless.cpp | ||
---|---|---|
121 | 121 |
* @return 0 on success, a negative error code on failure |
122 | 122 |
*/ |
123 | 123 |
int colonet_wl_send(short client_source, short dest, ColonetRobotMessageType msg_type, unsigned char msg_code, |
124 |
unsigned char* args) { |
|
125 |
//printf("colonet_wl_send: client_source:%d, dest:%d, msg_code:%d\n", client_source, dest, msg_code);
|
|
124 |
unsigned char* args) {
|
|
125 |
printf("colonet_wl_send: client_source:%d, dest:%d, msg_code:%d\n", client_source, dest, msg_code); |
|
126 | 126 |
|
127 |
//create a new packet to be sent
|
|
127 |
//create and set up new packet to be sent.
|
|
128 | 128 |
ColonetRobotServerPacket pkt; |
129 |
|
|
130 |
//set up the packet |
|
131 |
|
|
132 | 129 |
pkt.client_id = client_source; |
133 | 130 |
pkt.msg_code = msg_code; |
134 | 131 |
|
... | ... | |
140 | 137 |
|
141 | 138 |
if (dest == GLOBAL_DEST) { |
142 | 139 |
//printf("sending to global dest\n"); |
143 |
if (wl_send_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt), |
|
144 |
sizeof(ColonetRobotServerPacket), 0) != 0) { |
|
140 |
int ret = wl_send_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt), |
|
141 |
sizeof(ColonetRobotServerPacket), 0); |
|
142 |
if (ret != 0) { |
|
143 |
fprintf(stderr, "%s: wl_send_global_packet failed.\n", __FUNCTION__); |
|
145 | 144 |
return -1; |
146 | 145 |
} |
147 | 146 |
} else { |
148 | 147 |
//("sending to specific robot: %d.\n", dest); |
149 |
if (wl_send_robot_to_robot_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt), |
|
150 |
sizeof(ColonetRobotServerPacket), dest, COLONET_RESPONSE_PACKET_FRAME_ID) != 0) { |
|
148 |
int ret = wl_send_robot_to_robot_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt), |
|
149 |
sizeof(ColonetRobotServerPacket), dest, |
|
150 |
COLONET_RESPONSE_PACKET_FRAME_ID); |
|
151 |
if (ret != 0) { |
|
152 |
fprintf(stderr, "%s: wl_send_robot_to_robot_global_packet failed.\n", __FUNCTION__); |
|
151 | 153 |
return -1; |
152 | 154 |
} |
153 | 155 |
} |
... | ... | |
192 | 194 |
* @brief Gets the sensor matrix from the wireless library |
193 | 195 |
* |
194 | 196 |
* @param numrobots A pointer to the variable where you want the number of robots to be stored |
195 |
* @param ids_ A pointer to a pointer that you want to point to the list of xbee ids. This memory is dynamically allocated and should be freed by the calling process when it is done with it |
|
197 |
* @param ids_ A pointer to a pointer that you want to point to the list of xbee ids. This memory is dynamically |
|
198 |
* allocated and should be freed by the calling process when it is done with it |
|
196 | 199 |
* |
197 |
* @return The 2d matrix reprsenting the sensor matrix. This memory is dynamically allocated and should be freed by the calling process when it is done with it |
|
200 |
* @return The 2d matrix reprsenting the sensor matrix. This memory is dynamically allocated and should be freed by |
|
201 |
* the calling process when it is done with it |
|
198 | 202 |
*/ |
199 | 203 |
int** colonet_get_sensor_matrix(int* numrobots, int** ids_) { |
200 | 204 |
int num_robots; |
... | ... | |
230 | 234 |
} |
231 | 235 |
|
232 | 236 |
static void handle_receive(char type, int source, unsigned char* data, int len) { |
233 |
//TODO: These are just here to get rid of compiler warnings |
|
234 |
type = type; |
|
237 |
type = type; //TODO: This is just here to get rid of compiler warnings. |
|
235 | 238 |
|
236 |
printf("!!!***Got packet from robot***!!!\n");
|
|
239 |
fprintf(stderr, "***Got packet from robot***\n");
|
|
237 | 240 |
|
238 | 241 |
ColonetRobotServerPacket* pkt = (ColonetRobotServerPacket*)data; |
239 | 242 |
|
... | ... | |
294 | 297 |
* @return NULL |
295 | 298 |
*/ |
296 | 299 |
static void* listen(void* args) { |
297 |
//TODO: These are just here to get rid of compiler warnings |
|
298 |
args = args; |
|
300 |
args = args; //TODO: These are just here to get rid of compiler warnings. |
|
299 | 301 |
|
300 |
printf("Called listen.\n");
|
|
302 |
fprintf(stderr, "Called listen.\n");
|
|
301 | 303 |
|
302 |
PacketGroupHandler pgh = {COLONET_PACKET_GROUP_ID, |
|
303 |
timeout_handler, |
|
304 |
handle_response, |
|
305 |
handle_receive, |
|
306 |
unregister}; |
|
304 |
PacketGroupHandler pgh = {COLONET_PACKET_GROUP_ID, timeout_handler, handle_response, handle_receive, unregister}; |
|
307 | 305 |
wl_register_packet_group(&pgh); |
308 | 306 |
|
309 | 307 |
while (1) { |
Also available in: Unified diff