diff --git a/packetmag.cpp b/packetmag.cpp index c20754c..e974766 100644 --- a/packetmag.cpp +++ b/packetmag.cpp @@ -15,9 +15,14 @@ PacketMag::PacketMag(uint8_t mag, std::list* pageSet, ttx::Config _priorityCount(priority), _state(PACKETSTATE_HEADER), _thisRow(0), - _lastTxt(nullptr) + _lastTxt(nullptr), + _nextPacket29DC(0) { //ctor + for (int i=0;isize()>0) { //std::cerr << "[Mag::Mag] enters. page size=" << _pageSet->size() << std::endl; @@ -44,7 +49,9 @@ Packet* PacketMag::GetPacket(Packet* p) unsigned int thisSubcode; int thisStatus; int* links=NULL; - + TTXLine* tempLine; + int Packet29Index; + static vbit::Packet* filler=new Packet(8,25," "); // filler // We should only call GetPacket if IsReady has returned true @@ -62,13 +69,32 @@ Packet* PacketMag::GetPacket(Packet* p) // If there is no page, we should send a filler if (_pageSet->size()<1) { - p->SetMRAG(8,25); // we set the MRAG but the contents of pkt is still whatever the last packet was. - return filler; + p->Set_packet(filler->Get_packet()); + return p; } switch (_state) { case PACKETSTATE_HEADER: // Start to send out a new page, which may be a simple page or one of a carousel + if (GetEvent(EVENT_PACKET_29)) + { + while (_packet29[_nextPacket29DC] == nullptr) + { + _nextPacket29DC++; + } + + if (_nextPacket29DC >= MAXPACKET29TYPES) + { + _nextPacket29DC = 0; + ClearEvent(EVENT_PACKET_29); + } + else + { + p->SetRow(_magNumber, 29, _packet29[_nextPacket29DC]->GetLine(), CODING_13_TRIPLETS); + _nextPacket29DC++; + return p; + } + } if (GetEvent(EVENT_SPECIAL_PAGES)) { _page=_specialPages->NextPage(); @@ -84,7 +110,8 @@ Packet* PacketMag::GetPacket(Packet* p) } /* 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 */ - thisStatus=0x8010; + thisStatus = _page->GetPageStatus() & 0x8000; // get transmit flag + thisStatus |= 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 that will be transmitted for this page which needs calculating somehow. */ if (_page->IsCarousel()) @@ -208,6 +235,38 @@ Packet* PacketMag::GetPacket(Packet* p) } } + tempLine = _page->GetTxRow(29); + while (tempLine != nullptr) + { + // TODO: we don't want to do this every time the page is encountered. We should do it once then check to see if it has changed + // Other issues include: multiple pages with packets 29 will overwrite each other, and when the page is deleted the packets will remain. + //std::cerr << "page includes packet 29" << std::endl; + switch (tempLine->GetCharAt(0)) + { + case '@': + Packet29Index = 0; + break; + case 'A': + Packet29Index = 1; + break; + case 'D': + Packet29Index = 2; + break; + default: + Packet29Index = -1; + } + if (Packet29Index > -1) + { + if (_packet29[Packet29Index]==nullptr) + _packet29[Packet29Index]=new TTXLine(tempLine->GetLine(),true); // Didn't exist before + else + _packet29[Packet29Index]->Setm_textline(tempLine->GetLine(), true); + } + + tempLine = tempLine->GetNextLine(); + // loop until every row 29 is copied + } + if (!(thisStatus & 0x8000)) { _page=nullptr; diff --git a/packetmag.h b/packetmag.h index 4aaf860..a070ac0 100644 --- a/packetmag.h +++ b/packetmag.h @@ -7,6 +7,8 @@ #include "specialpages.h" #include "configure.h" +#define MAXPACKET29TYPES 3 + namespace vbit { @@ -44,7 +46,9 @@ class PacketMag : public PacketSource uint8_t _thisRow; // The current line that we are outputting TTXLine* _lastTxt; // The text of the last row that we fetched. Used for enhanced packets - + TTXLine* _packet29[MAXPACKET29TYPES]; // space to store magazine related enhancement packets + TTXLine* _nextPacket29; + int _nextPacket29DC; }; } diff --git a/packetsource.h b/packetsource.h index 8cd52c8..cf7a8f6 100644 --- a/packetsource.h +++ b/packetsource.h @@ -73,7 +73,8 @@ enum Event EVENT_SUBTITLE, EVENT_DATABROADCAST, EVENT_NUMBER_ITEMS, - EVENT_SPECIAL_PAGES + EVENT_SPECIAL_PAGES, + EVENT_PACKET_29 } ; diff --git a/service.cpp b/service.cpp index 6cabf32..36225d7 100644 --- a/service.cpp +++ b/service.cpp @@ -151,6 +151,7 @@ void Service::_updateEvents() for (std::list::const_iterator iterator = _Sources.begin(), end = _Sources.end(); iterator != end; ++iterator) { (*iterator)->SetEvent(EVENT_SPECIAL_PAGES); + (*iterator)->SetEvent(EVENT_PACKET_29); } } // if (seconds>30) exit(0); // JUST FOR DEBUGGING!!!! Must remove diff --git a/ttxpage.h b/ttxpage.h index 05abbf5..52a5886 100644 --- a/ttxpage.h +++ b/ttxpage.h @@ -32,7 +32,7 @@ #define PAGESTATUS_C11_SERIALMAG 0x0040 // Allow for enhancement packets -#define MAXROW 28 +#define MAXROW 29 // @todo more page codings enum PageCoding {CODING_7BIT_TEXT,CODING_8BIT_DATA,CODING_13_TRIPLETS,CODING_HAMMING_8_4};