28 "poll buffer size must be greater than zero"
32 "ring buffer size must be greater than zero"
39Deframer ::Deframer(
const char*
const compName) :
40 DeframerComponentBase(compName),
43 m_inRing(m_ringBuffer, sizeof m_ringBuffer)
45 (void) memset(m_pollBuffer, 0,
sizeof m_pollBuffer);
49 DeframerComponentBase::init(instance);
52Deframer ::~Deframer() {}
58 m_protocol = &protocol;
61 protocol.
setup(*
this);
68void Deframer ::cmdResponseIn_handler(
72 const Fw::CmdResponse& response
77void Deframer ::framedIn_handler(
80 const Drv::RecvStatus& recvStatus
83 if (recvStatus.e == Drv::RecvStatus::RECV_OK) {
85 processBuffer(recvBuffer);
88 framedDeallocate_out(0, recvBuffer);
91void Deframer ::schedIn_handler(
96 Fw::Buffer buffer(m_pollBuffer,
sizeof(m_pollBuffer));
97 const Drv::PollStatus status = framedPoll_out(0, buffer);
98 if (status.e == Drv::PollStatus::POLL_OK) {
100 processBuffer(buffer);
108Fw::Buffer Deframer ::allocate(
const U32 size) {
109 return bufferAllocate_out(0, size);
112void 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);
140 comOut_out(0, com, 0);
144 "[ERROR] Serializing com buffer failed with status %d\n",
154 if (isConnected_bufferOut_OutputPort(0)) {
158 packetBuffer.
setData(packetData +
sizeof(packetType));
159 packetBuffer.
setSize(packetSize -
sizeof(packetType));
161 bufferOut_out(0, packetBuffer);
174 "[ERROR] Deserializing packet type failed with status %d\n",
181 bufferDeallocate_out(0, packetBuffer);
190void 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;
227void Deframer ::processRing() {
240 for (U32 i = 0; i < ringCapacity; i++) {
242 remaining = m_inRing.get_allocated_size();
244 if (remaining == 0) {
252 status = m_protocol->deframe(m_inRing, needed);
255 m_inRing.get_allocated_size() == remaining,
256 m_inRing.get_allocated_size(),
264 FW_ASSERT(needed <= remaining, needed, remaining);
265 m_inRing.rotate(needed);
267 m_inRing.get_allocated_size() == remaining - needed,
268 m_inRing.get_allocated_size(),
277 FW_ASSERT(needed > remaining, needed, remaining);
287 m_inRing.get_allocated_size() == remaining - 1,
288 m_inRing.get_allocated_size(),
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
U32 FwPacketDescriptorType
C++-compatible configuration header for fprime configuration.
SerializeBufferBase & getSerializeRepr()
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)
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
Abstract base class representing a deframing protocol.
DeframingStatus
Status of the deframing call.
@ DEFRAMING_STATUS_SUCCESS
@ DEFRAMING_INVALID_CHECKSUM
void setup(DeframingProtocolInterface &interface)
interface supplied to the deframing protocol
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.