21TlmPacketizer ::TlmPacketizer(
const char*
const compName)
22 : TlmPacketizerComponentBase(compName), m_numPackets(0), m_configured(false), m_startLevel(0), m_maxLevel(0) {
25 this->m_tlmEntries.slots[entry] =
nullptr;
29 this->m_tlmEntries.buckets[entry].used =
false;
30 this->m_tlmEntries.buckets[entry].bucketNo = entry;
31 this->m_tlmEntries.buckets[entry].next =
nullptr;
32 this->m_tlmEntries.buckets[entry].id = 0;
35 this->m_tlmEntries.free = 0;
38 this->m_missTlmCheck[entry].checked =
false;
39 this->m_missTlmCheck[entry].id = 0;
44 this->m_fillBuffers[buffer].updated =
false;
45 this->m_fillBuffers[buffer].requested =
false;
46 this->m_sendBuffers[buffer].updated =
false;
51 TlmPacketizerComponentBase::init(queueDepth, instance);
54TlmPacketizer ::~TlmPacketizer() {}
73 TlmEntry* entryToUse = this->findBucket(
id);
76 entryToUse->used =
true;
78 entryToUse->ignored =
false;
81 entryToUse->packetOffset[pktEntry] = packetLen;
83 packetLen += packetList.
list[pktEntry]->
list[tlmEntry].
size;
88 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0, packetLen);
93 stat = this->m_fillBuffers[pktEntry].buffer.serialize(packetList.
list[pktEntry]->
id);
96 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
99 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
101 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
103 if (packetList.
list[pktEntry]->
level > this->m_maxLevel) {
104 this->m_maxLevel = packetList.
list[pktEntry]->
level;
107 this->m_startLevel = startLevel;
116 TlmEntry* entryToUse = this->findBucket(
id);
120 entryToUse->used =
true;
122 entryToUse->ignored =
true;
130 this->m_configured =
true;
133TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(
FwChanIdType id) {
136 TlmEntry* entryToUse =
nullptr;
137 TlmEntry* prevEntry =
nullptr;
140 if (this->m_tlmEntries.slots[index]) {
141 entryToUse = this->m_tlmEntries.slots[index];
144 if (entryToUse->id ==
id) {
147 prevEntry = entryToUse;
148 entryToUse = entryToUse->next;
154 entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
157 prevEntry->next = entryToUse;
159 entryToUse->next =
nullptr;
162 entryToUse->packetOffset[pktOffsetEntry] = -1;
171 this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
172 entryToUse = this->m_tlmEntries.slots[index];
173 entryToUse->next =
nullptr;
176 entryToUse->packetOffset[pktOffsetEntry] = -1;
194 TlmEntry* entryToUse =
nullptr;
197 entryToUse = this->m_tlmEntries.slots[index];
200 if (not entryToUse) {
201 this->missingChannel(
id);
207 if (entryToUse->id ==
id) {
209 if (entryToUse->ignored) {
214 entryToUse = entryToUse->next;
218 this->missingChannel(
id);
226 if (entryToUse->packetOffset[pkt] != -1) {
230 this->m_fillBuffers[pkt].updated =
true;
231 this->m_fillBuffers[pkt].latestTime = timeTag;
232 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
234 this->m_lock.unLock();
243 if (not this->isConnected_PktSend_OutputPort(0)) {
252 if ((this->m_fillBuffers[pkt].updated) and
253 ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or (this->m_fillBuffers[pkt].requested))) {
254 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
256 this->m_fillBuffers[pkt].updated =
false;
258 this->m_fillBuffers[pkt].requested =
false;
261 (this->m_fillBuffers[pkt].level <= this->m_startLevel)) {
262 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
263 this->m_sendBuffers[pkt].updated =
true;
265 this->m_sendBuffers[pkt].updated =
false;
268 this->m_lock.unLock();
272 if (this->m_sendBuffers[pkt].updated) {
275 &this->m_sendBuffers[pkt]
281 this->PktSend_out(0, this->m_sendBuffers[pkt].buffer, 0);
286void TlmPacketizer ::pingIn_handler(
const NATIVE_INT_TYPE portNum, U32 key) {
288 this->pingOut_out(0, key);
295void TlmPacketizer ::SET_LEVEL_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32 level) {
296 this->m_startLevel = level;
297 if (level > this->m_maxLevel) {
298 this->log_WARNING_LO_MaxLevelExceed(level, this->m_maxLevel);
300 this->tlmWrite_SendLevel(level);
301 this->log_ACTIVITY_HI_LevelSet(level);
302 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
305void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32
id) {
307 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
308 if (this->m_fillBuffers[pkt].
id ==
id) {
310 this->m_fillBuffers[pkt].updated =
true;
311 this->m_fillBuffers[pkt].latestTime = this->getTime();
312 this->m_fillBuffers[pkt].requested =
true;
313 this->m_lock.unLock();
315 this->log_ACTIVITY_LO_PacketSent(
id);
321 if (pkt == this->m_numPackets) {
322 log_WARNING_LO_PacketNotFound(
id);
323 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR);
327 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
338 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
340 }
else if (not this->m_missTlmCheck[slot].checked) {
341 this->m_missTlmCheck[slot].checked =
true;
342 this->m_missTlmCheck[slot].id = id;
343 this->log_WARNING_LO_NoChan(
id);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
U32 FwPacketDescriptorType
#define FW_COM_BUFFER_MAX_SIZE
Max size of Fw::Com buffer.
C++-compatible configuration header for fprime configuration.
@ FW_PACKET_PACKETIZED_TLM
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
U8 * getBuffAddr()
gets buffer address for data filling
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const NATIVE_UINT_TYPE startLevel)
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ PACKET_UPDATE_ON_CHANGE
static const NATIVE_UINT_TYPE TLMPACKETIZER_MAX_MISSING_TLM_CHECK
static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_MOD_VALUE
static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_BUCKETS
static const PacketUpdateMode PACKET_UPDATE_MODE
static const NATIVE_UINT_TYPE MAX_PACKETIZER_PACKETS
static const NATIVE_UINT_TYPE TLMPACKETIZER_NUM_TLM_HASH_SLOTS
NATIVE_UINT_TYPE size
serialized size of channel in bytes
FwChanIdType id
Id of channel.
FwTlmPacketizeIdType id
packet ID
NATIVE_UINT_TYPE level
packet level - used to select set of packets to send
const TlmPacketizerChannelEntry * list
pointer to a channel entry
NATIVE_UINT_TYPE numEntries
number of channels in packet
const TlmPacketizerPacket * list[MAX_PACKETIZER_PACKETS]
NATIVE_UINT_TYPE numEntries