From 8bac282a56e409ba9ca197bd511ff6de112c0141 Mon Sep 17 00:00:00 2001 From: John Romein <romein@astron.nl> Date: Tue, 19 Aug 2008 19:32:31 +0000 Subject: [PATCH] bug 225: RSP format defined. --- Appl/CEP/CS1/CS1_IONProc/src/InputThread.cc | 14 +++--- Appl/CEP/CS1/CS1_IONProc/src/RSP.h | 52 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 Appl/CEP/CS1/CS1_IONProc/src/RSP.h diff --git a/Appl/CEP/CS1/CS1_IONProc/src/InputThread.cc b/Appl/CEP/CS1/CS1_IONProc/src/InputThread.cc index 85ee0bab8f9..77eac6d55d1 100644 --- a/Appl/CEP/CS1/CS1_IONProc/src/InputThread.cc +++ b/Appl/CEP/CS1/CS1_IONProc/src/InputThread.cc @@ -33,6 +33,7 @@ #include <Stream/SystemCallException.h> #include <BeamletBuffer.h> #include <InputThread.h> +#include <RSP.h> #include <errno.h> #include <signal.h> @@ -135,12 +136,12 @@ void InputThread::mainLoop() setAffinity(); TimeStamp actualstamp = itsArgs.startTime - itsArgs.nrTimesPerPacket; - unsigned packetSize = 16 + itsArgs.nrSubbandsPerPacket * itsArgs.nrTimesPerPacket * sizeof(Beamlet); + unsigned packetSize = sizeof(struct RSP::header) + itsArgs.nrSubbandsPerPacket * itsArgs.nrTimesPerPacket * sizeof(Beamlet); unsigned previousSeqid = 0; bool previousSeqidIsAccepted = false; - char packet[8192] __attribute__ ((aligned(16))); // Max RSP packet size + RSP packet __attribute__ ((aligned(16))); // Max RSP packet size bool dataShouldContainValidStamp = dynamic_cast<NullStream *>(itsArgs.stream) == 0; @@ -153,7 +154,7 @@ void InputThread::mainLoop() // interruptible read, to allow stopping this thread even if the station // does not send data - itsArgs.stream->read(packet, packetSize); + itsArgs.stream->read(&packet, packetSize); } catch (SystemCallException &ex) { if (ex.error == EINTR) break; @@ -163,10 +164,9 @@ void InputThread::mainLoop() ++ itsArgs.packetCounters->nrPacketsReceived; - // get the actual timestamp of first EPApacket in frame if (dataShouldContainValidStamp) { - unsigned seqid = * reinterpret_cast<unsigned *>(packet + 8); - unsigned blockid = * reinterpret_cast<unsigned *>(packet + 12); + unsigned seqid = packet.header.timestamp; + unsigned blockid = packet.header.blockSequenceNumber; #if defined WORDS_BIGENDIAN seqid = byteSwap(seqid); @@ -203,7 +203,7 @@ void InputThread::mainLoop() } // expected packet received so write data into corresponding buffer - itsArgs.BBuffer->writePacketData(reinterpret_cast<Beamlet *>(packet + 16), actualstamp); + itsArgs.BBuffer->writePacketData(reinterpret_cast<Beamlet *>(&packet.data), actualstamp); } std::clog << "InputThread::mainLoop() exiting loop" << std::endl; diff --git a/Appl/CEP/CS1/CS1_IONProc/src/RSP.h b/Appl/CEP/CS1/CS1_IONProc/src/RSP.h new file mode 100644 index 00000000000..dde4491ca69 --- /dev/null +++ b/Appl/CEP/CS1/CS1_IONProc/src/RSP.h @@ -0,0 +1,52 @@ +//# RSP: RSP data format +//# +//# Copyright (C) 2008 +//# 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 +//# +//# $Id$ + +#ifndef LOFAR_CS1_ION_PROC_RSP_H +#define LOFAR_CS1_ION_PROC_RSP_H + + +namespace LOFAR { +namespace CS1 { + +#include <cstddef> + + +// All data is in Little Endian format! + +struct RSP { + struct header { + uint16_t version; + uint16_t configuration; + uint16_t station; + uint8_t nrBeamlets; + uint8_t nrBlocks; + uint32_t timestamp; + uint32_t blockSequenceNumber; + } header; + + char data[8130]; +}; + +} // namespace CS1 +} // namespace LOFAR + +#endif -- GitLab