diff --git a/filemonitor.cpp b/filemonitor.cpp index 0d04a71..c55bd7d 100644 --- a/filemonitor.cpp +++ b/filemonitor.cpp @@ -112,6 +112,7 @@ void FileMonitor::run() // We need a mutex or semaphore to lock out this page while we do that // lock p->LoadPage(name); // What if this fails? We can see the bool. What to do ? + p->IncrementUpdateCount(); p->GetPageCount(); // renumber the subpages int mag=(p->GetPageNumber() >> 16) & 0x7; if (p->IsCarousel() && !(p->GetCarouselFlag()) && !(p->Special())) diff --git a/packetmag.cpp b/packetmag.cpp index 8913e2a..729ab25 100644 --- a/packetmag.cpp +++ b/packetmag.cpp @@ -108,16 +108,17 @@ Packet* PacketMag::GetPacket(Packet* p) { _status = _page->GetCarouselPage()->GetPageStatus() & 0x8000; // get transmit flag _region = _page->GetCarouselPage()->GetRegion(); - thisSubcode=_page->GetCarouselPage()->GetSubCode() & 0x000F; // will break if carousel has more than 16 subpages but that would be out of spec anyway. - thisSubcode |= _page->GetCarouselPage()->GetLastPacket() << 8; + thisSubcode = (_page->GetCarouselPage()->GetSubCode() & 0x000F) | (_page->GetCarouselPage()->GetLastPacket() << 8); } else { _status = _page->GetPageStatus() & 0x8000; // get transmit flag _region = _page->GetRegion(); - thisSubcode = _page->GetLastPacket() << 8; // S3 and S4 + thisSubcode = (_page->GetSubCode() & 0x000F) | (_page->GetLastPacket() << 8); } + thisSubcode |= _page->GetUpdateCount() << 4; + /* rules for the control bits are complicated. There are rules to allow the page to be sent as fragments. Since we aren't doing that, all the flags are left clear except for C9 (interrupted sequence) to keep special pages out of rolling headers */ _status |= 0x0010; /* rules for the subcode are really complicated. The S1 nibble should be the sub page number, S2 is a counter that increments when the page is updated, S3 and S4 hold the last row number */ diff --git a/ttxpagestream.cpp b/ttxpagestream.cpp index 971cc5a..dea84ce 100644 --- a/ttxpagestream.cpp +++ b/ttxpagestream.cpp @@ -1,22 +1,24 @@ #include "ttxpagestream.h" TTXPageStream::TTXPageStream() : - _isCarousel(false), - _transitionTime(0), - _CarouselPage(NULL), - _fileStatus(NEW), - _isSpecial(false) + _isCarousel(false), + _transitionTime(0), + _CarouselPage(NULL), + _fileStatus(NEW), + _isSpecial(false), + _updateCount(0) { //ctor } TTXPageStream::TTXPageStream(std::string filename) : - TTXPage(filename), - _isCarousel(false), - _transitionTime(0), - _CarouselPage(NULL), - _fileStatus(NEW), - _isSpecial(false) + TTXPage(filename), + _isCarousel(false), + _transitionTime(0), + _CarouselPage(NULL), + _fileStatus(NEW), + _isSpecial(false), + _updateCount(0) { struct stat attrib; // create a file attribute structure stat(filename.c_str(), &attrib); // get the attributes of the file @@ -88,3 +90,7 @@ bool TTXPageStream::operator==(const TTXPageStream& rhs) const return true; return false; } + +void TTXPageStream::IncrementUpdateCount(){ + _updateCount = (_updateCount + 1) % 8; +} diff --git a/ttxpagestream.h b/ttxpagestream.h index 7745f1c..caa4b85 100644 --- a/ttxpagestream.h +++ b/ttxpagestream.h @@ -47,6 +47,9 @@ class TTXPageStream : public TTXPage bool GetSpecialFlag() { return _isSpecial; } void SetSpecialFlag(bool val) { _isSpecial = val; } + + int GetUpdateCount() {return _updateCount;} + void IncrementUpdateCount(); ///** Access _CurrentPage //* \return The current value of _CurrentPage @@ -142,6 +145,9 @@ class TTXPageStream : public TTXPage bool _Selected; /// Marked as selected by the inserter P command bool _isSpecial; + + int _updateCount; // update counter for special pages. + }; #endif // _TTXPAGESTREAM_H_