28 "poll buffer size must be greater than zero"
32 "ring buffer size must be greater than zero"
43 m_inRing(m_ringBuffer, sizeof m_ringBuffer)
45 (void) memset(m_pollBuffer, 0,
sizeof m_pollBuffer);
54 m_protocol = &protocol;
57 protocol.
setup(*
this);
64 void Deframer ::cmdResponseIn_handler(
73 void Deframer ::framedIn_handler(
81 processBuffer(recvBuffer);
87 void Deframer ::schedIn_handler(
92 Fw::Buffer buffer(m_pollBuffer,
sizeof(m_pollBuffer));
96 processBuffer(buffer);
104 Fw::Buffer Deframer ::allocate(
const U32 size) {
108 void Deframer ::route(
Fw::Buffer& packetBuffer) {
121 bool deallocate =
true;
125 U8 *
const packetData = packetBuffer.
getData();
126 const U32 packetSize = packetBuffer.
getSize();
127 switch (packetType) {
133 status = com.
setBuff(packetData, packetSize);
140 "[ERROR] Serializing com buffer failed with status %d\n",
154 packetBuffer.
setData(packetData +
sizeof(packetType));
155 packetBuffer.
setSize(
static_cast<U32
>(packetSize -
sizeof(packetType)));
170 "[ERROR] Deserializing packet type failed with status %d\n",
186 void Deframer ::processBuffer(
Fw::Buffer& buffer) {
188 const U32 bufferSize = buffer.
getSize();
193 U32 remaining = bufferSize;
195 for (U32 i = 0; i < bufferSize; ++i) {
197 if (remaining == 0) {
206 m_inRing.
serialize(&bufferData[offset], serSize);
217 remaining -= serSize;
227 void Deframer ::processRing() {
240 for (U32 i = 0; i < ringCapacity; i++) {
244 if (remaining == 0) {
252 status = m_protocol->
deframe(m_inRing, needed);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
PlatformAssertArgType FwAssertArgType
U32 FwPacketDescriptorType
C++-compatible configuration header for fprime configuration.
@ POLL_OK
Poll successfully received data.
Status associated with the received data.
@ RECV_OK
Receive worked as expected.
SerializeBufferBase & getSerializeRepr()
Enum representing a command response.
static void log(const char *format,...)
log a formated string with supplied arguments
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
SerializeStatus setBuff(const U8 *src, Serializable::SizeType length)
sets buffer contents and size
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Auto-generated base for Deframer component.
void bufferDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferDeallocate.
void framedDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port framedDeallocate.
void bufferOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferOut.
Fw::Buffer bufferAllocate_out(FwIndexType portNum, U32 size)
Invoke output port bufferAllocate.
Drv::PollStatus framedPoll_out(FwIndexType portNum, Fw::Buffer &pollBuffer)
Invoke output port framedPoll.
bool isConnected_bufferOut_OutputPort(FwIndexType portNum)
void comOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comOut.
~Deframer()
Destroy Deframer instance.
void setup(DeframingProtocol &protocol)
Set up the instance.
Deframer(const char *const compName)
Construct Deframer instance.
Abstract base class representing a deframing protocol.
virtual DeframingStatus deframe(Types::CircularBuffer &buffer, U32 &needed)=0
DeframingStatus
Status of the deframing call.
@ DEFRAMING_STATUS_SUCCESS
@ DEFRAMING_INVALID_CHECKSUM
void setup(DeframingProtocolInterface &interface)
interface supplied to the deframing protocol
Fw::SerializeStatus serialize(const U8 *const buffer, const NATIVE_UINT_TYPE size)
NATIVE_UINT_TYPE get_free_size() const
NATIVE_UINT_TYPE get_allocated_size() const
NATIVE_UINT_TYPE get_capacity() const
Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount)
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
static const U32 POLL_BUFFER_SIZE
The size of the polling buffer in bytes.
static const U32 RING_BUFFER_SIZE
The size of the circular buffer in bytes.