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 FW_ASSERT(this->m_channels[entryIndex].ignored, static_cast<FwAssertArgType>(
id));
146 TlmEntry& entry = this->m_channels[entryIndex];
147 entry.ignored =
true;
148 entry.channelSize = ignoreList.
list[channelEntry].
size;
155 this->m_configured =
true;
162 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
172 this->missingChannel(
id);
176 TlmEntry& entry = this->m_channels[entryIndex];
184 entry.hasValue =
true;
187 if (entry.packetOffset[pkt] != -1) {
190 this->m_fillBuffers[pkt].updated =
true;
191 this->m_fillBuffers[pkt].latestTime = timeTag;
192 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
195 static_cast<FwAssertArgType>(entry.channelSize));
203 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
209 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
225 this->missingChannel(
id);
229 const TlmEntry& entry = this->m_channels[entryIndex];
238 if (!entry.hasValue) {
253 if (entry.packetOffset[pkt] != -1) {
256 timeTag = this->m_fillBuffers[pkt].latestTime;
257 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
258 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
269 FW_ASSERT(0, static_cast<FwAssertArgType>(entry.id));
275 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
278 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
281 bool anySectionNeedsSend =
false;
285 bool isNewData = this->m_fillBuffers[pkt].updated;
286 FwChanIdType entryGroup = this->m_fillBuffers[pkt].level;
287 this->m_fillBuffers[pkt].updated =
false;
291 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
292 TlmPacketizer_GroupConfig& entryGroupConfig =
293 this->m_groupConfigs[
static_cast<FwSizeType>(section)][entryGroup];
296 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
297 pktEntryFlags.updateFlag = UpdateFlag::NEW;
313 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
314 sectionNeedsSend[section] =
true;
316 if (not((entryGroupConfig.get_enabled() and
324 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
330 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
331 pktEntryFlags.prevSentCounter++;
339 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
341 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_min()) {
342 sectionNeedsSend[section] =
true;
350 pktEntryFlags.prevSentCounter >= entryGroupConfig.get_max()) {
351 sectionNeedsSend[section] =
true;
354 if (sectionNeedsSend[section]) {
355 anySectionNeedsSend =
true;
360 if (anySectionNeedsSend) {
362 BufferEntry sendBuffer = this->m_fillBuffers[pkt];
372 if (sectionNeedsSend[section]) {
373 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
374 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
376 this->
PktSend_out(outIndex, sendBuffer.buffer, pktEntryFlags.prevSentCounter);
378 pktEntryFlags.prevSentCounter = 0;
379 pktEntryFlags.updateFlag = UpdateFlag::PAST;
386 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
392 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
398 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
415 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_enabled(
424 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
434 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
435 if (this->m_fillBuffers[pkt].
id ==
id) {
437 this->m_fillBuffers[pkt].updated =
true;
438 this->m_fillBuffers[pkt].latestTime = this->
getTime();
441 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
449 if (pkt == this->m_numPackets) {
458 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
468 (void)(this->m_sectionEnabled[section] = enable);
473 void TlmPacketizer ::ENABLE_GROUP_cmdHandler(
FwOpcodeType opCode,
484 this->m_groupConfigs[section][tlmGroup].set_enabled(enable);
489 void TlmPacketizer ::FORCE_GROUP_cmdHandler(
FwOpcodeType opCode,
500 this->m_groupConfigs[section][tlmGroup].set_forceEnabled(enable);
505 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
518 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
522 void TlmPacketizer::configureSectionGroupRate(
535 TlmPacketizer_GroupConfig& groupConfig = this->m_groupConfigs[section][tlmGroup];
536 groupConfig.set_rateLogic(rateLogic);
537 groupConfig.set_min(minDelta);
538 groupConfig.set_max(maxDelta);
547 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
558 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
560 }
else if (not this->m_missTlmCheck[slot].checked) {
561 this->m_missTlmCheck[slot].checked =
true;
562 this->m_missTlmCheck[slot].id = id;
580 FW_ASSERT(0, static_cast<FwAssertArgType>(local_id));
595 FW_ASSERT(0, static_cast<FwAssertArgType>(local_id));
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
Parameter to control section enable flags.
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
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
Parameter to control section configuration.
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 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_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.
Command failed validation.
RateGroupDivider component implementation.
Enum representing parameter validity.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
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.