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;
69 TlmEntry* entryToUse = this->findBucket(
id);
72 entryToUse->used =
true;
74 entryToUse->ignored =
false;
77 entryToUse->packetOffset[pktEntry] =
static_cast<NATIVE_INT_TYPE>(packetLen);
79 packetLen += packetList.
list[pktEntry]->
list[tlmEntry].
size;
84 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0, packetLen);
89 stat = this->m_fillBuffers[pktEntry].buffer.serialize(packetList.
list[pktEntry]->
id);
92 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
95 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
97 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
99 if (packetList.
list[pktEntry]->
level > this->m_maxLevel) {
100 this->m_maxLevel = packetList.
list[pktEntry]->
level;
103 this->m_startLevel = startLevel;
112 TlmEntry* entryToUse = this->findBucket(
id);
116 entryToUse->used =
true;
118 entryToUse->ignored =
true;
126 this->m_configured =
true;
129 TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(
FwChanIdType id) {
132 TlmEntry* entryToUse =
nullptr;
133 TlmEntry* prevEntry =
nullptr;
136 if (this->m_tlmEntries.slots[index]) {
137 entryToUse = this->m_tlmEntries.slots[index];
140 if (entryToUse->id ==
id) {
143 prevEntry = entryToUse;
144 entryToUse = entryToUse->next;
150 entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
153 prevEntry->next = entryToUse;
155 entryToUse->next =
nullptr;
158 entryToUse->packetOffset[pktOffsetEntry] = -1;
167 this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
168 entryToUse = this->m_tlmEntries.slots[index];
169 entryToUse->next =
nullptr;
172 entryToUse->packetOffset[pktOffsetEntry] = -1;
190 TlmEntry* entryToUse =
nullptr;
193 entryToUse = this->m_tlmEntries.slots[index];
196 if (not entryToUse) {
197 this->missingChannel(
id);
203 if (entryToUse->id ==
id) {
205 if (entryToUse->ignored) {
210 entryToUse = entryToUse->next;
214 this->missingChannel(
id);
222 if (entryToUse->packetOffset[pkt] != -1) {
226 this->m_fillBuffers[pkt].updated =
true;
227 this->m_fillBuffers[pkt].latestTime = timeTag;
228 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
235 void TlmPacketizer ::Run_handler(
const NATIVE_INT_TYPE portNum, U32 context) {
248 if ((this->m_fillBuffers[pkt].updated) and
249 ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or (this->m_fillBuffers[pkt].requested))) {
250 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
252 this->m_fillBuffers[pkt].updated =
false;
254 this->m_fillBuffers[pkt].requested =
false;
257 (this->m_fillBuffers[pkt].level <= this->m_startLevel)) {
258 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
259 this->m_sendBuffers[pkt].updated =
true;
261 this->m_sendBuffers[pkt].updated =
false;
268 if (this->m_sendBuffers[pkt].updated) {
271 &this->m_sendBuffers[pkt]
277 this->
PktSend_out(0, this->m_sendBuffers[pkt].buffer, 0);
282 void TlmPacketizer ::pingIn_handler(
const NATIVE_INT_TYPE portNum, U32 key) {
291 void TlmPacketizer ::SET_LEVEL_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32 level) {
292 this->m_startLevel = level;
293 if (level > this->m_maxLevel) {
301 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq, U32
id) {
303 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
304 if (this->m_fillBuffers[pkt].
id ==
id) {
306 this->m_fillBuffers[pkt].updated =
true;
307 this->m_fillBuffers[pkt].latestTime = this->
getTime();
308 this->m_fillBuffers[pkt].requested =
true;
317 if (pkt == this->m_numPackets) {
334 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
336 }
else if (not this->m_missTlmCheck[slot].checked) {
337 this->m_missTlmCheck[slot].checked =
true;
338 this->m_missTlmCheck[slot].id = id;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
PlatformAssertArgType FwAssertArgType
U32 FwPacketDescriptorType
#define FW_COM_BUFFER_MAX_SIZE
C++-compatible configuration header for fprime configuration.
@ VALIDATION_ERROR
Command failed validation.
@ OK
Command successfully executed.
@ FW_PACKET_PACKETIZED_TLM
External serialize buffer with no copy semantics.
Serializable::SizeType getBuffLength() const
returns current buffer size
U8 * getBuffAddr()
gets buffer address for data filling
void unLock()
unlock the mutex and assert success
void lock()
lock the mutex and assert success
Auto-generated base for TlmPacketizer component.
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.
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
void tlmWrite_SendLevel(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_LO_PacketNotFound(U32 id)
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_WARNING_LO_NoChan(U32 Id)
void log_ACTIVITY_LO_PacketSent(U32 id)
void log_ACTIVITY_HI_LevelSet(U32 id)
void log_WARNING_LO_MaxLevelExceed(U32 level, U32 max)
TlmPacketizer(const char *const compName)
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