Project

General

Profile

Revision 118

updated server for new wl library changes

View differences:

ConnectionPool.cpp
16 16
#include "includes/ConnectionPool.h"
17 17
#include "includes/client.h"
18 18
#include "../lib/colonet_defs.h"
19
#include <colonet_wireless.h>
19 20

  
20 21
/**
21 22
 * @brief The default constructor for ConnectionPool
......
139 140
 * Sees is any clients are ready to read from their file descriptor or are
140 141
 *  ready to write to their file descriptor.
141 142
 *
142
 * @param wireless A pointer to the wireless object
143
 *
144 143
 * @return 0 on success, negative error code on error
145 144
 */
146 145
//TODO: test that it drops commands properly if it gets sent too much data
147 146
//      do we want it to drop the data or drop the connection?
148
int ConnectionPool::check_clients(ColonetWireless * wireless) {
147
int ConnectionPool::check_clients() {
149 148
  char temporary_buffer[READ_BUFFER_SIZE];
150 149
  char temporary_command_buffer[READ_BUFFER_SIZE+1];
151 150
  int i;
......
228 227
            break;
229 228
          }
230 229

  
231
          if (parse_command(temporary_command_buffer, i, wireless) < 0) {
230
          if (parse_command(temporary_command_buffer, i) < 0) {
232 231
            printf("There was an error parsing command\n");
233 232
            break;
234 233
          }
......
376 375
}
377 376

  
378 377
//TODO: write a function to write data into the write buffers (jason: what was this referring to?)
379
int ConnectionPool::parse_command(char* command, int pool_index, ColonetWireless * wireless) {
378
int ConnectionPool::parse_command(char* command, int pool_index) {
380 379
  char tokens[MAX_TOKENS][MAX_TOKEN_SIZE];
381 380
  unsigned char int_tokens[MAX_TOKENS];
382 381
  int number_tokens = 0;
......
435 434
    */
436 435

  
437 436
    // Fill arguments buffer with arguments 
438
    for (i = ROBOT_COMMAND_LEN; i < number_int_tokens-ROBOT_COMMAND_OFFSET; i++) {
437
    for (i = ROBOT_COMMAND_LEN; i < number_int_tokens-ROBOT_COMMAND_OFFSET;
438
         i++) {
439 439
      arguments[i-ROBOT_COMMAND_LEN] = int_tokens[i];
440 440
    }
441 441

  
......
446 446
    }
447 447
  
448 448
    // Send packet to robot 
449
    fprintf(stderr, "Calling wireless->send(%d, %d, %d, arguments)\n", 
449
    fprintf(stderr, "Calling colonet_wl_send(%d, %d, %d, arguments)\n", 
450 450
            int_tokens[0], int_tokens[1], int_tokens[2]);
451
    wireless->send(int_tokens[0], int_tokens[1], int_tokens[2], arguments);
451
    colonet_wl_send(pool_index, int_tokens[0],
452
                    (ColonetMessageType)int_tokens[1], int_tokens[2],
453
                    arguments);
452 454
  } else if (command_id == REQUEST_FROM_SERVER) {
453 455
    if (number_tokens < 2)
454 456
      return -1;

Also available in: Unified diff