26 this->m_tlmEntries.slots[entry] =
nullptr;
30 this->m_tlmEntries.buckets[entry].used =
false;
31 this->m_tlmEntries.buckets[entry].bucketNo = entry;
32 this->m_tlmEntries.buckets[entry].next =
nullptr;
33 this->m_tlmEntries.buckets[entry].id = 0;
36 this->m_tlmEntries.free = 0;
39 this->m_missTlmCheck[entry].checked =
false;
40 this->m_missTlmCheck[entry].id = 0;
45 this->m_fillBuffers[buffer].updated =
false;
46 this->m_fillBuffers[buffer].requested =
false;
47 this->m_sendBuffers[buffer].updated =
false;
65 FW_ASSERT(packetList.
list[pktEntry]->
list, static_cast<FwAssertArgType>(pktEntry));
70 TlmEntry* entryToUse = this->findBucket(
id);
73 entryToUse->used =
true;
75 entryToUse->ignored =
false;
77 entryToUse->hasValue =
false;
78 entryToUse->channelSize = packetList.
list[pktEntry]->
list[tlmEntry].
size;
81 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
82 static_cast<FwAssertArgType>(packetLen));
83 entryToUse->packetOffset[pktEntry] =
static_cast<FwSignedSizeType>(packetLen);
85 packetLen += entryToUse->channelSize;
89 static_cast<FwAssertArgType>(pktEntry));
91 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
94 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
96 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
99 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
102 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
104 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
106 if (packetList.
list[pktEntry]->
level > this->m_maxLevel) {
107 this->m_maxLevel = packetList.
list[pktEntry]->
level;
110 this->m_startLevel = startLevel;
119 TlmEntry* entryToUse = this->findBucket(
id);
123 entryToUse->used =
true;
125 entryToUse->ignored =
true;
127 entryToUse->hasValue =
false;
128 entryToUse->channelSize = ignoreList.
list[channelEntry].
size;
135 this->m_configured =
true;
138 TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(
FwChanIdType id) {
141 TlmEntry* entryToUse =
nullptr;
142 TlmEntry* prevEntry =
nullptr;
145 if (this->m_tlmEntries.slots[index]) {
146 entryToUse = this->m_tlmEntries.slots[index];
149 if (entryToUse->id ==
id) {
152 prevEntry = entryToUse;
153 entryToUse = entryToUse->next;
158 static_cast<FwAssertArgType>(this->m_tlmEntries.free));
160 entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
163 prevEntry->next = entryToUse;
165 entryToUse->next =
nullptr;
168 entryToUse->packetOffset[pktOffsetEntry] = -1;
176 static_cast<FwAssertArgType>(this->m_tlmEntries.free));
178 this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
179 entryToUse = this->m_tlmEntries.slots[index];
180 entryToUse->next =
nullptr;
183 entryToUse->packetOffset[pktOffsetEntry] = -1;
194 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
201 TlmEntry* entryToUse =
nullptr;
204 entryToUse = this->m_tlmEntries.slots[index];
207 if (not entryToUse) {
208 this->missingChannel(
id);
214 if (entryToUse->id ==
id) {
216 if (entryToUse->ignored) {
221 entryToUse = entryToUse->next;
225 this->missingChannel(
id);
233 if (entryToUse->packetOffset[pkt] != -1) {
236 this->m_fillBuffers[pkt].updated =
true;
237 this->m_fillBuffers[pkt].latestTime = timeTag;
238 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
242 entryToUse->hasValue =
true;
258 TlmEntry* entryToUse =
nullptr;
261 entryToUse = this->m_tlmEntries.slots[index];
264 if (not entryToUse) {
265 this->missingChannel(
id);
272 if (entryToUse->id ==
id) {
275 if (entryToUse->ignored) {
281 entryToUse = entryToUse->next;
285 this->missingChannel(
id);
291 if (!entryToUse->hasValue) {
306 if (entryToUse->packetOffset[pkt] != -1) {
309 timeTag = this->m_fillBuffers[pkt].latestTime;
310 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
311 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entryToUse->channelSize));
322 FW_ASSERT(0, static_cast<FwAssertArgType>(entryToUse->id));
328 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
340 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
341 if ((this->m_fillBuffers[pkt].updated) and
342 ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or (this->m_fillBuffers[pkt].requested))) {
343 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
345 this->m_fillBuffers[pkt].updated =
false;
347 this->m_fillBuffers[pkt].requested =
false;
350 (this->m_fillBuffers[pkt].level <= this->m_startLevel)) {
351 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
352 this->m_sendBuffers[pkt].updated =
true;
354 this->m_sendBuffers[pkt].updated =
false;
360 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
361 if (this->m_sendBuffers[pkt].updated) {
364 &this->m_sendBuffers[pkt]
370 this->
PktSend_out(0, this->m_sendBuffers[pkt].buffer, 0);
375 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
385 this->m_startLevel = level;
386 if (level > this->m_maxLevel) {
394 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32
id) {
396 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
397 if (this->m_fillBuffers[pkt].
id ==
id) {
399 this->m_fillBuffers[pkt].updated =
true;
400 this->m_fillBuffers[pkt].latestTime = this->
getTime();
401 this->m_fillBuffers[pkt].requested =
true;
410 if (pkt == this->m_numPackets) {
427 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
429 }
else if (not this->m_missTlmCheck[slot].checked) {
430 this->m_missTlmCheck[slot].checked =
true;
431 this->m_missTlmCheck[slot].id = id;
Serialization/Deserialization operation was successful.
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
TlmPacketizer(const char *const compName)
FwIdType FwOpcodeType
The type of a command opcode.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
FwSizeType size
serialized size of channel in bytes
PlatformSizeType FwSizeType
FwTlmPacketizeIdType id
packet ID
static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS
Serializable::SizeType getSize() const override
Get current buffer size.
const TlmPacketizerPacket * list[MAX_PACKETIZER_PACKETS]
void log_WARNING_LO_NoChan(FwChanIdType Id) const
static const FwChanIdType MAX_PACKETIZER_PACKETS
void unLock()
unlock the mutex and assert success
PlatformSignedSizeType FwSignedSizeType
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port PktSend.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
static const FwChanIdType TLMPACKETIZER_NUM_TLM_HASH_SLOTS
const TlmPacketizerChannelEntry * list
pointer to a channel entry
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK
void tlmWrite_SendLevel(FwChanIdType arg, Fw::Time _tlmTime=Fw::Time()) const
SerializeStatus
forward declaration for string
FwChanIdType id
Id of channel.
FwChanIdType level
packet level - used to select set of packets to send
static const PacketUpdateMode PACKET_UPDATE_MODE
External serialize buffer with no copy semantics.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
static const FwChanIdType TLMPACKETIZER_HASH_MOD_VALUE
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
void log_WARNING_LO_PacketNotFound(U32 id) const
void resetSer() override
Reset serialization pointer to beginning of buffer.
U16 FwTlmPacketizeIdType
The type of a telemetry packet identifier.
Command successfully executed.
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const FwChanIdType startLevel)
uint8_t U8
8-bit unsigned integer
void log_WARNING_LO_MaxLevelExceed(FwChanIdType level, FwChanIdType max) const
PlatformIndexType FwIndexType
FwSizeType getCapacity() const
Get buffer capacity.
void log_ACTIVITY_HI_LevelSet(FwChanIdType id) const
Command failed validation.
RateGroupDivider component implementation.
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
FwChanIdType numEntries
number of channels in packet
void log_ACTIVITY_LO_PacketSent(U32 id) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
void lock()
lock the mutex and assert success
Auto-generated base for TlmPacketizer component.