Class: Cosmos::IgnorePacketProtocol
- Defined in:
- lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb
Overview
Ignore a specific packet by not letting it through the protocol
Instance Attribute Summary
Attributes inherited from Protocol
Instance Method Summary collapse
-
#initialize(target_name, packet_name, allow_empty_data = nil) ⇒ IgnorePacketProtocol
constructor
A new instance of IgnorePacketProtocol.
- #read_packet(packet) ⇒ Object
- #write_packet(packet) ⇒ Object
Methods inherited from Protocol
#connect_reset, #disconnect_reset, #post_write_interface, #read_data, #reset, #write_data
Constructor Details
#initialize(target_name, packet_name, allow_empty_data = nil) ⇒ IgnorePacketProtocol
Returns a new instance of IgnorePacketProtocol.
30 31 32 33 34 35 |
# File 'lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb', line 30 def initialize(target_name, packet_name, allow_empty_data = nil) super(allow_empty_data) System.telemetry.packet(target_name, packet_name) @target_name = target_name @packet_name = packet_name end |
Instance Method Details
#read_packet(packet) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb', line 37 def read_packet(packet) # Need to make sure packet is identified and defined target_names = nil target_names = @interface.target_names if @interface identified_packet = System.telemetry.identify_and_define_packet(packet, target_names) if identified_packet if identified_packet.target_name == @target_name && identified_packet.packet_name == @packet_name return :STOP end end return super(packet) end |
#write_packet(packet) ⇒ Object
50 51 52 53 54 |
# File 'lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb', line 50 def write_packet(packet) return :STOP if packet.target_name == @target_name && packet.packet_name == @packet_name return super(packet) end |