Class: Cosmos::CcsdsTransferFrames::CcsdsTransferFrameProtocol
- Inherits:
-
Protocol
- Object
- Protocol
- Cosmos::CcsdsTransferFrames::CcsdsTransferFrameProtocol
- Defined in:
- lib/cosmos/ccsds_transfer_frames/ccsds_transfer_frame_protocol.rb
Overview
Given a stream of ccsds transfer frames, extract ccsds space packets based on the first header pointer and packet lengths.
Only read is supported.
Defined Under Namespace
Classes: VirtualChannel
Constant Summary collapse
- FRAME_PRIMARY_HEADER_LENGTH =
6- FIRST_HEADER_POINTER_BIT_OFFSET =
FRAME_PRIMARY_HEADER_LENGTH * 8 - 11
- FIRST_HEADER_POINTER_BITS =
11- IDLE_FRAME_FIRST_HEADER_POINTER =
0b11111111110- NO_PACKET_START_FIRST_HEADER_POINTER =
0b11111111111- FRAME_VIRTUAL_CHANNEL_BIT_OFFSET =
12- FRAME_VIRTUAL_CHANNEL_BITS =
3- VIRTUAL_CHANNEL_COUNT =
8- FRAME_OPERATIONAL_CONTROL_FIELD_LENGTH =
4- FRAME_ERROR_CONTROL_FIELD_LENGTH =
2- SPACE_PACKET_HEADER_LENGTH =
6- SPACE_PACKET_LENGTH_BIT_OFFSET =
4 * 8
- SPACE_PACKET_LENGTH_BITS =
2 * 8
- SPACE_PACKET_APID_BITS =
11- SPACE_PACKET_APID_BIT_OFFSET =
2 * 8 - SPACE_PACKET_APID_BITS
- IDLE_PACKET_APID =
0b11111111111
Instance Method Summary collapse
-
#initialize(transfer_frame_length, transfer_frame_secondary_header_length, transfer_frame_has_operational_control_field, transfer_frame_has_frame_error_control_field, prefix_packets = false, include_idle_packets = false, allow_empty_data = nil) ⇒ CcsdsTransferFrameProtocol
constructor
A new instance of CcsdsTransferFrameProtocol.
- #read_data(data) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(transfer_frame_length, transfer_frame_secondary_header_length, transfer_frame_has_operational_control_field, transfer_frame_has_frame_error_control_field, prefix_packets = false, include_idle_packets = false, allow_empty_data = nil) ⇒ CcsdsTransferFrameProtocol
Returns a new instance of CcsdsTransferFrameProtocol.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cosmos/ccsds_transfer_frames/ccsds_transfer_frame_protocol.rb', line 63 def initialize( transfer_frame_length, transfer_frame_secondary_header_length, transfer_frame_has_operational_control_field, transfer_frame_has_frame_error_control_field, prefix_packets = false, include_idle_packets = false, allow_empty_data = nil) super(allow_empty_data) @frame_length = Integer(transfer_frame_length) @frame_headers_length = FRAME_PRIMARY_HEADER_LENGTH + Integer(transfer_frame_secondary_header_length) @frame_trailer_length = 0 has_ocf = ConfigParser.handle_true_false(transfer_frame_has_operational_control_field) @frame_trailer_length += FRAME_OPERATIONAL_CONTROL_FIELD_LENGTH if has_ocf has_fecf = ConfigParser.handle_true_false(transfer_frame_has_frame_error_control_field) @frame_trailer_length += FRAME_ERROR_CONTROL_FIELD_LENGTH if has_fecf @frame_data_field_length = @frame_length - @frame_headers_length - @frame_trailer_length @packet_prefix_length = 0 @prefix_packets = ConfigParser.handle_true_false(prefix_packets) @packet_prefix_length += @frame_headers_length if @prefix_packets @include_idle_packets = ConfigParser.handle_true_false(include_idle_packets) end |
Instance Method Details
#read_data(data) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cosmos/ccsds_transfer_frames/ccsds_transfer_frame_protocol.rb', line 98 def read_data(data) @data << data if (@data.length >= @frame_length) frame = @data.slice!(0, @frame_length) process_frame(frame) end packet_data = get_packet() # Potentially allow blank string to be sent to other protocols if no # packet is ready in this one if (Symbol === packet_data && packet_data == :STOP && data.length <= 0) return super(data) end return packet_data end |
#reset ⇒ Object
92 93 94 95 96 |
# File 'lib/cosmos/ccsds_transfer_frames/ccsds_transfer_frame_protocol.rb', line 92 def reset super() @data = '' @virtual_channels = Array.new(VIRTUAL_CHANNEL_COUNT) { VirtualChannel.new } end |