19 const TlmPacketizer_TelemetrySendPortMap TlmPacketizer::TELEMETRY_SEND_PORT_MAP = {};
33 this->m_missTlmCheck[entry].checked =
false;
34 this->m_missTlmCheck[entry].id = 0;
39 this->m_fillBuffers[buffer].updated =
false;
43 "NUM_CONFIGURABLE_TLMPACKETIZER_GROUPS MUST BE MAX_CONFIGURABLE_TLMPACKETIZER_GROUP + 1");
59 this->m_numChannels = 0;
60 this->m_channelIndices.
clear();
61 this->m_configured =
false;
70 FW_ASSERT(packetList.
list[pktEntry]->
list !=
nullptr, static_cast<FwAssertArgType>(pktEntry));
78 entryIndex = this->m_numChannels++;
79 this->m_channels[entryIndex].id = id;
80 this->m_channels[entryIndex].hasValue =
false;
81 this->m_channels[entryIndex].channelSize = channelSize;
83 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
91 FW_ASSERT(this->m_channels[entryIndex].channelSize == channelSize, static_cast<FwAssertArgType>(
id),
92 static_cast<FwAssertArgType>(channelSize),
93 static_cast<FwAssertArgType>(this->m_channels[entryIndex].channelSize));
96 TlmEntry& entry = this->m_channels[entryIndex];
97 entry.ignored =
false;
98 entry.channelSize = channelSize;
101 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
102 static_cast<FwAssertArgType>(packetLen));
105 packetLen += entry.channelSize;
109 static_cast<FwAssertArgType>(pktEntry));
111 (void)memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
114 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
116 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
119 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
122 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
124 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
126 if (packetList.
list[pktEntry]->
level > maxLevel) {
127 maxLevel = packetList.
list[pktEntry]->
level;
141 entryIndex = this->m_numChannels++;
142 this->m_channels[entryIndex].id = id;
143 this->m_channels[entryIndex].hasValue =
false;
145 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
151 FW_ASSERT(this->m_channels[entryIndex].ignored, static_cast<FwAssertArgType>(
id));
154 TlmEntry& entry = this->m_channels[entryIndex];
155 entry.ignored =
true;
156 entry.channelSize = ignoreList.
list[channelEntry].
size;
163 this->m_configured =
true;
170 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
180 this->missingChannel(
id);
184 TlmEntry& entry = this->m_channels[entryIndex];
192 entry.hasValue =
true;
195 if (entry.packetOffset[pkt] != -1) {
198 this->m_fillBuffers[pkt].updated =
true;
199 this->m_fillBuffers[pkt].latestTime = timeTag;
200 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
203 static_cast<FwAssertArgType>(entry.channelSize));
211 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
217 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
233 this->missingChannel(
id);
237 const TlmEntry& entry = this->m_channels[entryIndex];
246 if (!entry.hasValue) {
261 if (entry.packetOffset[pkt] != -1) {
264 timeTag = this->m_fillBuffers[pkt].latestTime;
265 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
266 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
278 FW_ASSERT(
false, static_cast<FwAssertArgType>(entry.id));
284 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
287 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
290 bool anySectionNeedsSend =
false;
294 bool isNewData = this->m_fillBuffers[pkt].updated;
295 FwChanIdType entryGroup = this->m_fillBuffers[pkt].level;
296 this->m_fillBuffers[pkt].updated =
false;
300 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
301 TlmPacketizer_GroupConfig& entryGroupConfig =
302 this->m_groupConfigs[
static_cast<FwSizeType>(section)][entryGroup];
305 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
306 pktEntryFlags.updateFlag = UpdateFlag::NEW;
322 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
323 sectionNeedsSend[section] =
true;
325 if (not((entryGroupConfig.get_enabled() and
333 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
339 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
340 pktEntryFlags.prevSentCounter++;
348 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
350 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_min()) {
351 sectionNeedsSend[section] =
true;
359 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_max()) {
360 sectionNeedsSend[section] =
true;
363 if (sectionNeedsSend[section]) {
364 anySectionNeedsSend =
true;
369 if (anySectionNeedsSend) {
371 BufferEntry sendBuffer = this->m_fillBuffers[pkt];
381 if (sectionNeedsSend[section]) {
382 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
383 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
385 this->
PktSend_out(outIndex, sendBuffer.buffer, pktEntryFlags.prevSentCounter);
387 pktEntryFlags.prevSentCounter = 0;
388 pktEntryFlags.updateFlag = UpdateFlag::PAST;
395 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
401 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
407 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
424 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_enabled(
433 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
443 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
444 if (this->m_fillBuffers[pkt].
id ==
id) {
446 this->m_fillBuffers[pkt].updated =
true;
447 this->m_fillBuffers[pkt].latestTime = this->
getTime();
450 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
458 if (pkt == this->m_numPackets) {
467 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
477 (void)(this->m_sectionEnabled[section] = enable);
482 void TlmPacketizer ::ENABLE_GROUP_cmdHandler(
FwOpcodeType opCode,
493 this->m_groupConfigs[section][tlmGroup].set_enabled(enable);
498 void TlmPacketizer ::FORCE_GROUP_cmdHandler(
FwOpcodeType opCode,
509 this->m_groupConfigs[section][tlmGroup].set_forceEnabled(enable);
514 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
527 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
531 void TlmPacketizer::configureSectionGroupRate(
544 TlmPacketizer_GroupConfig& groupConfig = this->m_groupConfigs[section][tlmGroup];
545 groupConfig.set_rateLogic(rateLogic);
546 groupConfig.set_min(minDelta);
547 groupConfig.set_max(maxDelta);
556 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
567 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
569 }
else if (not this->m_missTlmCheck[slot].checked) {
570 this->m_missTlmCheck[slot].checked =
true;
571 this->m_missTlmCheck[slot].id = id;
589 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
604 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
Serialization/Deserialization operation was successful.
Parameter to control section enable flags.
bool isValid() const
Check raw enum value for validity.
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
TlmPacketizer(const char *const compName)
REQUIRED: Counter, leave as last element.
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
void tlmWrite_GroupConfigs(const Svc::TlmPacketizer_SectionConfigs &arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_HI_LevelSet(FwChanIdType level) const
void log_ACTIVITY_LO_PacketSent(U32 packetId) const
Serializable::SizeType getSize() const override
Get current buffer size.
FwIdType FwPrmIdType
The type of a parameter identifier.
const TlmPacketizerPacket * list[MAX_PACKETIZER_PACKETS]
void log_WARNING_LO_NoChan(FwChanIdType Id) const
static const FwChanIdType MAX_PACKETIZER_PACKETS
Maximum number of packets that the packetizer can handle.
void unLock()
unlock the mutex and assert success
bool isValid() const
Check raw enum value for validity.
PlatformSignedSizeType FwSignedSizeType
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Send on updates after MIN ticks since last send.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
Success find(const K &key, V &value) const override
Send every MAX ticks between sends.
const TlmPacketizerChannelEntry * list
pointer to a channel entry
void log_WARNING_LO_PacketNotFound(U32 packetId) const
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK
Maximum number of missing channels to track and report.
void tlmWrite_SectionEnabled(const Svc::TlmPacketizer_SectionEnabled &arg, Fw::Time _tlmTime=Fw::Time()) const
Write telemetry channel SectionEnabled.
SerializeStatus
forward declaration for string
No logic applied. Does not send group and freezes counter.
void registerExternalParameters(Fw::ParamExternalDelegate *paramExternalDelegatePtr)
Initialize the external parameter delegate.
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
FwChanIdType id
Id of channel.
FwChanIdType level
packet level - used to select set of packets to send
Data was the wrong format (e.g. wrong packet type)
void log_WARNING_LO_SectionUnconfigurable(const Svc::TelemetrySection §ion, const Fw::Enabled &enable) const
Log event SectionUnconfigurable.
Enumeration for rate logic types for telemetry groups.
External serialize buffer with no copy semantics.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void resetSer() override
Reset serialization pointer to beginning of buffer.
Deserialized type ID didn't match.
Enabled and disabled states.
U16 FwTlmPacketizeIdType
The type of a telemetry packet identifier.
Command successfully executed.
void clear() override
Clear the map.
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const FwChanIdType startLevel)
bool isValid() const
Check raw enum value for validity.
uint8_t U8
8-bit unsigned integer
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port PktSend.
void log_WARNING_LO_MaxLevelExceed(FwChanIdType level, FwChanIdType max) const
Parameter to control section configuration.
PlatformIndexType FwIndexType
Command failed validation.
RateGroupDivider component implementation.
U8 * getBuffAddr() override
Get buffer address for data filling (non-const version)
Enum representing parameter validity.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
FwSizeType getCapacity() const override
Get buffer capacity.
FwChanIdType numEntries
number of channels in packet
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
Success insert(const K &key, const V &value) override
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
void lock()
lock the mutex and assert success
Auto-generated base for TlmPacketizer component.