20 const TlmPacketizer_TelemetrySendPortMap TlmPacketizer::TELEMETRY_SEND_PORT_MAP = {};
34 this->m_missTlmCheck[entry].checked =
false;
35 this->m_missTlmCheck[entry].id = 0;
40 this->m_fillBuffers[buffer].updated =
false;
44 "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;
73 static_cast<FwAssertArgType>(pktEntry));
81 entryIndex = this->m_numChannels++;
82 this->m_channels[entryIndex].id = id;
83 this->m_channels[entryIndex].hasValue =
false;
84 this->m_channels[entryIndex].channelSize = channelSize;
86 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
94 FW_ASSERT(this->m_channels[entryIndex].channelSize == channelSize, static_cast<FwAssertArgType>(
id),
95 static_cast<FwAssertArgType>(channelSize),
96 static_cast<FwAssertArgType>(this->m_channels[entryIndex].channelSize));
99 TlmEntry& entry = this->m_channels[entryIndex];
100 entry.ignored =
false;
101 entry.channelSize = channelSize;
104 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
105 static_cast<FwAssertArgType>(packetLen));
108 packetLen += entry.channelSize;
112 static_cast<FwAssertArgType>(pktEntry));
114 (void)memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
117 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
119 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
122 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
125 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
127 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
129 if (packetList.
list[pktEntry]->
level > maxLevel) {
130 maxLevel = packetList.
list[pktEntry]->
level;
144 entryIndex = this->m_numChannels++;
145 this->m_channels[entryIndex].id = id;
146 this->m_channels[entryIndex].hasValue =
false;
148 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
154 FW_ASSERT(this->m_channels[entryIndex].ignored, static_cast<FwAssertArgType>(
id));
157 TlmEntry& entry = this->m_channels[entryIndex];
158 entry.ignored =
true;
159 entry.channelSize = ignoreList.
list[channelEntry].
size;
166 this->m_configured =
true;
173 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
183 this->missingChannel(
id);
187 TlmEntry& entry = this->m_channels[entryIndex];
197 if (val.
getSize() > entry.channelSize) {
205 if (entry.packetOffset[pkt] != -1) {
208 this->m_fillBuffers[pkt].updated =
true;
209 this->m_fillBuffers[pkt].latestTime = timeTag;
210 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
214 entry.hasValue =
true;
220 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
226 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
242 this->missingChannel(
id);
246 const TlmEntry& entry = this->m_channels[entryIndex];
255 if (!entry.hasValue) {
270 if (entry.packetOffset[pkt] != -1) {
273 timeTag = this->m_fillBuffers[pkt].latestTime;
274 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
275 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
287 FW_ASSERT(
false, static_cast<FwAssertArgType>(entry.id));
293 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
296 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
299 bool anySectionNeedsSend =
false;
303 bool isNewData = this->m_fillBuffers[pkt].updated;
304 FwChanIdType entryGroup = this->m_fillBuffers[pkt].level;
305 this->m_fillBuffers[pkt].updated =
false;
309 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
310 TlmPacketizer_GroupConfig& entryGroupConfig =
311 this->m_groupConfigs[
static_cast<FwSizeType>(section)][entryGroup];
314 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
315 pktEntryFlags.updateFlag = UpdateFlag::NEW;
331 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
332 sectionNeedsSend[section] =
true;
334 if (not((entryGroupConfig.get_enabled() and
342 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
348 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
349 pktEntryFlags.prevSentCounter++;
357 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
359 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_min()) {
360 sectionNeedsSend[section] =
true;
368 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_max()) {
369 sectionNeedsSend[section] =
true;
372 if (sectionNeedsSend[section]) {
373 anySectionNeedsSend =
true;
378 if (anySectionNeedsSend) {
380 BufferEntry sendBuffer = this->m_fillBuffers[pkt];
390 if (sectionNeedsSend[section]) {
391 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
392 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
394 this->
PktSend_out(outIndex, sendBuffer.buffer, pktEntryFlags.prevSentCounter);
396 pktEntryFlags.prevSentCounter = 0;
397 pktEntryFlags.updateFlag = UpdateFlag::PAST;
404 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
410 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
416 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
433 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_enabled(
442 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
452 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
453 if (this->m_fillBuffers[pkt].
id ==
id) {
455 this->m_fillBuffers[pkt].updated =
true;
456 this->m_fillBuffers[pkt].latestTime = this->
getTime();
459 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
467 if (pkt == this->m_numPackets) {
476 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
486 (void)(this->m_sectionEnabled[section] = enable);
491 void TlmPacketizer ::ENABLE_GROUP_cmdHandler(
FwOpcodeType opCode,
502 this->m_groupConfigs[section][tlmGroup].set_enabled(enable);
507 void TlmPacketizer ::FORCE_GROUP_cmdHandler(
FwOpcodeType opCode,
518 this->m_groupConfigs[section][tlmGroup].set_forceEnabled(enable);
523 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
536 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
540 void TlmPacketizer::configureSectionGroupRate(
553 TlmPacketizer_GroupConfig& groupConfig = this->m_groupConfigs[section][tlmGroup];
554 groupConfig.set_rateLogic(rateLogic);
555 groupConfig.set_min(minDelta);
556 groupConfig.set_max(maxDelta);
565 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
576 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
578 }
else if (not this->m_missTlmCheck[slot].checked) {
579 this->m_missTlmCheck[slot].checked =
true;
580 this->m_missTlmCheck[slot].id = id;
598 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
613 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
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.
#define FW_PARAM_OK(paramValid)
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.
bool isValid() const
Check raw enum value for validity.
Parameter to control section enable flags.
PlatformSignedSizeType FwSignedSizeType
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
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
Serializable::SizeType getCapacity() const override
Get buffer capacity.
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.
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
Enumeration for rate logic types for telemetry groups.
External serialize buffer with no copy semantics.
void unLock()
unlock the mutex and assert success
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
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
Parameter to control section configuration.
void lock()
lock the mutex and assert success
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
PlatformIndexType FwIndexType
void log_WARNING_HI_OversizedChannel(FwChanIdType Id, FwSizeType valSize, FwSizeType expected)
Command failed validation.
RateGroupDivider component implementation.
Enum representing parameter validity.
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.
Auto-generated base for TlmPacketizer component.