Method: OpenC3::Protocol#read_data

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

#read_data(data, extra = nil) ⇒ Object

Ensure we have some data in case this is the only protocol



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 56

def read_data(data, extra = nil)
  if data.length <= 0
    if @allow_empty_data.nil?
      if @interface and @interface.read_protocols[-1] == self
        # Last read interface in chain with auto @allow_empty_data
        return :STOP
      end
    elsif !@allow_empty_data
      # Don't @allow_empty_data means STOP
      return :STOP
    end
  end
  return data, extra
end