193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/openc3/tools/table_manager/table_manager_core.rb', line 193
def self.load_binary(config, data)
binary_data_index = 0
total_table_length = 0
config.tables.each do |table_name, table|
total_table_length += table.length
end
config.tables.each do |table_name, table|
if binary_data_index + table.length > data.length
table.buffer = data[binary_data_index..-1]
raise MismatchError,
"Binary size of #{data.length} not large enough to fully represent table definition of length #{total_table_length}. "+
"The remaining table definition (starting with byte #{data.length - binary_data_index} in #{table.table_name}) will be filled with 0."
end
table.buffer = data[binary_data_index...binary_data_index + table.length]
binary_data_index += table.length
end
if binary_data_index < data.length
raise MismatchError,
"Binary size of #{data.length} larger than table definition of length #{total_table_length}. "+
"Discarding the remaing #{data.length - binary_data_index} bytes."
end
end
|