21 const TlmPacketizer_TelemetrySendPortMap TlmPacketizer::TELEMETRY_SEND_PORT_MAP = {};
28 "FwTlmPacketizeOffsetType must span an entire ComBuffer");
34 "Fw::DeserialStatus must mirror Fw::SerializeStatus values");
46 this->m_missTlmCheck[entry].checked =
false;
47 this->m_missTlmCheck[entry].id = 0;
52 this->m_fillBuffers[buffer].updated =
false;
56 "NUM_CONFIGURABLE_TLMPACKETIZER_GROUPS MUST BE MAX_CONFIGURABLE_TLMPACKETIZER_GROUP + 1");
72 this->m_numChannels = 0;
73 this->m_channelIndices.
clear();
74 this->m_configured =
false;
85 static_cast<FwAssertArgType>(pktEntry));
93 entryIndex = this->m_numChannels++;
94 this->m_channels[entryIndex].id = id;
95 this->m_channels[entryIndex].hasValue =
false;
96 this->m_channels[entryIndex].channelSize = channelSize;
98 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = NOT_IN_PACKET;
106 FW_ASSERT(this->m_channels[entryIndex].channelSize == channelSize, static_cast<FwAssertArgType>(
id),
107 static_cast<FwAssertArgType>(channelSize),
108 static_cast<FwAssertArgType>(this->m_channels[entryIndex].channelSize));
111 TlmEntry& entry = this->m_channels[entryIndex];
112 entry.ignored =
false;
113 entry.channelSize = channelSize;
116 FW_ASSERT(packetLen < NOT_IN_PACKET, static_cast<FwAssertArgType>(packetLen));
119 packetLen += entry.channelSize;
123 static_cast<FwAssertArgType>(pktEntry));
125 (void)memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0,
static_cast<size_t>(packetLen));
128 static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM));
130 stat = this->m_fillBuffers[pktEntry].buffer.serializeFrom(packetList.
list[pktEntry]->
id);
133 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
136 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
138 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
140 if (packetList.
list[pktEntry]->
level > maxLevel) {
141 maxLevel = packetList.
list[pktEntry]->
level;
155 entryIndex = this->m_numChannels++;
156 this->m_channels[entryIndex].id = id;
157 this->m_channels[entryIndex].hasValue =
false;
159 this->m_channels[entryIndex].packetOffset[pktOffsetEntry] = NOT_IN_PACKET;
165 FW_ASSERT(this->m_channels[entryIndex].ignored, static_cast<FwAssertArgType>(
id));
168 TlmEntry& entry = this->m_channels[entryIndex];
169 entry.ignored =
true;
170 entry.channelSize = ignoreList.
list[channelEntry].
size;
177 this->m_configured =
true;
184 void TlmPacketizer ::TlmRecv_handler(
const FwIndexType portNum,
194 this->missingChannel(
id);
198 TlmEntry& entry = this->m_channels[entryIndex];
208 if (val.
getSize() > entry.channelSize) {
216 if (entry.packetOffset[pkt] != NOT_IN_PACKET) {
219 this->m_fillBuffers[pkt].updated =
true;
220 this->m_fillBuffers[pkt].latestTime = timeTag;
221 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
225 entry.hasValue =
true;
230 void TlmPacketizer ::configureSectionGroupRate_handler(
FwIndexType portNum,
236 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
252 this->missingChannel(
id);
256 const TlmEntry& entry = this->m_channels[entryIndex];
265 if (!entry.hasValue) {
280 if (entry.packetOffset[pkt] != NOT_IN_PACKET) {
283 timeTag = this->m_fillBuffers[pkt].latestTime;
284 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entry.packetOffset[pkt]];
285 (void)memcpy(val.
getBuffAddr(), ptr,
static_cast<size_t>(entry.channelSize));
296 FW_ASSERT(
false, static_cast<FwAssertArgType>(entry.id));
302 void TlmPacketizer ::Run_handler(
const FwIndexType portNum, U32 context) {
305 for (
FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) {
308 bool anySectionNeedsSend =
false;
311 bool isNewData =
false;
315 isNewData = this->m_fillBuffers[pkt].updated;
316 entryGroup = this->m_fillBuffers[pkt].level;
317 this->m_fillBuffers[pkt].updated =
false;
321 PktSendCounters& pktEntryFlags = this->m_packetFlags[
static_cast<FwSizeType>(section)][pkt];
326 if (isNewData && pktEntryFlags.updateFlag != UpdateFlag::REQUESTED) {
327 pktEntryFlags.updateFlag = UpdateFlag::NEW;
342 if (pktEntryFlags.updateFlag == UpdateFlag::REQUESTED) {
343 sectionNeedsSend[section] =
true;
345 if (not this->sendAllowed(effectiveEntryConfig.get_sendState(), section)) {
348 if (pktEntryFlags.updateFlag == UpdateFlag::NEVER_UPDATED) {
354 if (pktEntryFlags.prevSentCounter < std::numeric_limits<U32>::max()) {
355 pktEntryFlags.prevSentCounter++;
363 if (pktEntryFlags.updateFlag == UpdateFlag::NEW and
365 pktEntryFlags.prevSentCounter >= effectiveEntryConfig.get_rates().get_min()) {
366 sectionNeedsSend[section] =
true;
374 pktEntryFlags.prevSentCounter >= effectiveEntryConfig.get_rates().get_max()) {
375 sectionNeedsSend[section] =
true;
378 if (sectionNeedsSend[section]) {
379 anySectionNeedsSend =
true;
384 if (anySectionNeedsSend) {
390 sendBuffer = this->m_fillBuffers[pkt].buffer;
391 sendTime = this->m_fillBuffers[pkt].latestTime;
402 if (sectionNeedsSend[section]) {
403 PktSendCounters& pktEntryFlags = this->m_packetFlags[section][pkt];
404 FwIndexType outIndex = this->sectionGroupToPort(section, entryGroup);
406 this->
PktSend_out(outIndex, sendBuffer, pktEntryFlags.prevSentCounter);
408 pktEntryFlags.prevSentCounter = 0;
409 pktEntryFlags.updateFlag = UpdateFlag::PAST;
416 void TlmPacketizer ::controlIn_handler(
FwIndexType portNum,
422 (void)(this->m_sectionEnabled[static_cast<FwSizeType>(section)] = enabled);
428 void TlmPacketizer ::pingIn_handler(
const FwIndexType portNum, U32 key) {
445 this->m_groupConfigs[
static_cast<FwSizeType>(section)][group].set_sendState(
454 void TlmPacketizer ::SEND_PKT_cmdHandler(
const FwOpcodeType opCode,
459 if (this->resolvePacket(section,
id, pkt) != PacketStatus::OK) {
466 this->m_fillBuffers[pkt].updated =
true;
467 this->m_fillBuffers[pkt].latestTime = this->
getTime();
470 this->m_packetFlags[section][pkt].updateFlag = UpdateFlag::REQUESTED;
476 void TlmPacketizer ::ENABLE_SECTION_cmdHandler(
FwOpcodeType opCode,
486 (void)(this->m_sectionEnabled[section] = enable);
491 void TlmPacketizer ::CONFIGURE_GROUP_SEND_cmdHandler(
FwOpcodeType opCode,
501 this->m_groupConfigs[section][tlmGroup].set_sendState(sendState);
507 void TlmPacketizer ::CONFIGURE_GROUP_RATES_cmdHandler(
FwOpcodeType opCode,
520 this->configureSectionGroupRate(section, tlmGroup, rateLogic, minDelta, maxDelta);
524 void TlmPacketizer ::GET_PACKET_CONFIG_cmdHandler(
FwOpcodeType opCode,
529 const PacketStatus status = this->resolvePacket(section, packetId, pkt);
530 if (status == PacketStatus::OK) {
533 this->effectiveConfig(static_cast<FwIndexType>(section.
e), pkt));
535 this->
cmdResponse_out(opCode, cmdSeq, TlmPacketizer::toCmdResponse(status));
538 void TlmPacketizer ::OVERRIDE_PACKET_SEND_cmdHandler(
FwOpcodeType opCode,
546 TlmPacketizer::toCmdResponse(this->overridePacket(section, packetId, requested)));
549 void TlmPacketizer ::OVERRIDE_PACKET_RATES_cmdHandler(
FwOpcodeType opCode,
560 TlmPacketizer::toCmdResponse(this->overridePacket(section, packetId, requested)));
563 void TlmPacketizer ::CLEAR_PACKET_OVERRIDE_cmdHandler(
FwOpcodeType opCode,
569 TlmPacketizer::toCmdResponse(this->overridePacket(section, packetId, requested)));
572 void TlmPacketizer::configureSectionGroupRate(
585 this->m_groupConfigs[section][tlmGroup].set_rates(
Svc::RateConfig(rateLogic, minDelta, maxDelta));
594 const FwIndexType outIndex = TlmPacketizer::TELEMETRY_SEND_PORT_MAP[
static_cast<FwSizeType>(section)][group];
603 case PacketStatus::OK:
605 case PacketStatus::MIRROR_FAILED:
615 Svc::TlmSendConfig effective = this->m_groupConfigs[sectionIndex][this->m_fillBuffers[pkt].level];
626 if (overridesRates) {
633 switch (sendState.
e) {
643 FW_ASSERT(0, static_cast<FwAssertArgType>(sendState.
e));
650 if (this->m_fillBuffers[p].
id == packetId) {
663 return PacketStatus::INVALID_SECTION;
667 return PacketStatus::UNKNOWN_PACKET;
669 return PacketStatus::OK;
710 :
TlmPacketizer::mergeOverrideType(previous.get_overrideType(), requested.get_overrideType()));
713 return PacketStatus::MIRROR_FAILED;
715 return PacketStatus::OK;
722 PacketStatus status = this->resolvePacket(section, packetId, pkt);
723 if (status != PacketStatus::OK) {
726 status = this->applyPacketOverride(section, pkt, requested);
727 if (status != PacketStatus::OK) {
734 this->m_packetOverrides[static_cast<FwSizeType>(section.
e)][pkt]);
736 return PacketStatus::OK;
748 status = deserializer.deserializeTo(entry);
769 if (not reported.isValid()) {
798 this->m_packetOverrides[sectionIndex][pkt]);
806 FW_ASSERT(static_cast<FwSizeType>(buffer.
getSize()) >= entrySize, static_cast<FwAssertArgType>(buffer.
getSize()));
810 buffer.
setSize(static_cast<Fw::Buffer::SizeType>(entrySize));
819 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
821 }
else if (not this->m_missTlmCheck[slot].checked) {
822 this->m_missTlmCheck[slot].checked =
true;
823 this->m_missTlmCheck[slot].id = id;
845 this->m_sectionEnabled = loaded;
856 this->m_groupConfigs = loaded;
861 FW_ASSERT(
false, static_cast<FwAssertArgType>(local_id));
876 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.
bool isConnected_packetOverrideOut_OutputPort(FwIndexType portNum) const
TlmPacketizer(const char *const compName)
void set_sendState(Svc::TlmSendState::T sendState)
Set member sendState.
Parameter to control section enable flags.
REQUIRED: Counter, leave as last element.
FwIdType FwOpcodeType
The type of a command opcode.
Deserialized type ID didn't match.
Deserialization buffer was empty when trying to read more data.
#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
Deserialization buffer was empty when trying to read data.
void setSize(FwSizeType size)
Send policy of a group or packet. Resolution: packet -> group -> section enable.
void log_ACTIVITY_HI_LevelSet(FwChanIdType level) const
Telemetry send policy (send state + rates), shared by the per-group config and per-packet override...
void log_ACTIVITY_HI_GroupSendStateSet(const Svc::TelemetrySection §ion, FwChanIdType tlmGroup, const Svc::TlmSendState &sendState) const
void set_rates(const Svc::RateConfig &rates)
Set member rates.
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
void log_ACTIVITY_HI_PacketSent(U32 packetId) const
A single per-packet override record: mirrored on packetOverrideOut, reloaded from packetOverrideIn...
bool isConnected_allocate_OutputPort(FwIndexType portNum) const
bool isValid() const
Check raw enum value for validity.
Per-packet override: which fields apply and their values.
void log_ACTIVITY_HI_PacketOverrideCleared(const Svc::TelemetrySection §ion, U32 packetId) const
Deserialization data had incorrect values (unexpected data types)
void log_WARNING_LO_ReloadRecordInvalid(U32 packetId) const
Deserialization data had incorrect values (unexpected data types)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Enum representing a command response.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void log_ACTIVITY_HI_PacketOverrideSet(const Svc::TelemetrySection §ion, U32 packetId, const Svc::PacketOverrideConfig &override) const
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
void log_WARNING_LO_InvalidPacketConfig(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.
Svc::RateConfig & get_rates()
Get member rates.
Svc::TlmSendState::T get_sendState() const
Get member sendState.
SerializeStatus
forward declaration for string
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.
U16 FwTlmPacketizeOffsetType
bool isConnected_deallocate_OutputPort(FwIndexType portNum) const
FwChanIdType id
Id of channel.
ExternalSerializeBufferWithMemberCopy getDeserializer()
Svc::PacketOverrideType::T get_overrideType() const
Get member overrideType.
FwChanIdType level
packet level - used to select set of packets to send
The rates are overridden; the send state follows the group.
Data was the wrong format (e.g. wrong packet type)
Which fields of a packet's config override its group.
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)
Svc::TlmSendConfig & get_sendConfig()
Get member sendConfig.
Enumeration for rate logic types for telemetry groups.
Packet: use the group's state; group: use the section enable (default)
void deallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port deallocate.
void set_sendConfig(const Svc::TlmSendConfig &sendConfig)
Set member sendConfig.
Data was left in the buffer, but not enough to deserialize.
External serialize buffer with no copy semantics.
Data was left in in the buffer, but not enough to deserialize.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void resetSer() override
Reset serialization pointer to beginning of buffer.
Fw::Buffer allocate_out(FwIndexType portNum, FwSizeType size) const
Invoke output port allocate.
Send only while the section is enabled.
Deserialized type ID didn't match.
void log_WARNING_HI_ConfigReloadFailed(const Fw::DeserialStatus &status) const
Enabled and disabled states.
U16 FwTlmPacketizeIdType
The type of a telemetry packet identifier.
Command successfully executed.
void log_WARNING_HI_ConfigMirrorAllocFailed()
void clear() override
Clear the map.
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const FwChanIdType startLevel)
virtual Serializable::SizeType getDeserializeSizeLeft() const =0
Get remaining deserialization buffer size.
bool isValid() const
Check raw enum value for validity.
Parameter to control section configuration.
uint8_t U8
8-bit unsigned integer
enum T e
The raw enum value.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
enum T e
The raw enum value.
FwSizeType getSize() const
void log_ACTIVITY_HI_PacketConfigReport(const Svc::TelemetrySection §ion, U32 packetId, const Svc::PacketOverrideConfig &override, const Svc::TlmSendConfig &effective) const
Command had execution error.
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
void log_WARNING_LO_ReloadRecordUnknownPacket(U32 packetId) const
PlatformIndexType FwIndexType
Svc::TelemetrySection::T get_section() const
Get member section.
locks a mutex within the current scope
void packetOverrideOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port packetOverrideOut.
void set_overrideType(Svc::PacketOverrideType::T overrideType)
Set member overrideType.
void log_WARNING_HI_OversizedChannel(FwChanIdType Id, FwSizeType valSize, FwSizeType expected)
Command failed validation.
RateGroupDivider component implementation.
No override: the packet follows its group.
void packetOverrideReturnOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port packetOverrideReturnOut.
Enum representing parameter validity.
U32 get_packetId() const
Get member packetId.
Svc::PacketOverrideConfig & get_override()
Get member override.
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
The send state is overridden; rates follow the group.
ExternalSerializeBufferWithMemberCopy getSerializer()
The size of the serial representation.
Both the send state and the rates are overridden.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
Auto-generated base for TlmPacketizer component.
Send; the section enable is ignored.