F´ Flight Software - C/C++ Documentation  NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TlmChanImplTask.cpp
Go to the documentation of this file.
1 
14 #include <cstring>
15 #include <Fw/Types/BasicTypes.hpp>
16 #include <Fw/Types/Assert.hpp>
17 #include <Fw/Tlm/TlmPacket.hpp>
18 #include <Fw/Com/ComBuffer.hpp>
19 
20 #include <stdio.h>
21 
22 namespace Svc {
23 
25  // Only write packets if connected
26  if (not this->isConnected_PktSend_OutputPort(0)) {
27  return;
28  }
29 
30  // lock mutex long enough to modify active telemetry buffer
31  // so the data can be read without worrying about updates
32  this->lock();
33  this->m_activeBuffer = 1 - this->m_activeBuffer;
34  // set activeBuffer to not updated
35  for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) {
36  this->m_tlmEntries[this->m_activeBuffer].buckets[entry].updated = false;
37  }
38  this->unLock();
39 
40  // go through each entry and send a packet if it has been updated
41 
42  for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) {
43  TlmEntry* p_entry = &this->m_tlmEntries[1-this->m_activeBuffer].buckets[entry];
44  if ((p_entry->updated) && (p_entry->used)) {
45  this->m_tlmPacket.setId(p_entry->id);
46  this->m_tlmPacket.setTimeTag(p_entry->lastUpdate);
47  this->m_tlmPacket.setTlmBuffer(p_entry->buffer);
48  this->m_comBuffer.resetSer();
50  FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
51  p_entry->updated = false;
52  this->PktSend_out(0,this->m_comBuffer,0);
53  }
54  }
55  }
56 
57 }
Svc::TlmChanImpl::tlmEntry::lastUpdate
Fw::Time lastUpdate
last updated time
Definition: TlmChanImpl.hpp:53
TlmChanImpl.hpp
Component that stores telemetry channel values.
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::TlmPacket::serialize
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
Definition: TlmPacket.cpp:20
Svc::TlmChanImpl::tlmEntry::updated
bool updated
set whenever a value has been written. Used to skip if writing out values for downlinking
Definition: TlmChanImpl.hpp:52
ComBuffer.hpp
Fw::SerializeBufferBase::resetSer
void resetSer(void)
reset to beginning of buffer to reuse for serialization
Definition: Serializable.cpp:570
Svc::TlmChanImpl::m_activeBuffer
U32 m_activeBuffer
Definition: TlmChanImpl.hpp:66
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Svc::TlmChanImpl::tlmEntry::used
bool used
if entry has been used
Definition: TlmChanImpl.hpp:56
Svc::TlmChanImpl::tlmEntry
Definition: TlmChanImpl.hpp:50
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Svc::TlmChanImpl::m_comBuffer
Fw::ComBuffer m_comBuffer
Definition: TlmChanImpl.hpp:69
Fw::TlmPacket::setId
void setId(FwChanIdType id)
Definition: TlmPacket.cpp:76
Svc::TlmChanImpl::tlmEntry::id
FwChanIdType id
telemetry id stored in slot
Definition: TlmChanImpl.hpp:51
TlmPacket.hpp
Svc::TlmChanImpl::m_tlmPacket
Fw::TlmPacket m_tlmPacket
Definition: TlmChanImpl.hpp:70
Svc::TlmChanImpl::tlmEntry::buffer
Fw::TlmBuffer buffer
buffer to store serialized telemetry
Definition: TlmChanImpl.hpp:54
Svc
Definition: ActiveLoggerComponentAc.cpp:22
Svc::TlmChanComponentBase::unLock
virtual void unLock(void)
Definition: TlmChanComponentAc.cpp:476
Svc::TlmChanImpl::Run_handler
void Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)
Handler for input port Run.
Definition: TlmChanImplTask.cpp:24
BasicTypes.hpp
Declares ISF basic types.
Fw::TlmPacket::setTlmBuffer
void setTlmBuffer(TlmBuffer &buffer)
Definition: TlmPacket.cpp:80
Svc::TlmChanImpl::TlmSet::buckets
TlmEntry buckets[TLMCHAN_HASH_BUCKETS]
set of buckets used in hash table
Definition: TlmChanImpl.hpp:62
Svc::TlmChanImpl::m_tlmEntries
struct Svc::TlmChanImpl::TlmSet m_tlmEntries[2]
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Fw::TlmPacket::setTimeTag
void setTimeTag(Time &timeTag)
Definition: TlmPacket.cpp:84