Created
June 6, 2010 19:37
-
-
Save LTe/427823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plik = File.open("intel.hex", "r") | |
hex = plik.readlines | |
binfile = [] | |
hex.each do |line| | |
adress = line[3..6] | |
type = line[7..8] | |
data = line[9..40] | |
checksum = line[41..42] | |
puts "Ad: #{adress}, type: #{type}, data: #{data}, checksum: #{checksum} | #{adress.to_i(16) / 16} |" | |
binfile[adress.to_i(16) / 32] = data.unpack("H32") | |
end | |
binfile.inspect | |
binfile.collect! {|x| | |
if(x == nil) | |
x = ("0"*16) | |
else | |
x = x | |
end | |
} | |
puts binfile.join.inspect | |
result = binfile.join | |
result = result.split(//) | |
result.each_index { |x| | |
if(x % 32 == 0) | |
puts ":count||adress||#{result[x..x+32]}" | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment