-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Submission of UartFramer component (#1261)
* Changed PrmBuffer m_data to m_bufferData for VxWorks * More m_data instances * VxWorks and virtual destructors * Added Vxworks fatal handler compile * Fixed active component schematron * Changed ActiveTextLogger to use Fw::Logger to avoid VxWorks mushing of output * Importing TlmPacketizer * fix(BufferManager): size checking logic and assert cleanup * fix: change U64 to POINTER_CAST * TlmPacketizer unit tests pass * Adding codegen for packets * More work on packet generator * Fixing generated pathnames * Fixes to topology for TlmPacketizer and TlmPacketizer name updates * Typo * Fix TlmPacketizer unit tests after name change * Additional fixes to packet telemetry script and packet contents * ran tlm_packet_gen.py through black formatter * Added spellcheck words * Added join() for pktTlm * Fix to ai_parser.py formatting * More spell check exclusions * Updated headers and const * Code copied in * Starting on SDD * new image path * More SDD * SDD done * Unit tests complete * sdd typo Co-authored-by: Kyle Botteon <botteon@jpl.nasa.gov>
- Loading branch information
Showing
16 changed files
with
2,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#### | ||
# F prime CMakeLists.txt: | ||
# | ||
# SOURCE_FILES: combined list of source and autocoding diles | ||
# MOD_DEPS: (optional) module dependencies | ||
# | ||
#### | ||
set(MOD_DEPS Os) | ||
|
||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/UartFramer.fpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/UartFramer.cpp" | ||
) | ||
register_fprime_module() | ||
|
||
## UTs ### | ||
# Note: this UT expects user input | ||
set(UT_MOD_DEPS | ||
Os | ||
) | ||
set(UT_SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/UartFramer.fpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMain.cpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp" | ||
) | ||
register_fprime_ut() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// ====================================================================== | ||
// \title UartFramer.cpp | ||
// \author tcanham | ||
// \brief cpp file for UartFramer component implementation class | ||
// | ||
// \copyright | ||
// Copyright 2009-2015, by the California Institute of Technology. | ||
// ALL RIGHTS RESERVED. United States Government Sponsorship | ||
// acknowledged. | ||
// | ||
// ====================================================================== | ||
|
||
|
||
#include <Drv/UartFramer/UartFramer.hpp> | ||
#include "Fw/Types/BasicTypes.hpp" | ||
#include "Fw/Types/Assert.hpp" | ||
|
||
namespace Drv { | ||
|
||
// ---------------------------------------------------------------------- | ||
// Construction, initialization, and destruction | ||
// ---------------------------------------------------------------------- | ||
|
||
UartFramer :: | ||
UartFramer( | ||
const char *const compName | ||
) : UartFramerComponentBase(compName), m_size(0) | ||
{ | ||
|
||
} | ||
|
||
void UartFramer :: | ||
init( | ||
const NATIVE_INT_TYPE instance | ||
) | ||
{ | ||
UartFramerComponentBase::init(instance); | ||
} | ||
|
||
UartFramer :: | ||
~UartFramer() | ||
{ | ||
|
||
} | ||
|
||
void UartFramer::allocate(NATIVE_UINT_TYPE number, NATIVE_UINT_TYPE size) { | ||
|
||
FW_ASSERT(size > 0, size); | ||
this->m_size = size; | ||
|
||
Fw::Buffer buff; | ||
// request a buffer and pass it on to the UART for each requested | ||
for (NATIVE_UINT_TYPE buffNum = 0; buffNum < number; buffNum++) { | ||
buff = this->DeframerAllocate_out(0,this->m_size); | ||
FW_ASSERT(buff.getSize() == size,buff.getSize(),size); | ||
FW_ASSERT(buff.getData()); | ||
this->readBufferSend_out(0,buff); | ||
} | ||
|
||
} | ||
|
||
// ---------------------------------------------------------------------- | ||
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
Drv::SendStatus UartFramer :: | ||
Framer_handler( | ||
const NATIVE_INT_TYPE portNum, | ||
Fw::Buffer &sendBuffer | ||
) | ||
{ | ||
this->serialSend_out(0,sendBuffer); | ||
this->FramerDeallocate_out(0,sendBuffer); | ||
// no status from send, so return OK | ||
return Drv::SendStatus::SEND_OK; | ||
} | ||
|
||
void UartFramer :: | ||
serialRecv_handler( | ||
const NATIVE_INT_TYPE portNum, | ||
Fw::Buffer &serBuffer, | ||
Drv::SerialReadStatus &status | ||
) | ||
{ | ||
|
||
Drv::RecvStatus outStat = Drv::RecvStatus::RECV_OK; | ||
// Check the UART status | ||
if (status != Drv::SerialReadStatus::SER_OK) { | ||
outStat = Drv::RecvStatus::RECV_ERROR; | ||
} | ||
|
||
// Forward buffer to deframer | ||
this->Deframer_out(0,serBuffer,outStat); | ||
|
||
// allocate a replacement buffer and send it to | ||
// the UART driver | ||
Fw::Buffer newBuff = this->DeframerAllocate_out(0,this->m_size); | ||
if (newBuff.getSize() != this->m_size) { | ||
this->log_WARNING_HI_BuffErr(); | ||
} else { | ||
this->readBufferSend_out(0,newBuff); | ||
} | ||
|
||
} | ||
|
||
} // end namespace Drv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Drv { | ||
|
||
passive component UartFramer { | ||
|
||
# ---------------------------------------------------------------------- | ||
# Ports for UART | ||
# ---------------------------------------------------------------------- | ||
|
||
@ port to send a buffer for reads to the UART driver | ||
output port readBufferSend: Fw.BufferSend | ||
|
||
@ send a UART buffer | ||
output port serialSend: Drv.SerialWrite | ||
|
||
@ receive a buffer from the UART - one of the above | ||
sync input port serialRecv: Drv.SerialRead | ||
|
||
# ---------------------------------------------------------------------- | ||
# Ports for Framer/Deframer | ||
# ---------------------------------------------------------------------- | ||
|
||
@ Buffer from Framer | ||
sync input port Framer: Drv.ByteStreamSend | ||
|
||
@ Buffer to Deframer | ||
output port Deframer: Drv.ByteStreamRecv | ||
|
||
# ---------------------------------------------------------------------- | ||
# Ports to get buffers | ||
# ---------------------------------------------------------------------- | ||
|
||
@ Allocation output port - will be sent to Deframer for deallocation | ||
output port DeframerAllocate: Fw.BufferGet | ||
|
||
@ Deallocation output port - deallocation of Framer buffers | ||
output port FramerDeallocate: Fw.BufferSend | ||
|
||
|
||
# ---------------------------------------------------------------------- | ||
# Special F Prime ports | ||
# ---------------------------------------------------------------------- | ||
|
||
event port Log | ||
|
||
text event port LogText | ||
|
||
time get port Time | ||
|
||
# ---------------------------------------------------------------------- | ||
# Events | ||
# ---------------------------------------------------------------------- | ||
|
||
@ UART open error | ||
event BuffErr() \ | ||
severity warning high \ | ||
id 0 \ | ||
format "Couldn't get UART buffer" \ | ||
throttle 5 | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// ====================================================================== | ||
// \title UartFramer.hpp | ||
// \author tcanham | ||
// \brief hpp file for UartFramer component implementation class | ||
// | ||
// \copyright | ||
// Copyright 2009-2015, by the California Institute of Technology. | ||
// ALL RIGHTS RESERVED. United States Government Sponsorship | ||
// acknowledged. | ||
// | ||
// ====================================================================== | ||
|
||
#ifndef UartFramer_HPP | ||
#define UartFramer_HPP | ||
|
||
#include "Drv/UartFramer/UartFramerComponentAc.hpp" | ||
|
||
namespace Drv { | ||
|
||
class UartFramer : | ||
public UartFramerComponentBase | ||
{ | ||
|
||
public: | ||
|
||
// ---------------------------------------------------------------------- | ||
// Construction, initialization, and destruction | ||
// ---------------------------------------------------------------------- | ||
|
||
//! Construct object UartFramer | ||
//! | ||
UartFramer( | ||
const char *const compName /*!< The component name*/ | ||
); | ||
|
||
//! Initialize object UartFramer | ||
//! | ||
void init( | ||
const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/ | ||
); | ||
|
||
//! Destroy object UartFramer | ||
//! | ||
~UartFramer(); | ||
|
||
|
||
//! Allocate pool of buffers for UART receive - BufferManager and UART | ||
// instances must be connected and ready. BufferManager should have at least | ||
// number+1 buffers allocated | ||
void allocate(NATIVE_UINT_TYPE number, NATIVE_UINT_TYPE size); | ||
|
||
PRIVATE: | ||
|
||
// ---------------------------------------------------------------------- | ||
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
//! Handler implementation for Framer | ||
//! | ||
Drv::SendStatus Framer_handler( | ||
const NATIVE_INT_TYPE portNum, /*!< The port number*/ | ||
Fw::Buffer &sendBuffer | ||
); | ||
|
||
//! Handler implementation for serialRecv | ||
//! | ||
void serialRecv_handler( | ||
const NATIVE_INT_TYPE portNum, /*!< The port number*/ | ||
Fw::Buffer &serBuffer, /*!< | ||
Buffer containing data | ||
*/ | ||
Drv::SerialReadStatus &status /*!< | ||
Status of read | ||
*/ | ||
); | ||
|
||
// Private data members | ||
|
||
NATIVE_UINT_TYPE m_size; //!< size of UART buffers | ||
|
||
|
||
}; | ||
|
||
} // end namespace Drv | ||
|
||
#endif |
Binary file not shown.
Oops, something went wrong.