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);
58 m_protocol = &protocol;
61 protocol.
setup(*
this);
68 void Deframer ::cmdResponseIn_handler(
77 void Deframer ::framedIn_handler(
85 processBuffer(recvBuffer);
91 void Deframer ::schedIn_handler(
96 Fw::Buffer buffer(m_pollBuffer,
sizeof(m_pollBuffer));
100 processBuffer(buffer);
108 Fw::Buffer Deframer ::allocate(
const U32 size) {
112 void Deframer ::route(
Fw::Buffer& packetBuffer) {
125 bool deallocate =
true;
129 U8 *
const packetData = packetBuffer.
getData();
130 const U32 packetSize = packetBuffer.
getSize();
131 switch (packetType) {
137 status = com.
setBuff(packetData, packetSize);
144 "[ERROR] Serializing com buffer failed with status %d\n",
158 packetBuffer.
setData(packetData +
sizeof(packetType));
159 packetBuffer.
setSize(packetSize -
sizeof(packetType));
174 "[ERROR] Deserializing packet type failed with status %d\n",
190 void Deframer ::processBuffer(
Fw::Buffer& buffer) {
192 const U32 bufferSize = buffer.
getSize();
197 U32 remaining = bufferSize;
199 for (U32 i = 0; i < bufferSize; ++i) {
201 if (remaining == 0) {
210 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);
264 FW_ASSERT(needed <= remaining, needed, remaining);
277 FW_ASSERT(needed > remaining, needed, remaining);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
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 logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
void init()
Object initializer.
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
SerializeStatus setBuff(const U8 *src, NATIVE_UINT_TYPE length)
sets buffer contents and size
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Auto-generated base for Deframer component.
void bufferDeallocate_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferDeallocate.
void framedDeallocate_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port framedDeallocate.
Fw::Buffer bufferAllocate_out(NATIVE_INT_TYPE portNum, U32 size)
Invoke output port bufferAllocate.
Drv::PollStatus framedPoll_out(NATIVE_INT_TYPE portNum, Fw::Buffer &pollBuffer)
Invoke output port framedPoll.
void bufferOut_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferOut.
void comOut_out(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comOut.
bool isConnected_bufferOut_OutputPort(NATIVE_INT_TYPE portNum)
~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.