Skip to content

Commit

Permalink
closes #956, use target name from command for response
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmelt committed Apr 2, 2019
1 parent 285a1f0 commit dc70b3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/cosmos/interfaces/protocols/template_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def initialize(
allow_empty_data)
@response_template = nil
@response_packet = nil
@response_target_name = nil
@response_packets = []
@write_block_queue = Queue.new
@ignore_lines = ignore_lines.to_i
Expand Down Expand Up @@ -124,7 +125,7 @@ def read_packet(packet)
end

# Grab the response packet specified in the command
result_packet = System.telemetry.packet(@interface.target_names[0], @response_packet).clone
result_packet = System.telemetry.packet(@response_target_name, @response_packet).clone
result_packet.received_time = nil
result_packet.id_items.each do |item|
result_packet.write_item(item, item.id_value, :RAW)
Expand Down Expand Up @@ -181,17 +182,20 @@ def write_packet(packet)
begin
@response_template = packet.read("RSP_TEMPLATE").strip
@response_packet = packet.read("RSP_PACKET").strip
@response_target_name = packet.target_name
# If the template or packet are empty set them to nil. This allows for
# the user to remove the RSP_TEMPLATE and RSP_PACKET values and avoid
# any response timeouts
if @response_template.empty? || @response_packet.empty?
@response_template = nil
@response_packet = nil
@response_target_name = nil
end
rescue
# If there is no response template we set to nil
@response_template = nil
@response_packet = nil
@response_target_name = nil
end

# Grab the command template because that is all we eventually send
Expand Down Expand Up @@ -235,6 +239,7 @@ def post_write_interface(packet, data)

@response_template = nil
@response_packet = nil
@response_target_name = nil
@response_packets.clear
end
return super(packet, data)
Expand Down

0 comments on commit dc70b3e

Please sign in to comment.