Class: OpenC3::IgnorePacketProtocol

Inherits:
Protocol show all
Defined in:
lib/openc3/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

#allow_empty_data, #extra, #interface

Instance Method Summary collapse

Methods inherited from Protocol

#connect_reset, #disconnect_reset, #post_write_interface, #protocol_cmd, #read_data, #reset, #write_data

Constructor Details

#initialize(target_name, packet_name, allow_empty_data = nil) ⇒ IgnorePacketProtocol

Returns a new instance of IgnorePacketProtocol.

Parameters:

  • target_name (String)

    Target name

  • packet_name (String)

    Packet name



33
34
35
36
37
38
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 33

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



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 40

def read_packet(packet)
  # Need to make sure packet is identified and defined
  target_names = nil
  target_names = @interface.tlm_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



53
54
55
56
57
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 53

def write_packet(packet)
  return :STOP if packet.target_name == @target_name && packet.packet_name == @packet_name

  return super(packet)
end