Method: OpenC3::TemplateProtocol#post_write_interface

Defined in:
lib/openc3/interfaces/protocols/template_protocol.rb

#post_write_interface(packet, data) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/openc3/interfaces/protocols/template_protocol.rb', line 230

def post_write_interface(packet, data)
  if @response_template && @response_packet
    if @response_timeout
      response_timeout_time = Time.now + @response_timeout
    else
      response_timeout_time = nil
    end

    # Block the write until the response is received
    begin
      @write_block_queue.pop(true)
    rescue
      sleep(@response_polling_period)
      retry if !response_timeout_time
      retry if response_timeout_time and Time.now < response_timeout_time
      handle_error("#{@interface ? @interface.name : ""}: Timeout waiting for response")
    end

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