28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/wo_oo/electronics/intel_hex_file.rb', line 28
def self.write(path, data, start_address = 0)
next_address = start_address
File.open(path, "w") do |file|
while (line_data = data.slice!(0..15)).size > 0
line_size = line_data.size
file.print ":"
line = WOoo::Util::HexUtil.to_hex8(line_size)
line += WOoo::Util::HexUtil.to_hex16(next_address)
line += "00"
line += WOoo::Util::HexUtil.to_hex8(line_data).join("")
file.print line
file.print WOoo::Util::HexUtil.to_hex8(checksum(line))
file.print "\n"
next_address += line_size
end
file.print ":00000001FF"
end
end
|