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;
71 FW_ASSERT(packetList.
list[pktEntry]->
list !=
nullptr, static_cast<FwAssertArgType>(pktEntry));
79 entryIndex = this->m_numChannels++;
80 this->m_channels[entryIndex].id = id;
81 this->m_channels[entryIndex].hasValue =
false;
82 this->m_channels[entryIndex].channelSize = channelSize;
84 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
92 FW_ASSERT(this->m_channels[entryIndex].channelSize == channelSize, static_cast<FwAssertArgType>(
id),
93 static_cast<FwAssertArgType>(channelSize),
94 static_cast<FwAssertArgType>(this->m_channels[entryIndex].channelSize));
97 TlmEntry& entry = this->m_channels[entryIndex];
98 entry.ignored =
false;
99 entry.channelSize = channelSize;
102 FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
103 static_cast<FwAssertArgType>(packetLen));
106 packetLen += entry.channelSize;
110 static_cast<FwAssertArgType>(pktEntry));
112 (void)memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
115 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
117 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
120 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
123 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
125 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
127 if (packetList.
list[pktEntry]->
level > maxLevel) {
128 maxLevel = packetList.
list[pktEntry]->
level;
142 entryIndex = this->m_numChannels++;
143 this->m_channels[entryIndex].id = id;
144 this->m_channels[entryIndex].hasValue =
false;
146 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = -1;
152 FW_ASSERT(this->m_channels[entryIndex].ignored, static_cast<FwAssertArgType>(
id));
155 TlmEntry& entry = this->m_channels[entryIndex];
156 entry.ignored =
true;
157 entry.channelSize = ignoreList.
list[channelEntry].
size;
164 this->m_configured =
true;
171 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
181 this->missingChannel(
id);
185 TlmEntry& entry = this->m_channels[entryIndex];
195 if (val.
getSize() > entry.channelSize) {
203 if (entry.packetOffset[pkt] != -1) {
206 this->m_fillBuffers[pkt].updated =
true;
207 this->m_fillBuffers[pkt].latestTime = timeTag;
208 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
212 entry.hasValue =
true;
218 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
224 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
240 this->missingChannel(
id);
244 const TlmEntry& entry = this->m_channels[entryIndex];
253 if (!entry.hasValue) {
268 if (entry.packetOffset[pkt] != -1) {
271 timeTag = this->m_fillBuffers[pkt].latestTime;
272 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
273 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
285 FW_ASSERT(
false, static_cast<FwAssertArgType>(entry.id));
291 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
294 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
297 bool anySectionNeedsSend =
false;
301 bool isNewData = this->m_fillBuffers[pkt].updated;
302 FwChanIdType entryGroup = this->m_fillBuffers[pkt].level;
303 this->m_fillBuffers[pkt].updated =
false;
307 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
308 TlmPacketizer_GroupConfig& entryGroupConfig =
309 this->m_groupConfigs[
static_cast<FwSizeType>(section)][entryGroup];
312 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
313 pktEntryFlags.updateFlag = UpdateFlag::NEW;
329 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
330 sectionNeedsSend[section] =
true;
332 if (not((entryGroupConfig.get_enabled() and
340 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
346 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
347 pktEntryFlags.prevSentCounter++;
355 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
357 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_min()) {
358 sectionNeedsSend[section] =
true;
366 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_max()) {
367 sectionNeedsSend[section] =
true;
370 if (sectionNeedsSend[section]) {
371 anySectionNeedsSend =
true;
376 if (anySectionNeedsSend) {
378 BufferEntry sendBuffer = this->m_fillBuffers[pkt];
388 if (sectionNeedsSend[section]) {
389 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
390 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
392 this->
PktSend_out(outIndex, sendBuffer.buffer, pktEntryFlags.prevSentCounter);
394 pktEntryFlags.prevSentCounter = 0;
395 pktEntryFlags.updateFlag = UpdateFlag::PAST;
402 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
408 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
414 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
431 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_enabled(
440 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
450 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
451 if (this->m_fillBuffers[pkt].
id ==
id) {
453 this->m_fillBuffers[pkt].updated =
true;
454 this->m_fillBuffers[pkt].latestTime = this->
getTime();
457 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
465 if (pkt == this->m_numPackets) {
474 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
484 (void)(this->m_sectionEnabled[section] = enable);
489 void TlmPacketizer ::ENABLE_GROUP_cmdHandler(
FwOpcodeType opCode,
500 this->m_groupConfigs[section][tlmGroup].set_enabled(enable);
505 void TlmPacketizer ::FORCE_GROUP_cmdHandler(
FwOpcodeType opCode,
516 this->m_groupConfigs[section][tlmGroup].set_forceEnabled(enable);
521 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
534 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
538 void TlmPacketizer::configureSectionGroupRate(
551 TlmPacketizer_GroupConfig& groupConfig = this->m_groupConfigs[section][tlmGroup];
552 groupConfig.set_rateLogic(rateLogic);
553 groupConfig.set_min(minDelta);
554 groupConfig.set_max(maxDelta);
563 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
574 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
576 }
else if (not this->m_missTlmCheck[slot].checked) {
577 this->m_missTlmCheck[slot].checked =
true;
578 this->m_missTlmCheck[slot].id = id;
596 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
611 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.
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.
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
Parameter to control section enable flags.
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.
Parameter to control section configuration.
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.
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.
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.
void lock()
lock the mutex and assert success
Auto-generated base for TlmPacketizer component.