Class: Cosmos::FixedProtocol
- Inherits:
-
BurstProtocol
- Object
- Protocol
- BurstProtocol
- Cosmos::FixedProtocol
- Defined in:
- lib/cosmos/interfaces/protocols/fixed_protocol.rb
Overview
Delineates packets by identifying them and then reading out their entire fixed length. Packets lengths can vary but they must all be fixed.
Instance Attribute Summary
Attributes inherited from Protocol
Instance Method Summary collapse
-
#initialize(min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry = true, fill_fields = false, unknown_raise = false, allow_empty_data = nil) ⇒ FixedProtocol
constructor
A new instance of FixedProtocol.
-
#read_packet(packet) ⇒ Object
Set the received_time, target_name and packet_name which we recorded when we identified this packet.
Methods inherited from BurstProtocol
#handle_sync_pattern, #log_discard, #read_data, #reset, #write_data, #write_packet
Methods inherited from Protocol
#connect_reset, #disconnect_reset, #post_write_interface, #read_data, #reset, #write_data, #write_packet
Constructor Details
#initialize(min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry = true, fill_fields = false, unknown_raise = false, allow_empty_data = nil) ⇒ FixedProtocol
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cosmos/interfaces/protocols/fixed_protocol.rb', line 37 def initialize( min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry = true, fill_fields = false, unknown_raise = false, allow_empty_data = nil ) super(discard_leading_bytes, sync_pattern, fill_fields, allow_empty_data) @min_id_size = Integer(min_id_size) @telemetry = telemetry @unknown_raise = ConfigParser.handle_true_false(unknown_raise) @received_time = nil @target_name = nil @packet_name = nil end |
Instance Method Details
#read_packet(packet) ⇒ Object
Set the received_time, target_name and packet_name which we recorded when we identified this packet. The server will also do this but since we know the information here, we perform this optimization.
58 59 60 61 62 63 |
# File 'lib/cosmos/interfaces/protocols/fixed_protocol.rb', line 58 def read_packet(packet) packet.received_time = @received_time packet.target_name = @target_name packet.packet_name = @packet_name return packet end |