33 static_cast<FwAssertArgType>(fixedFrameSize));
41 this->m_fecf = frameErrorControlField;
44 for (
U8 ind = 0; ind <
sizeof(this->m_vcs) /
sizeof(AosVc); ind++) {
45 AosVc& currentVc = this->m_vcs[ind];
48 currentVc.vc_struct_index = ind;
49 currentVc.frame.buffer = {currentVc.frame.backer, fixedFrameSize};
51 currentVc.idle_packet_types = idlePvns;
62 AosVc& currentVc = this->get_vc_struct(context);
63 FW_ASSERT(currentVc.virtualChannelId == vcId);
67 FW_ASSERT(currentVc.frame.state == BufferOwnershipState::OWNED,
68 static_cast<FwAssertArgType>(currentVc.frame.state));
72 if (!currentVc.past_first_fresh_packet) {
74 setup_header(context);
75 setup_m_pdu_header(context);
78 currentVc.past_first_fresh_packet =
true;
82 pack_pad_send(data, context);
85 void AosFramer::compute_and_inject_fecf(AosVc& currentVc) {
95 trailer.set_fecf(crc);
98 auto frameSerializer = currentVc.frame.buffer.getSerializer();
102 status = frameSerializer.serializeFrom(trailer);
115 void AosFramer ::dataReturnIn_handler(
FwIndexType portNum,
119 AosVc& currentVc = this->get_vc_struct(context);
122 FW_ASSERT(buffer_belongs(frameBuffer, currentVc.frame.backer,
sizeof(currentVc.frame.backer)));
123 currentVc.frame.state = BufferOwnershipState::OWNED;
126 if (currentVc.outstanding.packet.isValid()) {
127 this->pack_pad_send(currentVc.outstanding.packet, currentVc.outstanding.context, currentVc.outstanding.offset);
135 AosVc& currentVc = this->m_vcs[ind];
138 FW_ASSERT(currentVc.vc_struct_index == ind);
145 AosVc& currentVc = this->get_vc_struct(context);
158 U32 frameCountAndSignaling =
static_cast<U32
>((currentVc.virtualFrameCount & 0x00FFFFFFU)
165 frameCountAndSignaling |=
169 frameCountAndSignaling |=
static_cast<U32
>((currentVc.virtualFrameCount & 0x0F000000) >> 24);
171 header.set_globalVcId(globalVcId);
172 header.set_frameCountAndSignaling(frameCountAndSignaling);
175 currentVc.virtualFrameCount++;
184 auto frameSerializer = currentVc.frame.buffer.getSerializer();
186 status = frameSerializer.moveSerToOffset(0);
189 status = frameSerializer.serializeFrom(header);
195 AosVc& currentVc = this->get_vc_struct(context);
197 M_PDUHeader muxedPdu;
200 muxedPdu.set_firstHeaderPointer(0xFFFF);
204 muxedPdu.set_firstHeaderPointer(currentVc.current_payload_offset);
207 auto frameSerializer = currentVc.frame.buffer.getSerializer();
211 frameSerializer.serializeFrom(muxedPdu);
220 return (buffer.
getData() >= start && buffer.
getData() < start + size);
223 void AosFramer::check_and_send_vc(AosFramer::AosVc& currentVc) {
224 const FwSizeType maxPayload = currentVc.frame.buffer.getSize() - get_min_size();
227 if (currentVc.current_payload_offset == maxPayload) {
229 if (!currentVc.past_first_fresh_packet) {
231 setup_header(currentVc.outstanding.context);
234 setup_m_pdu_header(currentVc.outstanding.context,
true);
239 compute_and_inject_fecf(currentVc);
243 FW_ASSERT(currentVc.frame.state == BufferOwnershipState::OWNED);
244 currentVc.frame.state = BufferOwnershipState::NOT_OWNED;
247 currentVc.current_payload_offset = 0;
248 currentVc.past_first_fresh_packet =
false;
251 this->
dataOut_out(0, currentVc.frame.buffer, currentVc.outstanding.context);
261 pack_packet(data, context, dataOffset);
264 AosVc& currentVc = this->get_vc_struct(context);
271 const FwSizeType maxPayload = currentVc.frame.buffer.getSize() - min_size;
273 if (currentVc.current_payload_offset < maxPayload) {
275 fill_with_idle_packet(currentVc, context);
280 check_and_send_vc(currentVc);
288 AosVc& currentVc = this->get_vc_struct(context);
290 const FwSizeType maxPayload = currentVc.frame.buffer.getSize() - min_size;
291 const FwSizeType bytesAvailable = maxPayload - currentVc.current_payload_offset;
292 FW_ASSERT(bytesAvailable < currentVc.frame.buffer.getSize(),
293 static_cast<FwAssertArgType>(min_size + currentVc.current_payload_offset));
300 auto frameSerializer = currentVc.frame.buffer.getSerializer();
301 status = frameSerializer.moveSerToOffset(START_OF_PAYLOAD + currentVc.current_payload_offset);
304 const U8* dataStart = data.
getData() + dataOffset;
309 if (dataSize <= bytesAvailable) {
311 currentVc.outstanding.offset = 0;
314 dataSize = bytesAvailable;
317 currentVc.outstanding.offset = dataOffset + dataSize;
318 currentVc.outstanding.packet = data;
325 currentVc.current_payload_offset =
static_cast<U16
>(currentVc.current_payload_offset + dataSize);
328 currentVc.outstanding.context = context;
331 if (currentVc.outstanding.offset == 0) {
333 if (!buffer_belongs(data, currentVc.spp_idle.backer,
sizeof(currentVc.spp_idle.backer))) {
338 currentVc.outstanding.packet = {};
339 currentVc.outstanding.offset = 0;
350 SpacePacketHeader header;
351 header.set_packetIdentification(idleApid);
352 header.set_packetSequenceControl(
354 header.set_packetDataLength(lengthToken);
371 FW_ASSERT(vc.frame.buffer.getSize() < std::numeric_limits<U16>::max(),
373 const U16 pduSize =
static_cast<U16
>(vc.frame.buffer.getSize() - overhead);
376 const U16 idlePacketSize =
static_cast<U16
>(pduSize - vc.current_payload_offset);
379 auto frameSerializer = vc.frame.buffer.getSerializer();
380 Fw::SerializeStatus status = frameSerializer.moveSerToOffset(START_OF_PAYLOAD + vc.current_payload_offset);
385 if (!vc.past_first_fresh_packet) {
387 setup_header(context);
388 setup_m_pdu_header(context);
391 vc.past_first_fresh_packet =
true;
401 else if (idlePacketSize < 7) {
405 FW_ASSERT(!vc.outstanding.packet.isValid());
408 vc.outstanding.packet = {vc.spp_idle.backer, MIN_SPP_LENGTH};
411 auto pduSerializer = vc.outstanding.packet.getSerializer();
412 serialize_idle_spp_packet(pduSerializer, MIN_SPP_LENGTH);
421 pack_packet(vc.outstanding.packet, filtered_context);
424 serialize_idle_spp_packet(frameSerializer, idlePacketSize);
427 vc.current_payload_offset =
static_cast<U16
>(vc.current_payload_offset + idlePacketSize);
Serialization/Deserialization operation was successful.
static U16 compute(const U8 *buffer, U32 length)
compute CRC16 for a buffer
Advanced Orbiting Systems SDL.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
~AosFramer()
Destroy AosFramer object.
Auto-generated base for AosFramer component.
void set_sendNow(bool sendNow)
Set member sendNow.
bool isConnected_comStatusOut_OutputPort(FwIndexType portNum)
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataReturnOut.
AosFramer(const char *const compName)
Construct AosFramer object.
SerializeStatus
forward declaration for string
bool get_sendNow() const
Get member sendNow.
Omit length from serialization.
U8 get_vcId() const
Get member vcId.
The size of the serial representation.
uint8_t U8
8-bit unsigned integer
void comStatusOut_out(FwIndexType portNum, Fw::Success &condition)
Invoke output port comStatusOut.
FwSizeType getSize() const
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.
Per Space Packet Standard, all 1s (11bits) is reserved for Idle Packets.
void configure(U32 fixedFixedSize, bool frameErrorControlField, U8 idlePvns=PvnBitfield::SPP_MASK)
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
void dataOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataOut.