Project

General

Profile

Revision 681

added possibility of global client write

View differences:

trunk/code/projects/colonet/robot/colonet_dragonfly/colonet_dragonfly.c
117 117
  *y = robot_y;
118 118
}
119 119

  
120
static void report_arrived() {
121
  //usb_puts("requesting_abs_position\n");
122
  ColonetRobotServerPacket pkt;
123
  pkt.client_id = -1; //global
124
  pkt.msg_code = ROBOT_REPORT_ARRIVED_AT_POSITION;
125
  wl_send_global_packet(colonet_pgh.groupCode, 0, (char*)&pkt, sizeof(ColonetRobotServerPacket), 0);
126
}
127

  
120 128
void request_abs_position() {
121 129
  //usb_puts("requesting_abs_position\n");
122 130
  ColonetRobotServerPacket pkt;
123
  pkt.client_id = -1;
131
  pkt.client_id = -1; //global
124 132
  pkt.msg_code = ROBOT_REQUEST_POSITION_FROM_SERVER;
125 133
  wl_send_global_packet(colonet_pgh.groupCode, 0, (char*)&pkt, sizeof(ColonetRobotServerPacket), 0);
126 134
}
......
238 246
              // Reached destination.
239 247
              motors_off();
240 248
              robot_state = NO_COMMAND;
249

  
250
              // Notify server that robot arrived.
251
              report_arrived();
241 252
            } else {
242 253
              // e is the error vector (where we want to go)
243 254
              //char buf[80];
trunk/code/projects/colonet/server/colonet_wireless.cpp
262 262
static void handle_receive(char type, int source_robot, unsigned char* data, int len) {
263 263
  type = type; //TODO: This is just here to get rid of compiler warnings.
264 264

  
265
  printf("***Got packet from robot***\n");
265
  //printf("***Got packet from robot***\n");
266 266

  
267 267
  ColonetRobotServerPacket* pkt = (ColonetRobotServerPacket*)data;
268 268

  
trunk/code/projects/colonet/server/ConnectionPool.cpp
183 183
 * @brief Puts text into a write buffer that will be written to a client's file
184 184
 *  descriptor sometime when the client is ready to write.
185 185
 *
186
 * @param pool_index Index in the pool of the client to write to
186
 * @param pool_index Index in the pool of the client to write to.  -1 for global.
187 187
 * @param message The message to be written
188 188
 * @param length The length of the message
189 189
 *
190 190
 * @return 0 on success, negative error code on failure
191 191
 */
192 192
int ConnectionPool::write_to_client(int pool_index, char * message, int length) {
193
  if (pool_index < 0 || pool_index >= next_available_slot) {
194
    return ERROR_INVALID_CLIENT_ID;
195
  }
196

  
197 193
  if (!message) {
198 194
    return ERROR_INVALID_MESSAGE;
199 195
  }
......
208 204
    return ERROR_NOT_ENOUGH_ROOM;
209 205
  }
210 206

  
211
  //printf("Connection pool: attempting to write [%s], length %i to index %i.\n", message, length, pool_index);
207
  if (pool_index == -1) {
208
    // Global message.
209
    for (int i = 0; i < number_clients_ready; i++) {
210
      memcpy(write_buffer[i], message, length);
211
      write_buffer_size[i] += length;
212
    }
213
  } else {
214
    if (pool_index < 0 || pool_index >= next_available_slot) {
215
      return ERROR_INVALID_CLIENT_ID;
216
    }
212 217

  
213
  memcpy(write_buffer[pool_index], message, length);
214
  write_buffer_size[pool_index] += length;
218
    //printf("Connection pool: attempting to write [%s], length %i to index %i.\n", message, length, pool_index);
219
    memcpy(write_buffer[pool_index], message, length);
220
    write_buffer_size[pool_index] += length;
221
  }
215 222

  
216 223
  return 0;
217 224
}
trunk/code/projects/colonet/common/colonet_defs.h
157 157
#define SERVER_REPORT_VIRTUAL_WALL_LOWER 0x5B
158 158

  
159 159
#define SERVER_CLEAR_VIRTUAL_WALL 0x5C
160
#define ROBOT_REPORT_ARRIVED_AT_POSITION 0x5D
160 161

  
161 162
///////////////////////////
162 163
//Colonet specific commands
trunk/code/projects/colonet/client/ColonetServerInterface.java
62 62
	public static final String CLIENT_ASSIGN_ROBOT_ID = "87";
63 63
  public static final String CLIENT_SET_VIRTUAL_WALL = "89";
64 64
	public static final String MOVE_TO_ABSOLUTE_POSITION = "83"; //0x53
65
  
66 65

  
66

  
67 67
	//Queue instructions
68 68
	public static final String COLONET_QUEUE = "100";
69 69
	public static final String QUEUE_UPDATE = "101";
......
371 371

  
372 372
			sendData(MOVE_TO_ABSOLUTE_POSITION + " " + x_high + " " + x_low + " " + y_high + " " + y_low, "" + id);
373 373
	}
374
  
374

  
375 375
    /**
376 376
    * Establish a boundary for robot motion.
377 377
    */

Also available in: Unified diff