intel_hex 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/bin/intel_hex_reader +10 -9
- data/lib/intel_hex/file_reader.rb +8 -14
- data/lib/intel_hex/record/data.rb +37 -0
- data/lib/intel_hex/record/ela.rb +25 -0
- data/lib/intel_hex/record/eof.rb +25 -0
- data/lib/intel_hex/record/esa.rb +25 -0
- data/lib/intel_hex/record/sla.rb +25 -0
- data/lib/intel_hex/record/ssa.rb +25 -0
- data/lib/intel_hex/record/value_record_uint16.rb +26 -0
- data/lib/intel_hex/record/value_record_uint32.rb +28 -0
- data/lib/intel_hex/record.rb +103 -135
- data/lib/intel_hex/version.rb +1 -1
- data/lib/intel_hex.rb +3 -3
- metadata +21 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83a3051dc1f9299c66c10ad6923c8289253290f04fd306e424de9d4a07abb3f6
|
4
|
+
data.tar.gz: 271722ed6d1d13d773d37ba0bf13cb1b992a3d61419ac7f39fc5e5b3c779392b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5fb271d154af4ec43772b3c26c4250e3d6066521e58134fffd73dd138bb741d528f98a341fbd8bae1f3803ede52d21c8db86f0f0a8998177f2678fa05afaf8
|
7
|
+
data.tar.gz: 45020b875360c1a2f92955aa835c440d3049a13d2a291a9520681b294c7ffda203628a9b07685009734290bf6264e227c91c2dd7056f3a49ddd377acbeb79af1
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# An Intel hex file parser, for Ruby
|
2
2
|
|
3
|
-
|
3
|
+
[![rspec test status](https://github.com/jeremycole/intel_hex/actions/workflows/rspec.yml/badge.svg)](https://github.com/jeremycole/intel_hex/actions/workflows/rspec.yml)
|
4
|
+
[![rubocop style check status](https://github.com/jeremycole/intel_hex/actions/workflows/rubocop.yml/badge.svg)](https://github.com/jeremycole/intel_hex/actions/workflows/rubocop.yml)
|
4
5
|
|
5
|
-
[
|
6
|
+
See the [Wikipedia page on Intel HEX](https://en.wikipedia.org/wiki/Intel_HEX).
|
data/bin/intel_hex_reader
CHANGED
@@ -1,36 +1,37 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'pp'
|
4
|
+
require "optparse"
|
5
|
+
require "intel_hex"
|
7
6
|
|
8
7
|
@options = {
|
9
8
|
file: nil,
|
10
9
|
}
|
11
10
|
|
12
11
|
OptionParser.new do |opts|
|
13
|
-
opts.on(
|
12
|
+
opts.on("--help", "Print this help.") do
|
14
13
|
puts
|
15
14
|
puts opts
|
16
15
|
puts
|
17
16
|
exit
|
18
17
|
end
|
19
|
-
opts.on(
|
18
|
+
opts.on("-f", "--filename=FILE", "Load the specified file.") do |o|
|
20
19
|
@options[:file] = o
|
21
20
|
end
|
22
21
|
end.parse!
|
23
22
|
|
24
|
-
raise
|
23
|
+
raise "No file specified" unless @options[:file]
|
25
24
|
|
26
25
|
intel_hex_file = IntelHex::FileReader.new(@options[:file])
|
27
26
|
|
28
27
|
intel_hex_file.each_record do |record|
|
29
|
-
puts
|
28
|
+
puts format(
|
29
|
+
"Record type=%-4s offset=%-4d length=%-4d checksum=%-4d %s%s",
|
30
30
|
record.type,
|
31
31
|
record.offset,
|
32
32
|
record.length,
|
33
33
|
record.checksum,
|
34
|
-
record.
|
35
|
-
|
34
|
+
record.value ? "#{record.type}=" : "",
|
35
|
+
record.value_s
|
36
|
+
)
|
36
37
|
end
|
@@ -6,16 +6,12 @@ module IntelHex
|
|
6
6
|
@filename = filename
|
7
7
|
@address_base = 0
|
8
8
|
@address_mask = 0xffff
|
9
|
-
@esa = 0
|
10
|
-
@ssa = 0
|
11
|
-
@ela = 0
|
12
|
-
@sla = 0
|
13
9
|
end
|
14
10
|
|
15
11
|
def each_record
|
16
|
-
return
|
12
|
+
return enum_for(:each_record) unless block_given?
|
17
13
|
|
18
|
-
file = File.open(@filename,
|
14
|
+
file = File.open(@filename, "r")
|
19
15
|
|
20
16
|
begin
|
21
17
|
file.each_line do |line|
|
@@ -29,22 +25,20 @@ module IntelHex
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def each_byte_with_address
|
32
|
-
return
|
28
|
+
return enum_for(:each_byte_with_address) unless block_given?
|
33
29
|
|
34
30
|
each_record do |record|
|
35
31
|
case record.type
|
36
32
|
when :data
|
37
33
|
record.each_byte_with_address do |byte, offset|
|
38
|
-
yield byte, (@address_base + offset) & @address_mask
|
34
|
+
yield byte, (@address_base + (offset & 0xffff)) & @address_mask
|
39
35
|
end
|
40
36
|
when :esa
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@address_mask = 0xfffff # 20 bit address size
|
37
|
+
@address_base = record.value << 4 # bits 4..19 of address
|
38
|
+
@address_mask = 0xfffff # 20 bit address size
|
44
39
|
when :ela
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@address_mask = 0xffffffff # 32 bit address size
|
40
|
+
@address_base = record.value << 16 # bits 16..31 of address
|
41
|
+
@address_mask = 0xffffffff # 32 bit address size
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IntelHex
|
4
|
+
class Record
|
5
|
+
class Data < Record
|
6
|
+
def self.type_id
|
7
|
+
0
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.type_name
|
11
|
+
:data
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.type_data_length
|
15
|
+
(1..255)
|
16
|
+
end
|
17
|
+
|
18
|
+
def value
|
19
|
+
data
|
20
|
+
end
|
21
|
+
|
22
|
+
def value_s
|
23
|
+
data_string = data.map { |b| format("%02x", b) }.join(" ")
|
24
|
+
|
25
|
+
"[#{data_string}]"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.data(data = [])
|
30
|
+
record = Data.new
|
31
|
+
record.data = data
|
32
|
+
record
|
33
|
+
end
|
34
|
+
|
35
|
+
register_type(Data)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "intel_hex/record/value_record_uint16"
|
4
|
+
|
5
|
+
module IntelHex
|
6
|
+
class Record
|
7
|
+
class Ela < ValueRecordUint16
|
8
|
+
def self.type_id
|
9
|
+
4
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.type_name
|
13
|
+
:ela
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.ela(value = nil)
|
18
|
+
record = Ela.new
|
19
|
+
record.value = value if value
|
20
|
+
record
|
21
|
+
end
|
22
|
+
|
23
|
+
register_type(Ela)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IntelHex
|
4
|
+
class Record
|
5
|
+
class Eof < Record
|
6
|
+
def self.type_id
|
7
|
+
1
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.type_name
|
11
|
+
:eof
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.type_data_length
|
15
|
+
0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.eof
|
20
|
+
Eof.new
|
21
|
+
end
|
22
|
+
|
23
|
+
register_type(Eof)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "intel_hex/record/value_record_uint16"
|
4
|
+
|
5
|
+
module IntelHex
|
6
|
+
class Record
|
7
|
+
class Esa < ValueRecordUint16
|
8
|
+
def self.type_id
|
9
|
+
2
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.type_name
|
13
|
+
:esa
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.esa(value = nil)
|
18
|
+
record = Esa.new
|
19
|
+
record.value = value if value
|
20
|
+
record
|
21
|
+
end
|
22
|
+
|
23
|
+
register_type(Esa)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "intel_hex/record/value_record_uint32"
|
4
|
+
|
5
|
+
module IntelHex
|
6
|
+
class Record
|
7
|
+
class Sla < ValueRecordUint32
|
8
|
+
def self.type_id
|
9
|
+
5
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.type_name
|
13
|
+
:sla
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.sla(value = nil)
|
18
|
+
record = Sla.new
|
19
|
+
record.value = value if value
|
20
|
+
record
|
21
|
+
end
|
22
|
+
|
23
|
+
register_type(Sla)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "intel_hex/record/value_record_uint32"
|
4
|
+
|
5
|
+
module IntelHex
|
6
|
+
class Record
|
7
|
+
class Ssa < ValueRecordUint32
|
8
|
+
def self.type_id
|
9
|
+
3
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.type_name
|
13
|
+
:ssa
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.ssa(value = nil)
|
18
|
+
record = Ssa.new
|
19
|
+
record.value = value if value
|
20
|
+
record
|
21
|
+
end
|
22
|
+
|
23
|
+
register_type(Ssa)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IntelHex
|
4
|
+
class Record
|
5
|
+
class ValueRecordUint16 < Record
|
6
|
+
def self.type_data_length
|
7
|
+
2
|
8
|
+
end
|
9
|
+
|
10
|
+
# Retrieve the 16-bit unsigned integer value from the record.
|
11
|
+
def value
|
12
|
+
(data[0] << 8) | data[1]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Store a 32-bit unsigned integer value in the record.
|
16
|
+
def value=(value)
|
17
|
+
data[0..1] = [
|
18
|
+
(value & 0xff00) >> 8,
|
19
|
+
value & 0x00ff,
|
20
|
+
]
|
21
|
+
@length = data.size
|
22
|
+
@checksum = recalculate_checksum
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IntelHex
|
4
|
+
class Record
|
5
|
+
class ValueRecordUint32 < Record
|
6
|
+
def self.type_data_length
|
7
|
+
4
|
8
|
+
end
|
9
|
+
|
10
|
+
# Retrieve the 32-bit unsigned integer value from the record.
|
11
|
+
def value
|
12
|
+
(data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Store a 32-bit unsigned integer value in the record.
|
16
|
+
def value=(value)
|
17
|
+
data[0..3] = [
|
18
|
+
(value & 0xff000000) >> 24,
|
19
|
+
(value & 0x00ff0000) >> 16,
|
20
|
+
(value & 0x0000ff00) >> 8,
|
21
|
+
value & 0x000000ff,
|
22
|
+
]
|
23
|
+
@length = data.size
|
24
|
+
@checksum = recalculate_checksum
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/intel_hex/record.rb
CHANGED
@@ -4,90 +4,74 @@ module IntelHex
|
|
4
4
|
class MisformattedFileError < RuntimeError; end
|
5
5
|
|
6
6
|
class ValidationError < StandardError; end
|
7
|
+
|
7
8
|
class InvalidTypeError < ValidationError; end
|
9
|
+
|
8
10
|
class InvalidLengthError < ValidationError; end
|
11
|
+
|
9
12
|
class InvalidOffsetError < ValidationError; end
|
13
|
+
|
10
14
|
class InvalidDataError < ValidationError; end
|
15
|
+
|
11
16
|
class InvalidChecksumError < ValidationError; end
|
12
17
|
|
13
18
|
class Record
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
ssa
|
19
|
-
ela
|
20
|
-
sla
|
21
|
-
].freeze
|
19
|
+
class << self
|
20
|
+
def register_type(type)
|
21
|
+
@type_by_id ||= {}
|
22
|
+
@type_by_name ||= {}
|
22
23
|
|
23
|
-
|
24
|
+
raise "Type name #{type.type_name} is not a symbol" unless type.type_name.is_a?(Symbol)
|
25
|
+
raise "Type name #{type.type_name} redefined" if @type_by_name.include?(type.type_name)
|
26
|
+
raise "Type id #{type.type_id} redefined" if @type_by_id.include?(type.type_id)
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
eof: 0,
|
28
|
-
esa: 2,
|
29
|
-
ssa: 4,
|
30
|
-
ela: 2,
|
31
|
-
sla: 4,
|
32
|
-
}.freeze
|
28
|
+
@type_by_id[type.type_id] = @type_by_name[type.type_name] = type
|
29
|
+
end
|
33
30
|
|
34
|
-
|
35
|
-
raise MisformattedFileError, 'Expected \':\' at start of line' unless line[0] == ':'
|
36
|
-
raise MisformattedFileError, 'Line length incorrect' unless line.size >= (1 + 2 + 4 + 2)
|
31
|
+
attr_reader :type_by_id, :type_by_name
|
37
32
|
|
38
|
-
|
39
|
-
|
33
|
+
def type_id
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
checksum = line[data_end..(data_end + 2)].to_i(16)
|
37
|
+
def type_name
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
45
40
|
|
46
|
-
|
47
|
-
|
41
|
+
def type_data_length
|
42
|
+
raise NotImplementedError
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
record
|
53
|
-
end
|
45
|
+
def parse(line)
|
46
|
+
raise MisformattedFileError, "Expected ':' at start of line" unless line[0] == ":"
|
47
|
+
raise MisformattedFileError, "Line length incorrect" unless line.size >= (1 + 2 + 4 + 2)
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
49
|
+
length = line[1..2].to_i(16)
|
50
|
+
data_end = (9 + (length * 2))
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
52
|
+
offset = line[3..6].to_i(16)
|
53
|
+
type_id = line[7..8].to_i(16)
|
54
|
+
data = line[9...data_end].chars.each_slice(2).map { |a| a.join.to_i(16) }
|
55
|
+
checksum = line[data_end..(data_end + 2)].to_i(16)
|
64
56
|
|
65
|
-
|
66
|
-
type_with_value(:esa, value)
|
67
|
-
end
|
57
|
+
raise InvalidTypeError, "Unknown type #{type_id}" unless type_by_id.include?(type_id)
|
68
58
|
|
69
|
-
|
70
|
-
|
71
|
-
|
59
|
+
type = type_by_id[type_id]
|
60
|
+
type.new(length, offset, data, checksum, line: line, validate: true)
|
61
|
+
end
|
72
62
|
|
73
|
-
|
74
|
-
|
75
|
-
end
|
63
|
+
def inherited(subclass)
|
64
|
+
super
|
76
65
|
|
77
|
-
|
78
|
-
|
66
|
+
subclass.instance_eval { public_class_method :new }
|
67
|
+
end
|
79
68
|
end
|
80
69
|
|
81
|
-
|
82
|
-
|
83
|
-
attr_reader :
|
84
|
-
attr_reader :data
|
85
|
-
attr_reader :checksum
|
86
|
-
attr_reader :line
|
70
|
+
private_class_method :new
|
71
|
+
|
72
|
+
attr_reader :length, :offset, :data, :checksum, :line
|
87
73
|
|
88
|
-
|
89
|
-
def initialize(type, length = 0, offset = 0, data = [], checksum = nil, line: nil, validate: false)
|
90
|
-
@type = type
|
74
|
+
def initialize(length = 0, offset = 0, data = [], checksum = nil, line: nil, validate: false)
|
91
75
|
@length = length
|
92
76
|
@offset = offset
|
93
77
|
@data = data
|
@@ -97,36 +81,67 @@ module IntelHex
|
|
97
81
|
|
98
82
|
self.validate if validate
|
99
83
|
end
|
100
|
-
# rubocop:enable Metrics/ParameterLists
|
101
84
|
|
102
|
-
def
|
103
|
-
|
85
|
+
def type_id
|
86
|
+
self.class.type_id
|
104
87
|
end
|
105
88
|
|
106
|
-
def
|
107
|
-
|
89
|
+
def type_name
|
90
|
+
self.class.type_name
|
91
|
+
end
|
92
|
+
|
93
|
+
alias type type_name
|
94
|
+
|
95
|
+
def type_data_length
|
96
|
+
self.class.type_data_length
|
97
|
+
end
|
98
|
+
|
99
|
+
def data=(value)
|
100
|
+
raise InvalidDataError, "Incorrect data type" unless value.is_a?(Array)
|
101
|
+
raise InvalidLengthError, "Data length #{value.size} too large" unless value.size <= 255
|
102
|
+
|
103
|
+
@data = value
|
104
|
+
@length = data.size
|
105
|
+
@checksum = recalculate_checksum
|
106
|
+
end
|
108
107
|
|
109
|
-
|
108
|
+
def value
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
112
|
+
def value_s
|
113
|
+
value.to_s
|
110
114
|
end
|
111
115
|
|
112
116
|
def to_s
|
113
|
-
"
|
117
|
+
type_value = value ? "#{type}=#{value_s}" : ""
|
118
|
+
"#<#{self.class.name} type=#{type_name} offset=#{offset} length=#{length} #{type_value}>"
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_h
|
122
|
+
{
|
123
|
+
type: type,
|
124
|
+
offset: offset,
|
125
|
+
length: length,
|
126
|
+
checksum: checksum,
|
127
|
+
}.merge({ type => value })
|
114
128
|
end
|
115
129
|
|
116
130
|
def to_ascii
|
117
|
-
|
131
|
+
format(
|
132
|
+
":%02X%04X%02X%s%02X",
|
118
133
|
length,
|
119
134
|
offset,
|
120
|
-
|
121
|
-
data.map { |b|
|
122
|
-
checksum
|
123
|
-
|
135
|
+
type_id,
|
136
|
+
data.map { |b| format("%02X", b) }.join,
|
137
|
+
checksum
|
138
|
+
)
|
124
139
|
end
|
125
140
|
|
126
141
|
def calculate_checksum
|
127
142
|
return @calculated_checksum if @calculated_checksum
|
128
143
|
|
129
|
-
sum = length + ((offset & 0xff00) >> 8) + (offset & 0x00ff) +
|
144
|
+
sum = length + ((offset & 0xff00) >> 8) + (offset & 0x00ff) + type_id
|
130
145
|
sum += data.sum
|
131
146
|
|
132
147
|
@calculated_checksum = (((sum & 0xff) ^ 0xff) + 1) & 0xff
|
@@ -145,35 +160,28 @@ module IntelHex
|
|
145
160
|
end
|
146
161
|
|
147
162
|
def validate
|
148
|
-
validate_type
|
149
163
|
validate_length
|
150
164
|
validate_offset
|
151
165
|
validate_data
|
152
166
|
validate_checksum
|
153
167
|
end
|
154
168
|
|
155
|
-
def validate_type
|
156
|
-
return if TYPE_MAP.include?(type)
|
157
|
-
|
158
|
-
raise InvalidTypeError, "Type #{type} is invalid"
|
159
|
-
end
|
160
|
-
|
161
169
|
def validate_offset
|
162
170
|
raise InvalidOffsetError, "Offset #{offset} is negative" unless offset >= 0
|
163
171
|
raise InvalidOffsetError, "Offset #{offset} is too large" unless offset < 2**16
|
164
172
|
end
|
165
173
|
|
166
174
|
def validate_length
|
167
|
-
|
168
|
-
|
169
|
-
case valid_length
|
175
|
+
case type_data_length
|
170
176
|
when Integer
|
171
|
-
return if length ==
|
177
|
+
return if length == type_data_length
|
172
178
|
when Range
|
173
|
-
return if
|
179
|
+
return if type_data_length.include?(length)
|
180
|
+
else
|
181
|
+
raise InvalidTypeError, "Length for type #{type} is unhandled by validation"
|
174
182
|
end
|
175
183
|
|
176
|
-
raise InvalidLengthError, "Length for type #{type} must be #{
|
184
|
+
raise InvalidLengthError, "Length for type #{type} must be #{type_data_length}; #{length} given"
|
177
185
|
end
|
178
186
|
|
179
187
|
def validate_data
|
@@ -189,7 +197,7 @@ module IntelHex
|
|
189
197
|
end
|
190
198
|
|
191
199
|
def each_byte_with_address
|
192
|
-
return
|
200
|
+
return enum_for(:each_byte_with_address) unless block_given?
|
193
201
|
|
194
202
|
data.each_with_index do |byte, i|
|
195
203
|
yield byte, offset + i
|
@@ -197,52 +205,12 @@ module IntelHex
|
|
197
205
|
|
198
206
|
nil
|
199
207
|
end
|
200
|
-
|
201
|
-
def data=(value)
|
202
|
-
raise 'Incorrect data type' unless value.is_a?(Array)
|
203
|
-
raise InvalidLengthError, "Data length #{value.size} too large" unless value.size <= 255
|
204
|
-
|
205
|
-
@data = value
|
206
|
-
@length = data.size
|
207
|
-
@checksum = recalculate_checksum
|
208
|
-
end
|
209
|
-
|
210
|
-
def data_to_uint16(offset = 0)
|
211
|
-
(data[offset + 0] << 8) | data[offset + 1]
|
212
|
-
end
|
213
|
-
|
214
|
-
def uint16_to_data(value, offset = 0)
|
215
|
-
data[(offset...(offset + 2))] = [
|
216
|
-
(value & 0xff00) >> 8,
|
217
|
-
value & 0x00ff,
|
218
|
-
]
|
219
|
-
@length = data.size
|
220
|
-
@checksum = recalculate_checksum
|
221
|
-
end
|
222
|
-
|
223
|
-
def data_to_uint32(offset = 0)
|
224
|
-
(data[offset + 0] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3]
|
225
|
-
end
|
226
|
-
|
227
|
-
def uint32_to_data(value, offset = 0)
|
228
|
-
data[(offset...(offset + 4))] = [
|
229
|
-
(value & 0xff000000) >> 24,
|
230
|
-
(value & 0x00ff0000) >> 16,
|
231
|
-
(value & 0x0000ff00) >> 8,
|
232
|
-
value & 0x000000ff,
|
233
|
-
]
|
234
|
-
@length = data.size
|
235
|
-
@checksum = recalculate_checksum
|
236
|
-
end
|
237
|
-
|
238
|
-
alias esa data_to_uint16
|
239
|
-
alias ssa data_to_uint32
|
240
|
-
alias ela data_to_uint16
|
241
|
-
alias sla data_to_uint32
|
242
|
-
|
243
|
-
alias esa= uint16_to_data
|
244
|
-
alias ssa= uint32_to_data
|
245
|
-
alias ela= uint16_to_data
|
246
|
-
alias sla= uint32_to_data
|
247
208
|
end
|
248
209
|
end
|
210
|
+
|
211
|
+
require "intel_hex/record/data"
|
212
|
+
require "intel_hex/record/eof"
|
213
|
+
require "intel_hex/record/esa"
|
214
|
+
require "intel_hex/record/ssa"
|
215
|
+
require "intel_hex/record/ela"
|
216
|
+
require "intel_hex/record/sla"
|
data/lib/intel_hex/version.rb
CHANGED
data/lib/intel_hex.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intel_hex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Cole
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: An Intel hex file parser for (e.g. AVR) working with firmware files
|
28
14
|
email: jeremy@jcole.us
|
29
15
|
executables:
|
@@ -37,12 +23,21 @@ files:
|
|
37
23
|
- lib/intel_hex.rb
|
38
24
|
- lib/intel_hex/file_reader.rb
|
39
25
|
- lib/intel_hex/record.rb
|
26
|
+
- lib/intel_hex/record/data.rb
|
27
|
+
- lib/intel_hex/record/ela.rb
|
28
|
+
- lib/intel_hex/record/eof.rb
|
29
|
+
- lib/intel_hex/record/esa.rb
|
30
|
+
- lib/intel_hex/record/sla.rb
|
31
|
+
- lib/intel_hex/record/ssa.rb
|
32
|
+
- lib/intel_hex/record/value_record_uint16.rb
|
33
|
+
- lib/intel_hex/record/value_record_uint32.rb
|
40
34
|
- lib/intel_hex/version.rb
|
41
35
|
homepage: https://github.com/jeremycole/intel_hex
|
42
36
|
licenses:
|
43
37
|
- BSD-3-Clause
|
44
|
-
metadata:
|
45
|
-
|
38
|
+
metadata:
|
39
|
+
rubygems_mfa_required: 'true'
|
40
|
+
post_install_message:
|
46
41
|
rdoc_options: []
|
47
42
|
require_paths:
|
48
43
|
- lib
|
@@ -50,15 +45,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
45
|
requirements:
|
51
46
|
- - ">="
|
52
47
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
48
|
+
version: '3.0'
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '4'
|
54
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
53
|
requirements:
|
56
54
|
- - ">="
|
57
55
|
- !ruby/object:Gem::Version
|
58
56
|
version: '0'
|
59
57
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
61
|
-
signing_key:
|
58
|
+
rubygems_version: 3.5.16
|
59
|
+
signing_key:
|
62
60
|
specification_version: 4
|
63
61
|
summary: Parser for Intel hex files
|
64
62
|
test_files: []
|