Skip to content
Snippets Groups Projects
Commit 8bac282a authored by John Romein's avatar John Romein
Browse files

bug 225:

RSP format defined.
parent 0b082b81
Branches
Tags
No related merge requests found
......@@ -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;
......
//# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment