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");
60 this->m_numChannels = 0;
61 this->m_channelIndices.
clear();
62 this->m_configured =
false;
71 FW_ASSERT(packetList.
list[pktEntry]->
list, static_cast<FwAssertArgType>(pktEntry));
78 entryIndex = this->m_numChannels++;
79 this->m_channels[entryIndex].id = id;
80 this->m_channels[entryIndex].hasValue =
false;
82 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
88 TlmEntry& entry = this->m_channels[entryIndex];
89 entry.ignored =
false;
90 entry.channelSize = packetList.
list[pktEntry]->
list[tlmEntry].
size;
93 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
94 static_cast<FwAssertArgType>(packetLen));
97 packetLen += entry.channelSize;
101 static_cast<FwAssertArgType>(pktEntry));
103 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
106 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
108 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
111 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
114 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
116 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
118 if (packetList.
list[pktEntry]->
level > maxLevel) {
119 maxLevel = packetList.
list[pktEntry]->
level;
133 entryIndex = this->m_numChannels++;
134 this->m_channels[entryIndex].id = id;
135 this->m_channels[entryIndex].hasValue =
false;
137 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
143 TlmEntry& entry = this->m_channels[entryIndex];
144 entry.ignored =
true;
145 entry.channelSize = ignoreList.
list[channelEntry].
size;
152 this->m_configured =
true;
159 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
169 this->missingChannel(
id);
173 TlmEntry& entry = this->m_channels[entryIndex];
181 entry.hasValue =
true;
184 if (entry.packetOffset[pkt] != -1) {
187 this->m_fillBuffers[pkt].updated =
true;
188 this->m_fillBuffers[pkt].latestTime = timeTag;
189 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
196 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
202 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
218 this->missingChannel(
id);
222 const TlmEntry& entry = this->m_channels[entryIndex];
231 if (!entry.hasValue) {
246 if (entry.packetOffset[pkt] != -1) {
249 timeTag = this->m_fillBuffers[pkt].latestTime;
250 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
251 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
262 FW_ASSERT(0, static_cast<FwAssertArgType>(entry.id));
268 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
271 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
274 bool anySectionNeedsSend =
false;
278 bool isNewData = this->m_fillBuffers[pkt].updated;
279 FwChanIdType entryGroup = this->m_fillBuffers[pkt].level;
280 this->m_fillBuffers[pkt].updated =
false;
284 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
285 TlmPacketizer_GroupConfig& entryGroupConfig =
286 this->m_groupConfigs[
static_cast<FwSizeType>(section)][entryGroup];
289 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
290 pktEntryFlags.updateFlag = UpdateFlag::NEW;
306 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
307 sectionNeedsSend[section] =
true;
309 if (not((entryGroupConfig.get_enabled() and
317 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
323 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
324 pktEntryFlags.prevSentCounter++;
332 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
334 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_min()) {
335 sectionNeedsSend[section] =
true;
343 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_max()) {
344 sectionNeedsSend[section] =
true;
347 if (sectionNeedsSend[section]) {
348 anySectionNeedsSend =
true;
353 if (anySectionNeedsSend) {
355 BufferEntry sendBuffer = this->m_fillBuffers[pkt];
365 if (sectionNeedsSend[section]) {
366 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
367 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
369 this->
PktSend_out(outIndex, sendBuffer.buffer, pktEntryFlags.prevSentCounter);
371 pktEntryFlags.prevSentCounter = 0;
372 pktEntryFlags.updateFlag = UpdateFlag::PAST;
379 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
385 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
391 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
406 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_enabled(
415 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
421 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
422 if (this->m_fillBuffers[pkt].
id ==
id) {
424 this->m_fillBuffers[pkt].updated =
true;
425 this->m_fillBuffers[pkt].latestTime = this->
getTime();
428 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
436 if (pkt == this->m_numPackets) {
445 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
455 (void)(this->m_sectionEnabled[section] = enable);
460 void TlmPacketizer ::ENABLE_GROUP_cmdHandler(
FwOpcodeType opCode,
472 this->m_groupConfigs[section][tlmGroup].set_enabled(enable);
477 void TlmPacketizer ::FORCE_GROUP_cmdHandler(
FwOpcodeType opCode,
488 this->m_groupConfigs[section][tlmGroup].set_forceEnabled(enable);
493 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
506 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
510 void TlmPacketizer::configureSectionGroupRate(
523 TlmPacketizer_GroupConfig& groupConfig = this->m_groupConfigs[section][tlmGroup];
524 groupConfig.set_rateLogic(rateLogic);
525 groupConfig.set_min(minDelta);
526 groupConfig.set_max(maxDelta);
535 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
546 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
548 }
else if (not this->m_missTlmCheck[slot].checked) {
549 this->m_missTlmCheck[slot].checked =
true;
550 this->m_missTlmCheck[slot].id = id;
569 FW_ASSERT(0, static_cast<FwAssertArgType>(local_id));
583 FW_ASSERT(0, static_cast<FwAssertArgType>(local_id));
Serialization/Deserialization operation was successful.
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
Parameter to control section enable flags.
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 PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port PktSend.
Parameter to control section configuration.
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
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)
Enumeration for rate logic types for telemetry groups.
External serialize buffer with no copy semantics.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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.
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 log_WARNING_LO_SectionUnconfigurable(Svc::TelemetrySection section, Fw::Enabled enable) const
Log event SectionUnconfigurable.
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.
Enum representing parameter validity.
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
FwChanIdType numEntries
number of channels in packet
Success insert(const K &key, const V &value) override
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.