Class: Sappho::Heatmiser::Proxy::HeatmiserCRC

Inherits:
Object
  • Object
show all
Defined in:
lib/sappho-heatmiser-proxy/heatmiser_crc.rb

Constant Summary collapse

LookupHi =
[
    0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
    0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1
]
LookupLo =
[
    0x00, 0x21, 0x42, 0x63, 0x84, 0xA5, 0xC6, 0xE7,
    0x08, 0x29, 0x4A, 0x6B, 0x8C, 0xAD, 0xCE, 0xEF
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ HeatmiserCRC

Returns a new instance of HeatmiserCRC.



22
23
24
25
26
27
28
29
30
# File 'lib/sappho-heatmiser-proxy/heatmiser_crc.rb', line 22

def initialize bytes
  @bytes = bytes
  @crcHi = 0xFF
  @crcLo = 0xFF
  bytes.each do |byte|
    addNibble byte >> 4
    addNibble byte & 0x0F
  end
end

Instance Attribute Details

#crcHiObject (readonly)

Returns the value of attribute crcHi.



20
21
22
# File 'lib/sappho-heatmiser-proxy/heatmiser_crc.rb', line 20

def crcHi
  @crcHi
end

#crcLoObject (readonly)

Returns the value of attribute crcLo.



20
21
22
# File 'lib/sappho-heatmiser-proxy/heatmiser_crc.rb', line 20

def crcLo
  @crcLo
end

Instance Method Details

#appendCRCObject



32
33
34
# File 'lib/sappho-heatmiser-proxy/heatmiser_crc.rb', line 32

def appendCRC
  @bytes << @crcLo << @crcHi
end