Class: IntelHex::Record::ValueRecordUint32

Inherits:
IntelHex::Record show all
Defined in:
lib/intel_hex/record/value_record_uint32.rb

Direct Known Subclasses

Sla, Ssa

Instance Attribute Summary

Attributes inherited from IntelHex::Record

#checksum, #data, #length, #line, #offset

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IntelHex::Record

#calculate_checksum, data, #each_byte_with_address, ela, eof, esa, inherited, #initialize, parse, #recalculate_checksum, register_type, sla, ssa, #to_ascii, #to_h, #to_s, #type_data_length, #type_id, type_id, #type_name, type_name, #valid?, #validate, #validate_checksum, #validate_data, #validate_length, #validate_offset, #value_s

Constructor Details

This class inherits a constructor from IntelHex::Record

Class Method Details

.type_data_lengthObject



6
7
8
# File 'lib/intel_hex/record/value_record_uint32.rb', line 6

def self.type_data_length
  4
end

Instance Method Details

#valueObject

Retrieve the 32-bit unsigned integer value from the record.



11
12
13
# File 'lib/intel_hex/record/value_record_uint32.rb', line 11

def value
  (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]
end

#value=(value) ⇒ Object

Store a 32-bit unsigned integer value in the record.



16
17
18
19
20
21
22
23
24
25
# File 'lib/intel_hex/record/value_record_uint32.rb', line 16

def value=(value)
  data[0..3] = [
    (value & 0xff000000) >> 24,
    (value & 0x00ff0000) >> 16,
    (value & 0x0000ff00) >> 8,
    value & 0x000000ff,
  ]
  @length = data.size
  @checksum = recalculate_checksum
end