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;
64 FW_ASSERT(packetList.
list[pktEntry]->
list, static_cast<FwAssertArgType>(pktEntry));
69 TlmEntry* entryToUse = this->findBucket(
id);
72 entryToUse->used =
true;
74 entryToUse->ignored =
false;
76 entryToUse->hasValue =
false;
77 entryToUse->channelSize = packetList.
list[pktEntry]->
list[tlmEntry].
size;
80 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
81 static_cast<FwAssertArgType>(packetLen));
82 entryToUse->packetOffset[pktEntry] =
static_cast<FwSignedSizeType>(packetLen);
84 packetLen += entryToUse->channelSize;
88 static_cast<FwAssertArgType>(pktEntry));
90 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
93 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
95 stat = this->m_fillBuffers[pktEntry].buffer.serialize(packetList.
list[pktEntry]->
id);
98 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
101 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
103 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
105 if (packetList.
list[pktEntry]->
level > this->m_maxLevel) {
106 this->m_maxLevel = packetList.
list[pktEntry]->
level;
109 this->m_startLevel = startLevel;
118 TlmEntry* entryToUse = this->findBucket(
id);
122 entryToUse->used =
true;
124 entryToUse->ignored =
true;
126 entryToUse->hasValue =
false;
127 entryToUse->channelSize = ignoreList.
list[channelEntry].
size;
134 this->m_configured =
true;
137 TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(
FwChanIdType id) {
140 TlmEntry* entryToUse =
nullptr;
141 TlmEntry* prevEntry =
nullptr;
144 if (this->m_tlmEntries.slots[index]) {
145 entryToUse = this->m_tlmEntries.slots[index];
148 if (entryToUse->id ==
id) {
151 prevEntry = entryToUse;
152 entryToUse = entryToUse->next;
157 static_cast<FwAssertArgType>(this->m_tlmEntries.free));
159 entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
162 prevEntry->next = entryToUse;
164 entryToUse->next =
nullptr;
167 entryToUse->packetOffset[pktOffsetEntry] = -1;
175 static_cast<FwAssertArgType>(this->m_tlmEntries.free));
177 this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
178 entryToUse = this->m_tlmEntries.slots[index];
179 entryToUse->next =
nullptr;
182 entryToUse->packetOffset[pktOffsetEntry] = -1;
193 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
200 TlmEntry* entryToUse =
nullptr;
203 entryToUse = this->m_tlmEntries.slots[index];
206 if (not entryToUse) {
207 this->missingChannel(
id);
213 if (entryToUse->id ==
id) {
215 if (entryToUse->ignored) {
220 entryToUse = entryToUse->next;
224 this->missingChannel(
id);
232 if (entryToUse->packetOffset[pkt] != -1) {
235 this->m_fillBuffers[pkt].updated =
true;
236 this->m_fillBuffers[pkt].latestTime = timeTag;
237 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
241 entryToUse->hasValue =
true;
257 TlmEntry* entryToUse =
nullptr;
260 entryToUse = this->m_tlmEntries.slots[index];
263 if (not entryToUse) {
264 this->missingChannel(
id);
271 if (entryToUse->id ==
id) {
274 if (entryToUse->ignored) {
280 entryToUse = entryToUse->next;
284 this->missingChannel(
id);
290 if (!entryToUse->hasValue) {
305 if (entryToUse->packetOffset[pkt] != -1) {
308 timeTag = this->m_fillBuffers[pkt].latestTime;
309 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
310 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entryToUse->channelSize));
321 FW_ASSERT(0, static_cast<FwAssertArgType>(entryToUse->id));
327 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
339 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
340 if ((this->m_fillBuffers[pkt].updated) and
341 ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or (this->m_fillBuffers[pkt].requested))) {
342 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
344 this->m_fillBuffers[pkt].updated =
false;
346 this->m_fillBuffers[pkt].requested =
false;
349 (this->m_fillBuffers[pkt].level <= this->m_startLevel)) {
350 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
351 this->m_sendBuffers[pkt].updated =
true;
353 this->m_sendBuffers[pkt].updated =
false;
359 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
360 if (this->m_sendBuffers[pkt].updated) {
363 &this->m_sendBuffers[pkt]
369 this->
PktSend_out(0, this->m_sendBuffers[pkt].buffer, 0);
374 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
384 this->m_startLevel = level;
385 if (level > this->m_maxLevel) {
393 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32
id) {
395 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
396 if (this->m_fillBuffers[pkt].
id ==
id) {
398 this->m_fillBuffers[pkt].updated =
true;
399 this->m_fillBuffers[pkt].latestTime = this->
getTime();
400 this->m_fillBuffers[pkt].requested =
true;
409 if (pkt == this->m_numPackets) {
426 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
428 }
else if (not this->m_missTlmCheck[slot].checked) {
429 this->m_missTlmCheck[slot].checked =
true;
430 this->m_missTlmCheck[slot].id = id;
Serialization/Deserialization operation was successful.
TlmPacketizer(const char *const compName)
FwIdType FwOpcodeType
The type of a command opcode.
FwIdType FwPacketDescriptorType
The type of a com packet descriptor.
FwSizeType size
serialized size of channel in bytes
PlatformSizeType FwSizeType
FwTlmPacketizeIdType id
packet ID
void resetSer()
reset to beginning of buffer to reuse for serialization
static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
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
FwSizeType getBuffCapacity() const
returns capacity, not current size, of buffer
FwChanIdType id
Id of channel.
FwChanIdType level
packet level - used to select set of packets to send
Serializable::SizeType getBuffLength() const
returns current buffer size
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()
gets buffer address for data filling
void log_WARNING_LO_PacketNotFound(U32 id) const
#define FW_COM_BUFFER_MAX_SIZE
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
void log_ACTIVITY_HI_LevelSet(FwChanIdType id) const
Command failed validation.
RateGroupDivider component implementation.
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
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
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
Auto-generated base for TlmPacketizer component.