Skip to content
Snippets Groups Projects
Commit 8242cff1 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #2669: Added printRSP tool to dump the header of the first RSP packet on stdin

parent 47cfdcb2
No related branches found
No related tags found
No related merge requests found
......@@ -3939,6 +3939,7 @@ RTCP/Cobalt/InputProc/src/Station/PacketsToBuffer.cc -text
RTCP/Cobalt/InputProc/src/Station/PacketsToBuffer.h -text
RTCP/Cobalt/InputProc/src/Station/RSP.h -text
RTCP/Cobalt/InputProc/src/Station/filterRSP.cc -text
RTCP/Cobalt/InputProc/src/Station/printRSP.cc -text
RTCP/Cobalt/InputProc/src/Transpose/MPITransferStations.h -text
RTCP/Cobalt/InputProc/src/Transpose/MPITransferStations.tcc -text
RTCP/Cobalt/InputProc/src/WallClockTime.h -text
......
......@@ -18,3 +18,4 @@ lofar_add_library(inputproc
lofar_add_bin_program(newInputSection newInputSection.cc)
lofar_add_bin_program(filterRSP Station/filterRSP.cc)
lofar_add_bin_program(printRSP Station/printRSP.cc)
//# printRSP.cc: print one RSP header retrieved from stdin
//#
//# Copyright (C) 2009
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//# Always #include <lofar_config.h> first!
#include <lofar_config.h>
#include <Station/RSP.h>
#include <CoInterface/RSPTimeStamp.h>
#include <Common/LofarLogger.h>
#include <Common/DataConvert.h>
#include <Stream/FileStream.h>
#include <time.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace LOFAR;
using namespace LOFAR::RTCP;
using namespace std;
void report( const string &filename )
{
FileStream f(filename);
struct RSP packet;
// read header
f.read( &packet.header, sizeof (RSP::Header) );
#ifdef WORDS_BIGENDIAN
dataConvert(LittleEndian, packet.header.configuration);
dataConvert(LittleEndian, packet.header.timestamp);
dataConvert(LittleEndian, packet.header.blockSequenceNumber);
#endif
TimeStamp timeStamp = packet.timeStamp();
time_t seconds = timeStamp.getSeqId();
char buf[26];
ctime_r(&seconds, buf);
buf[strlen(buf) -1] = 0; // remove trailing \n
cout << "Time stamp: " << buf << " sample " << timeStamp.getBlockId() << endl;
cout << "RSP version: " << (int)packet.header.version << endl;
cout << "RSP board nr: " << packet.rspBoard() << endl;
cout << "Payload OK: " << (packet.payloadError() ? "NO" : "YES") << endl;
cout << "Clock: " << packet.clockMHz() << " MHz" << endl;
cout << "Bit mode: " << packet.bitMode() << " bit" << endl;
cout << "Blocks: " << (int)packet.header.nrBlocks << endl;
cout << "Beamlets: " << (int)packet.header.nrBeamlets << endl;
// read payload
f.read( &packet.payload, packet.packetSize() - sizeof (RSP::Header) );
#ifdef WORDS_BIGENDIAN
if (packet.bitMode() == 16)
dataConvert(LittleEndian, (int16*)&packet.payload, packet.header.nrBlocks * packet.header.nrBeamlets * 2 * 2);
#endif
}
int main()
{
INIT_LOGGER("printRSP");
report("/dev/stdin");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment