Method: OpenC3::PacketItemParser#verify_parameters

Defined in:
lib/openc3/packets/parsers/packet_item_parser.rb

#verify_parameters(cmd_or_tlm) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/openc3/packets/parsers/packet_item_parser.rb', line 50

def verify_parameters(cmd_or_tlm)
  if @parser.keyword.include?('ITEM') && cmd_or_tlm == PacketConfig::COMMAND
    raise @parser.error("ITEM types are only valid with TELEMETRY", @usage)
  elsif @parser.keyword.include?('PARAMETER') && cmd_or_tlm == PacketConfig::TELEMETRY
    raise @parser.error("PARAMETER types are only valid with COMMAND", @usage)
  end

  # The usage is formatted with brackets <XXX> around each option so
  # count the number of open brackets to determine the number of options
  max_options = @usage.count("<")
  # The last two options (description and endianness) are optional
  @parser.verify_num_parameters(max_options - 2, max_options, @usage)
  @parser.verify_parameter_naming(1) # Item name is the 1st parameter
end