Method: OpenC3::FileInterface#read_interface

Defined in:
lib/openc3/interfaces/file_interface.rb

#read_interfaceObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/openc3/interfaces/file_interface.rb', line 109

def read_interface
  while true
    if @file
      # Read more data from existing file
      data = @file.read(@file_read_size)
      # Throttle after each read size
      if @throttle and @sleeper.sleep(@throttle)
        return nil, nil
      end
      if data and data.length > 0
        read_interface_base(data, nil)
        return data, nil
      else
        finish_file()
      end
    end

    # Find the next file to read
    @filename = get_next_telemetry_file()
    if @filename
      if File.extname(@filename) == ".gz"
        @file = Zlib::GzipReader.open(@filename)
      else
        @file = File.open(@filename, "rb")
      end
      if @discard_file_header_bytes
        @file.read(@discard_file_header_bytes)
      end
      next
    end

    # Wait for a file to read
    result = @queue.pop
    return nil, nil unless result
  end
end