28 "poll buffer size must be greater than zero"
32 "ring buffer size must be greater than zero"
39Deframer ::Deframer(
const char*
const compName) :
43 m_inRing(m_ringBuffer, sizeof m_ringBuffer)
45 (void) memset(m_pollBuffer, 0,
sizeof m_pollBuffer);
48Deframer ::~Deframer() {}
54 m_protocol = &protocol;
57 protocol.
setup(*
this);
64void Deframer ::cmdResponseIn_handler(
73void Deframer ::framedIn_handler(
81 processBuffer(recvBuffer);
84 framedDeallocate_out(0, recvBuffer);
87void Deframer ::schedIn_handler(
92 Fw::Buffer buffer(m_pollBuffer,
sizeof(m_pollBuffer));
96 processBuffer(buffer);
104Fw::Buffer Deframer ::allocate(
const U32 size) {
105 return bufferAllocate_out(0, size);
108void 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);
136 comOut_out(0, com, 0);
140 "[ERROR] Serializing com buffer failed with status %d\n",
150 if (isConnected_bufferOut_OutputPort(0)) {
154 packetBuffer.
setData(packetData +
sizeof(packetType));
155 packetBuffer.
setSize(
static_cast<U32
>(packetSize -
sizeof(packetType)));
157 bufferOut_out(0, packetBuffer);
170 "[ERROR] Deserializing packet type failed with status %d\n",
177 bufferDeallocate_out(0, packetBuffer);
186void 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;
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,
268 m_inRing.rotate(needed);
270 m_inRing.get_allocated_size() == remaining - needed,
293 m_inRing.get_allocated_size() == remaining - 1,
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.
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.