Project

General

Profile

Revision 408

added asleep to wl_do loop

View differences:

trunk/code/projects/colonet/ColonetGUI/Makefile
34 34

  
35 35
install:
36 36
	@echo --- Copying files to /var/www/colonet ---
37
	rm -rf /var/www/colonet/
37 38
	mkdir /var/www/colonet/
38 39
	cp $(DIR)/Colonet.jar /var/www/colonet/Colonet.jar
39 40
	cp index.html /var/www/colonet/index.html
41
	cp colonetstyle.css /var/www/colonet/colonetstyle.css
40 42

  
41 43
clean:
42 44
	$(RM) $(DIR)/*.class
trunk/code/projects/colonet/ColonetServer/Command.cpp
145 145
  return 0;
146 146
}
147 147

  
148
int Command::parse_send_to_robot(int number_tokens,
149
                                 char tokens[MAX_TOKENS][MAX_TOKEN_SIZE],
150
                                 int pool_index) {
148
int Command::parse_send_to_robot(int number_tokens, char tokens[MAX_TOKENS][MAX_TOKEN_SIZE], int pool_index) {
151 149
  int i;
152 150
  unsigned char int_tokens[MAX_TOKENS];
153 151
  int number_int_tokens = number_tokens;
......
174 172
  // Send packet to robot
175 173
  fprintf(stderr, "Calling colonet_wl_send(%d, %d, %d, arguments)\n",
176 174
          int_tokens[0], int_tokens[1], int_tokens[2]);
177
  colonet_wl_send((short)pool_index, int_tokens[0],
178
                  (ColonetMessageType)int_tokens[1], int_tokens[2], arguments);
175
  if (colonet_wl_send((short)pool_index, int_tokens[0], (ColonetMessageType)int_tokens[1], int_tokens[2], arguments)
176
      != 0) {
177
    fprintf(stderr, "Error - Colonet_wl_send failed.");
178
    return -1;
179
  }
179 180

  
180 181
  return 0;
181 182
}
trunk/code/projects/colonet/ColonetServer/colonet_wireless.cpp
93 93
  return 0;
94 94
}
95 95

  
96
void colonet_wl_send(short client_source, short dest, ColonetMessageType msg_type, unsigned char msg_code,
96
int colonet_wl_send(short client_source, short dest, ColonetMessageType msg_type, unsigned char msg_code,
97 97
                     unsigned char* args) {
98 98
  printf("colonet_wl_send: client_source:%d, dest:%d, msg_code:%d\n", client_source, dest, msg_code);
99 99

  
......
107 107

  
108 108
  if (dest == GLOBAL_DEST) {
109 109
    printf("sending to global dest\n");
110

  
111
    wl_send_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt), sizeof(ColonetRobotServerPacket), 0);
110
    if (wl_send_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt),
111
                              sizeof(ColonetRobotServerPacket), 0) != 0) {
112
      return -1;
113
    }
112 114
  } else {
113 115
    printf("sending to specific robot.\n");
114 116
    wl_send_robot_to_robot_global_packet(COLONET_PACKET_GROUP_ID, (char)msg_type, (char*)(&pkt),
......
208 210

  
209 211
  while (1) {
210 212
    wl_do();
213
    usleep(50000);
211 214
  }
212 215

  
213 216
  wl_terminate();
trunk/code/projects/colonet/ColonetServer/includes/colonet_wireless.h
40 40
 *
41 41
 * @return void
42 42
 */
43
void colonet_wl_send(short client_source, short dest, ColonetMessageType msg_type, unsigned char msg_code,
44
                     unsigned char* args);
43
int colonet_wl_send(short client_source, short dest, ColonetMessageType msg_type, unsigned char msg_code,
44
                    unsigned char* args);
45 45

  
46 46
int colonet_get_num_robots(void);
47 47

  
trunk/code/projects/colonet/ColonetServer/ConnectionPool.cpp
335 335
      }
336 336

  
337 337
      Command command(this);
338
      if (command.parse_command(temporary_command_buffer, pool_index) < 0) {
338
      if (command.parse_command(temporary_command_buffer, pool_index) != 0) {
339 339
	printf("There was an error parsing command\n");
340 340
	break;
341 341
      }
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
150
    char buffer[WRITE_BUFFER_SIZE];
151

  
152
    int value = (int)(data[0]);
153
    snprintf(buffer, WRITE_BUFFER_SIZE, "%d\n", value);
154

  
155
    int buflen = strlen(buffer);
156
    */
157

  
158 148
    //Greg's code
159 149
    char * buffer = (char *) &(data[5]);
160 150
    int buflen = strlen(buffer);
......
218 208

  
219 209
  //get a socket fd
220 210
  if ((listen_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
221
    printf("\tThere was an error creating  socket\n");
211
    printf("\tThere was an error creating socket\n");
222 212
    return -1;
223 213
  }
224 214

  

Also available in: Unified diff