--- yoda/techmodel/CalibTrailerReader.cpp 2005/08/29 09:46:13 5.0 +++ yoda/techmodel/CalibTrailerReader.cpp 2006/02/04 12:37:44 5.1 @@ -1,23 +1,13 @@ +/** @file + * $Author: Maurizio Nagni $ + * $Date: 2005/08/29 09:45:48 $ + * $Revision: 5.0 $ + * + * Implementation of the CalibTrailerReader class. + */ -// Implementation of the CalibTrailerReader class. - - -#define UINT unsigned int -#define BYTE unsigned char -#include -#include -extern "C" { -#include -#include "CRC.h" -} - -#include -#include "stdio.h" #include "ReaderAlgorithms.h" -#include "event/CalibTrailerEvent.h" - -using namespace pamela; using namespace pamela::techmodel; static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibTrk1Reader")); @@ -36,7 +26,7 @@ */ std::string CalibTrailerReader::GetVersionInfo(void) const { return - "$Trailer: /home/cvsmanager/yoda/techmodel/CalibTrailerReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n"; + "$Trailer: /home/cvsmanager/yoda/techmodel/CalibTrailerReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 Maurizio Nagni Exp $\n"; } /** @@ -52,8 +42,16 @@ /** * Unpack the CalibTrailer event from an input file. */ -void CalibTrailerReader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){ - - +void CalibTrailerReader::RunEvent(int EventNumber, long int dataLength) throw (WrongCRCException){ + char subData[dataLength]; + UINT16 subCRC; //calculated CRC of the data + UINT16 readCRC; //CRC read from the end of the subpacket + long int length = dataLength - 2; //the block of data + + InputFile->read(subData, sizeof(subData)); + subCRC = CM_Compute_CRC16(0, (UINT8*)subData, length); + readCRC = (((UINT16)(subData[dataLength - 2]<<8))&0xFF00) + (((UINT16)subData[dataLength - 1])&0x00FF); + + if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibTrailer Packet "); }