F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
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 
24  void TlmChanImpl::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
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();
49  Fw::SerializeStatus stat = this->m_tlmPacket.serialize(this->m_comBuffer);
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 }
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
ComBuffer.hpp
Fw::SerializeBufferBase::resetSer
void resetSer(void)
reset to beginning of buffer to reuse for serialization
Definition: Serializable.cpp:565
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
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
Fw::TlmPacket::setId
void setId(FwChanIdType id)
Definition: TlmPacket.cpp:76
TlmPacket.hpp
Svc
Definition: ActiveRateGroupImplCfg.hpp:18
BasicTypes.hpp
Declares ISF basic types.
Fw::TlmPacket::setTlmBuffer
void setTlmBuffer(TlmBuffer &buffer)
Definition: TlmPacket.cpp:80
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