Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5802 in orxonox.OLD for branches


Ignore:
Timestamp:
Nov 27, 2005, 7:17:56 PM (19 years ago)
Author:
patrick
Message:

network: some more fixes on the network branche: for testing purpuses, the length of the binary data packet will be hard set to 11bytes.

Location:
branches/network/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_protocol.cc

    r5752 r5802  
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10    
     10
    1111   ### File Specific:
    1212   main-programmer: Benjamin Wuest
     
    6363int NetworkProtocol::createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source, unsigned int remoteID)
    6464{
    65   PRINTF(0)("create header\n");
    66   printf("length = %i, bufferLength = %i\n", length, bufferLength);
     65  printf("NetworkProtocol: create header length = %i, bufferLength = %i\n", length, bufferLength);
    6766  //If there isn't enough space for the header return -1
    6867  if (length + headerLength > bufferLength)
    6968    return -1;
    70  
     69
    7170  //Create space for the header
    7271  for( int i = length - 1; i >= 0; i--)
    7372    data[i + headerLength] = data[i];
    74  
     73
    7574  //Include header
    7675  data[0] = 255;
     76  return length + headerLength;
    7777}
    7878
     
    9494    return h;
    9595  }
    96  
     96
    9797  //Extract header
    9898  Header h;
    9999  h.protocol = data[0];
    100  
     100
    101101  h.length = length - headerLength;
    102102  h.data = data;
    103  
     103
    104104  //Remove header
    105105  for (int i = headerLength; i < length; i++)
    106106    data[i - headerLength] = data[i];
    107  
     107
    108108  return h;
    109109}
  • branches/network/src/lib/network/network_stream.cc

    r5800 r5802  
    106106
    107107  /* send the received data to connectionMonitor */
    108   this->connectionMonitor->processPacket((byte*)downBuffer, ret + sizeof(Header));
     108  this->connectionMonitor->processPacket((byte*)downBuffer, ret);
    109109
    110   this->networkProtocol->createHeader((byte*)downBuffer, ret, DATA_STREAM_BUFFER_SIZE,
    111                                        *(this->synchronizeables), 12);
     110  ret = this->networkProtocol->createHeader((byte*)downBuffer, ret, DATA_STREAM_BUFFER_SIZE,
     111                                            *(this->synchronizeables), 12);
    112112
     113  printf("created header: data packet wights: %i bytes\n", ret);
    113114  /* pass the data to the network socket */
    114   ret = this->networkSocket->writeBytes((byte*)downBuffer, PACKAGE_SIZE + sizeof(Header));
     115  ret = this->networkSocket->writeBytes((byte*)downBuffer, ret);
    115116  /* check if there was an error */
     117  printf("NetworkSocket: sent %i bytes\n", ret);
    116118  if( ret == -1) { PRINTF(0)("Error in writing data to the NetworkSocket\n");}
    117119
     
    123125  PRINT(0)("============== UPSTREAM:================\n");
    124126  /* first of all read  data from networkSocket*/
    125   ret = this->networkSocket->readBlock((byte*)upBuffer, PACKAGE_SIZE + sizeof(Header));
     127  ret = this->networkSocket->readBlock((byte*)upBuffer, 11/* this is very bad: hard coded packet sizes! */);
    126128  /* error checking: data read? */
    127   if( ret != PACKAGE_SIZE + sizeof(Header)) { PRINTF(0)("Error while reading data from the NetworkSocket\n");}
     129  printf("NetworkSocket: received %i bytes\n", ret);
     130  if( ret != PACKAGE_SIZE + sizeof(Header)) { PRINTF(0)("Error while reading data from the NetworkSocket. Skipping further work\n");}
     131  else
     132  {
     133    /* send the received data to connectionMonitor */
     134    this->connectionMonitor->processPacket((byte*)upBuffer, ret);
    128135
    129   /* send the received data to connectionMonitor */
    130   this->connectionMonitor->processPacket((byte*)upBuffer, PACKAGE_SIZE + sizeof(Header));
     136    /* extract Header */
     137    this->networkProtocol->extractHeader((byte*) upBuffer , ret);
    131138
    132   /* extract Header */
    133   this->networkProtocol->extractHeader((byte*) upBuffer , PACKAGE_SIZE + sizeof(Header));
    134 
    135   /* now pass the data to the sync object */
    136   this->synchronizeables->writeBytes((byte*)upBuffer, ret);
     139    /* now pass the data to the sync object */
     140    this->synchronizeables->writeBytes((byte*)upBuffer, ret);
     141  }
    137142
    138143}
  • branches/network/src/subprojects/network/simple_sync.cc

    r5800 r5802  
    9696  for(int i = 0; i < this->recLength; i++)
    9797  {
    98     PRINT(0)(" %i ",this->inData[i]);
     98    PRINT(0)(" [%u] ",this->inData[i]);
    9999  }
    100100  PRINT(0)("|\n");
     
    104104void SimpleSync::readDebug()
    105105{
    106   PRINTF(0)("Read out: |");
     106  PRINTF(0)("Read out bytes: |");
    107107  for(int i = 0; i < this->outLength; i++)
    108108  {
    109     PRINT(0)(" %c ",this->outData[i]);
     109    PRINT(0)(" [%u] ",this->outData[i]);
    110110  }
    111111  PRINT(0)("|\n");
Note: See TracChangeset for help on using the changeset viewer.