Ignore:
Timestamp:
01/11/11 14:44:34 (12 years ago)
Author:
ogrimm
Message:
Corrupt events (wrong start-package flag) are removed from internal buffer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FADBoard.cc

    r10080 r10099  
    182182
    183183  static char Buffer[READ_BUFFER_SIZE];
    184   static unsigned int Pos = 0;
     184  static unsigned int Pos = 0, Temp;
    185185  const PEVNT_HEADER *Header = (PEVNT_HEADER *) Buffer;
    186186  ssize_t Result;
     
    218218        }
    219219       
    220         // Check if full event available in buffer
    221         if (Pos < sizeof(PEVNT_HEADER) || ntohs(Header->start_package_flag) != 0xfb01) continue;
     220        // Check if buffer starts with start_package_flag, remove data if not
     221        Temp = 0;
     222        while (ntohs(Header->start_package_flag) != 0xfb01 && Pos > 0) {
     223          memmove(Buffer, Buffer+1, Pos-1);
     224          Pos--;
     225          Temp++;
     226        }
     227        if (Temp != 0) {
     228          printf("Removed %d bytes because of start_package_flag not found\n", Temp);
     229          continue;
     230        }
     231
     232        // Wait until the buffer contains at least enough bytes to potentially hold a PEVNT_HEADER
     233        if (Pos < sizeof(PEVNT_HEADER)) continue;
    222234       
    223235        unsigned int Length = ntohs(Header->package_length)*2*sizeof(char);
Note: See TracChangeset for help on using the changeset viewer.