sappho-heatmiser-proxy 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,8 @@ module Sappho
25
25
  end
26
26
 
27
27
  def communicate
28
- loop do
28
+ active = true
29
+ while active do
29
30
  begin
30
31
  timeout 20 do
31
32
  command = read 5
@@ -35,12 +36,14 @@ module Sappho
35
36
  'error: no response from heatmiser unit in last minute' :
36
37
  @status.valid ? 'ok' : 'error: last response from heatmiser unit was invalid'
37
38
  }
38
- @log.info "client requested status - reply: #{reply}"
39
- @client.writeline reply
39
+ @log.info "client check - reply: #{reply}"
40
+ @client.write "#{reply}\r\n"
41
+ active = false
40
42
  else
43
+ command = command.unpack('c*')
41
44
  @log.debug "header: #{TraceLog.hex command}" if @log.debug?
42
45
  packetSize = (command[1] & 0xFF) | ((command[2] << 8) & 0x0F00)
43
- command += read(packetSize - 5)
46
+ command += read(packetSize - 5).unpack('c*')
44
47
  CommandQueue.instance.push @ip, command unless (command[0] & 0xFF) == 0x93
45
48
  @status.get { @client.write @status.raw.pack('c*') if @status.valid }
46
49
  @log.info "command received from client #{@ip} so it is alive"
@@ -48,13 +51,13 @@ module Sappho
48
51
  end
49
52
  rescue Timeout::Error
50
53
  @log.info "no command received from client #{@ip} so presuming it dormant"
51
- break
54
+ active = false
52
55
  rescue HeatmiserClient::ReadError
53
56
  @log.info "unable to receive data from client #{@ip} so presuming it has disconnected"
54
- break
57
+ active = false
55
58
  rescue => error
56
59
  @log.error error
57
- break
60
+ active = false
58
61
  end
59
62
  end
60
63
  begin
@@ -67,7 +70,7 @@ module Sappho
67
70
  def read size
68
71
  data = @client.read size
69
72
  raise HeatmiserClient::ReadError unless data and data.size == size
70
- data.unpack('c*')
73
+ data
71
74
  end
72
75
 
73
76
  class ReadError < Interrupt
@@ -7,7 +7,7 @@ module Sappho
7
7
  module Heatmiser
8
8
  module Proxy
9
9
  NAME = "sappho-heatmiser-proxy"
10
- VERSION = "0.0.6"
10
+ VERSION = "0.0.7"
11
11
  AUTHORS = ["Andrew Heald"]
12
12
  EMAILS = ["andrew@heald.co.uk"]
13
13
  HOMEPAGE = "https://github.com/sappho/sappho-heatmiser-proxy/wiki"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sappho-heatmiser-proxy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Heald