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, #read_protocol_input_base, #read_protocol_output_base, #reset, #write_data, #write_protocol_input_base, #write_protocol_output_base

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



28
29
30
31
32
33
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 28

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_detailsObject



61
62
63
64
65
66
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 61

def read_details
  result = super()
  result['target_name'] = @target_name
  result['packet_name'] = @packet_name
  return result
end

#read_packet(packet) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 35

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_detailsObject



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

def write_details
  result = super()
  result['target_name'] = @target_name
  result['packet_name'] = @packet_name
  return result
end

#write_packet(packet) ⇒ Object



48
49
50
51
52
# File 'lib/openc3/interfaces/protocols/ignore_packet_protocol.rb', line 48

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

  return super(packet)
end