Fixed overflow support in SHM communication system.
[aesalon.git] / src / monitor / ZoneReader.cpp
blob5e181ba796556837847f9eb7f0ded08c1e33b02c
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/monitor/ZoneReader.cpp
8 */
10 #include "monitor/ZoneReader.h"
11 #include "shm/PacketHeader.h"
12 #include "util/MessageSystem.h"
14 namespace Monitor {
16 ZoneReader::ZoneReader(SHMReader *shmReader) : m_shmReader(shmReader) {
20 ZoneReader::~ZoneReader() {
24 void ZoneReader::run() {
25 run(this);
28 void *ZoneReader::run(void *voidInstance) {
29 Message(Debug, "Beginning ZoneReader loop . . .");
30 ZoneReader *instance = static_cast<ZoneReader *>(voidInstance);
31 SHMReader *reader = instance->m_shmReader;
32 SHMReader::ReadBroker broker;
34 while(true) {
35 reader->waitForPacket();
36 int32_t zone = reader->zoneWithData();
37 if(zone == -1) break;
39 SHM::PacketHeader *packetHeader;
40 broker.setupRequest(zone, sizeof(SHM::PacketHeader));
41 reader->processRequest(broker);
42 packetHeader = static_cast<SHM::PacketHeader *>(broker.data());
44 uint8_t *packetData;
45 broker.setupRequest(zone, packetHeader->packetSize);
46 reader->processRequest(broker);
47 packetData = static_cast<uint8_t *>(broker.data());
49 Message(Log, "Recieved packet from module " << packetHeader->moduleID << ", size " << packetHeader->packetSize);
52 Message(Debug, "Ending ZoneReader loop . . .");
54 return NULL;
57 } // namespace Monitor