Skip to content
Snippets Groups Projects
Commit 2a4f9dc5 authored by da1l6's avatar da1l6
Browse files

Support ruby 1.8.x in atmegacard eeprom generator.

parent 7b318ecb
No related branches found
No related tags found
No related merge requests found
......@@ -46,12 +46,20 @@ class IntelHexWriter
end
def hex2bin(hex)
c = hex.length / 2
bin = ('.'.encode('ASCII-8BIT'))*c
(0...c).each{|i|
bin.setbyte(i,hex[i << 1, 2].hex)
}
return bin
c = hex.length / 2
bin = ""
if ("".respond_to?(:encode))
bin = ('.'.encode('ASCII-8BIT'))*c
(0...c).each{|i|
bin.setbyte(i,hex[i << 1, 2].hex)
}
else
bin = '.'*c
(0...c).each{|i|
bin[i] = hex[i << 1, 2].hex
}
end
return bin
end
eeprom_file = ARGV[0]
......@@ -71,4 +79,4 @@ f.write_data(hex2bin(keystring))
f.write_data("\xFF"*KEY_LENGTH)
f.close
puts("OK")
\ No newline at end of file
puts("OK")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment