lib/cosmos/packets/parsers/packet_parser.rb in cosmos-4.5.2-java vs lib/cosmos/packets/parsers/packet_parser.rb in cosmos-5.0.2.pre.beta2
- old
+ new
@@ -1,19 +1,27 @@
# encoding: ascii-8bit
-# Copyright 2014 Ball Aerospace & Technologies Corp.
+# Copyright 2022 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
-# under the terms of the GNU General Public License
+# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# This program may also be used under the terms of a commercial or
+# enterprise edition license of COSMOS if purchased from the
+# copyright holder
require 'cosmos/packets/packet'
module Cosmos
-
class PacketParser
# @param parser [ConfigParser] Configuration parser
# @param target_name [String] The name of the target to create the packet
# under. If the target name is 'SYSTEM' the keyword parameter will be
# used instead of this parameter.
@@ -62,10 +70,11 @@
end
def verify_parameters
@usage = "#{@parser.keyword} <TARGET NAME> <PACKET NAME> <ENDIANNESS: BIG_ENDIAN/LITTLE_ENDIAN> <DESCRIPTION (Optional)>"
@parser.verify_num_parameters(3, 4, @usage)
+ @parser.verify_parameters_underscores(2) # Packet name is the 2nd parameter
end
def create_command(target_name, commands, warnings)
packet = create_packet(target_name)
PacketParser.finish_create_command(packet, commands, warnings)
@@ -74,21 +83,22 @@
def create_telemetry(target_name, telemetry, latest_data, warnings)
packet = create_packet(target_name)
PacketParser.finish_create_telemetry(packet, telemetry, latest_data, warnings)
end
- #private
+ # private
def create_packet(target_name)
params = @parser.parameters
target_name = params[0].to_s.upcase if target_name == 'SYSTEM'
packet_name = params[1].to_s.upcase
endianness = params[2].to_s.upcase.to_sym
description = params[3].to_s
if endianness != :BIG_ENDIAN and endianness != :LITTLE_ENDIAN
raise @parser.error("Invalid endianness #{params[2]}. Must be BIG_ENDIAN or LITTLE_ENDIAN.", @usage)
end
+
Packet.new(target_name, packet_name, endianness, description)
end
def self.check_for_duplicate(type, list, packet)
msg = nil
@@ -102,10 +112,11 @@
end
def self.finish_create_command(packet, commands, warnings)
warning = PacketParser.check_for_duplicate('Command', commands, packet)
warnings << warning if warning
+ packet.define_reserved_items()
commands[packet.target_name] ||= {}
packet
end
def self.finish_create_telemetry(packet, telemetry, latest_data, warnings)
@@ -117,8 +128,7 @@
telemetry[packet.target_name] = {}
latest_data[packet.target_name] = {}
end
packet
end
-
end
end