seriamp 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d3d9290f5631bdd707dd435ef0f0e7abe7da345017bc92764cacb78f6e485e
4
- data.tar.gz: 629ef868b42d3e0d50bf27fbc6a15fbfe036fdee9a4028aa03aae671a7c5e737
3
+ metadata.gz: 4e48ad0a8b0c004f0e7a931eed8b923bb06329af40db33c7d89b51831591531a
4
+ data.tar.gz: 292b04a8dca57285dbfea326a38b86bc6fb8e67e1ebb60215b49bdb236eecc94
5
5
  SHA512:
6
- metadata.gz: 0f799dc584037d91ed46ab8abffa4c0ab2dfd9d8db131d2195b5fbd9b2222702e54002f5eb3a97c40fcb1dbe3902639f0cda195a6407d6a6a04db9e3542a2f49
7
- data.tar.gz: a65df97c56a0d665f1636dafdbf323a75a4624d5669662cd5ad60b0d20780c5f30aa3bb7a261892db228c33da0f19c094d9c70727191f0a24c4e8e46b022675e
6
+ metadata.gz: bb8b19b6288bfe4b248aaaa1dffe26f801b64729af28923a8501222e05c8978747337c9d61b22d2794c2d6f33ebc16e831272569add01420c24ac9786674c5cd
7
+ data.tar.gz: f1fe372b20b6bd95f33637c3157d6cc210d03c3cd7e6047061657095ef07abc891c6a38b85c9788d0329898ff7e4506687cc9661ca411de0582c0367a9c5f6df
data/README.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Yamaha Receiver Serial Control Ruby Library
2
2
 
3
+ ## Hardware Requirements
4
+
5
+ I used USB to serial adapters with both Prolific PL2303 and FTDI chips.
6
+ Both chipsets work under Linux. The FTDI chipset appears to buffer the
7
+ incoming data - when reading from the device, it returns more than one
8
+ character at a time, whereas with the Prolific chipset only one character at
9
+ a time is returned. This means the FTDI chip can possibly offer faster
10
+ communication. Adapters based on the FTDI chip are also more expensive.
11
+
12
+ On Windows, FTDI provides drivers for at least Windows 7, however they
13
+ are not signed. Windows can be booted with the option to skip driver
14
+ signing enforcement, which makes the adapter work. I couldn't locate a
15
+ working Prolific driver for Windows 7.
16
+
17
+ These USB to serial adapters all have male connection on the RS232 end.
18
+ As such, no additional cable is needed if communicating with a receiver
19
+ that requires a straight cable and has a female terminal (such as the
20
+ Denon AVR-2308CI). For other receivers a gender changer or a cable is
21
+ necessary.
22
+
23
+ ### Sonance Sonamp 875D / 875D MK II
24
+
25
+ - 3-pin cable should be sufficient according to manual
26
+ - Null-modem cable required
27
+ - Receiver socket is female
28
+
29
+ ### Yamaha RX-V**00
30
+
31
+ - 5-pin cable required (with RTS pin connected)
32
+ - Null-modem cable required
33
+ - Receiver socket is male
34
+
35
+ ### Denon AVR-2308CI
36
+
37
+ - Straight cable required
38
+ - Receiver socket is female
39
+
40
+ ### Integra DTR
41
+
42
+ - Straight cable required
43
+
3
44
  ## Protocol Notes
4
45
 
5
46
  ### RX-V1500 Power Values
@@ -3,6 +3,7 @@
3
3
  require 'sinatra/base'
4
4
  require 'seriamp/utils'
5
5
  require 'seriamp/sonamp/client'
6
+ require 'seriamp/detect'
6
7
 
7
8
  module Seriamp
8
9
  module Sonamp
@@ -12,6 +13,10 @@ module Seriamp
12
13
  set :logger, nil
13
14
  set :client, nil
14
15
 
16
+ get '/' do
17
+ render_json(client.status)
18
+ end
19
+
15
20
  get '/power' do
16
21
  render_json(client.get_zone_power)
17
22
  end
@@ -55,6 +60,7 @@ module Seriamp
55
60
  end
56
61
 
57
62
  def render_json(data)
63
+ headers['content-type'] = 'application/json'
58
64
  data.to_json
59
65
  end
60
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Seriamp
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.5'
5
5
  end
@@ -42,6 +42,34 @@ module Seriamp
42
42
  empty_response
43
43
  end
44
44
 
45
+ post "/#{zone}/volume/up" do
46
+ client.public_send("#{zone}_volume_up")
47
+ client.public_send("#{zone}_volume_up")
48
+ plain_response client.main_volume_db
49
+ end
50
+
51
+ post "/#{zone}/volume/up/:step" do |step|
52
+ client.public_send("#{zone}_volume_up")
53
+ step.to_i.times do
54
+ client.public_send("#{zone}_volume_up")
55
+ end
56
+ plain_response client.main_volume_db
57
+ end
58
+
59
+ post "/#{zone}/volume/down" do
60
+ client.public_send("#{zone}_volume_down")
61
+ client.public_send("#{zone}_volume_down")
62
+ plain_response client.main_volume_db
63
+ end
64
+
65
+ post "/#{zone}/volume/down/:step" do |step|
66
+ client.public_send("#{zone}_volume_down")
67
+ step.to_i.times do
68
+ client.public_send("#{zone}_volume_down")
69
+ end
70
+ plain_response client.main_volume_db
71
+ end
72
+
45
73
  put "/#{zone}/input" do
46
74
  value = request.body.read
47
75
  client.public_send("set_#{zone}_input", value)
@@ -71,6 +99,11 @@ module Seriamp
71
99
  def empty_response
72
100
  render_json({})
73
101
  end
102
+
103
+ def plain_response(data)
104
+ headers['content-type'] = 'text/plain'
105
+ data.to_s
106
+ end
74
107
  end
75
108
  end
76
109
  end
@@ -7,7 +7,8 @@ require 'seriamp/yamaha/protocol/methods'
7
7
  module Seriamp
8
8
  module Yamaha
9
9
 
10
- RS232_TIMEOUT = 3
10
+ # The manual says response should be received in 500 ms.
11
+ RS232_TIMEOUT = 0.75
11
12
 
12
13
  class Client
13
14
  include Protocol::Methods
@@ -174,6 +175,29 @@ module Seriamp
174
175
  'R0178' => 'RX-V2500',
175
176
  }.freeze
176
177
 
178
+ PURE_DIRECT_FIELD = {
179
+ 'R0177' => 28,
180
+ 'R0178' => 126,
181
+ }.freeze
182
+
183
+ INPUT_MODE_R0178 = {
184
+ '0' => 'Auto',
185
+ '2' => 'DTS',
186
+ '4' => 'Analog',
187
+ '5' => 'Analog Only',
188
+ }.freeze
189
+
190
+ SAMPLE_RATE_R0178 = {
191
+ '0' => 'Analog',
192
+ '1' => 32000,
193
+ '2' => 44100,
194
+ '3' => 48000,
195
+ '4' => 64000,
196
+ '5' => 88200,
197
+ '6' => 96000,
198
+ '7' => 'Unknown',
199
+ }.freeze
200
+
177
201
  def do_status
178
202
  resp = nil
179
203
  loop do
@@ -240,12 +264,20 @@ module Seriamp
240
264
  sleep: SLEEP_GET.fetch(data[24]),
241
265
  night: night = data[27],
242
266
  night_name: NIGHT_GET.fetch(night),
243
- pure_direct: data[28] == '1',
267
+ pure_direct: data[PURE_DIRECT_FIELD.fetch(@model_code)] == '1',
244
268
  speaker_a: data[29] == '1',
245
269
  speaker_b: data[30] == '1',
246
- format: data[31..32],
247
- sample_rate: data[33..34],
270
+ # 2 positions on RX-Vx700
271
+ #format: data[31..32],
272
+ #sampling: data[33..34],
248
273
  )
274
+ if @model_code == 'R0178'
275
+ @status.update(
276
+ input_mode: INPUT_MODE_R0178.fetch(data[11]),
277
+ sampling: data[32],
278
+ sample_rate: SAMPLE_RATE_R0178.fetch(data[32]),
279
+ )
280
+ end
249
281
  end
250
282
  @status
251
283
  end
@@ -74,26 +74,34 @@ module Seriamp
74
74
  when 'volume'
75
75
  which = args.shift
76
76
  if %w(main zone2 zone3).include?(which)
77
- prefix = "set_#{which}"
78
77
  value = args.shift
79
78
  else
80
- prefix = 'set_main'
81
79
  value = which
80
+ which = 'main'
82
81
  end
83
- if %w(. -).include?(value)
84
- method = "#{prefix}_mute"
85
- value = true
82
+ prefix = "set_#{which}"
83
+ value = value.downcase
84
+ if value == 'up'
85
+ # Just like with remote, the first volume up or down command
86
+ # doesn't do anything.
87
+ client.public_send("#{which}_volume_up")
88
+ client.public_send("#{which}_volume_up")
89
+ elsif value == 'down'
90
+ client.public_send("#{which}_volume_down")
91
+ client.public_send("#{which}_volume_down")
86
92
  else
87
- method = "#{prefix}_volume_db"
88
- if value[0] == ','
89
- value = value[1..]
93
+ if %w(. -).include?(value)
94
+ method = "#{prefix}_mute"
95
+ value = true
96
+ else
97
+ method = "#{prefix}_volume_db"
98
+ if value[0] == ','
99
+ value = value[1..]
100
+ end
101
+ value = Float(value)
90
102
  end
91
- value = Float(value)
103
+ client.public_send(method, value)
92
104
  end
93
- client.public_send(method, value)
94
- p client.get_main_volume_text
95
- p client.get_zone2_volume_text
96
- p client.get_zone3_volume_text
97
105
  when 'input'
98
106
  which = args.shift&.downcase
99
107
  if %w(main zone2 zone3).include?(which)
@@ -112,8 +120,11 @@ module Seriamp
112
120
  client.set_pure_direct(state)
113
121
  when 'status'
114
122
  pp client.last_status
115
- when 'status_string'
116
- puts client.last_status_string
123
+ when 'dev-status'
124
+ status = client.last_status_string
125
+ 0.upto(status.length-1).each do |i|
126
+ puts "%3d %s" % [i, status[i]]
127
+ end
117
128
  when 'test'
118
129
  client.set_power(false)
119
130
  [true, false].each do |main_state|
@@ -66,6 +66,14 @@ module Seriamp
66
66
  set_zone2_volume(value)
67
67
  end
68
68
 
69
+ def main_volume_up
70
+ remote_command('7A1A')
71
+ end
72
+
73
+ def main_volume_down
74
+ remote_command('7A1B')
75
+ end
76
+
69
77
  def zone2_volume_up
70
78
  remote_command('7ADA')
71
79
  end
data/seriamp.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "seriamp"
5
- spec.version = '0.1.3'
5
+ spec.version = '0.1.5'
6
6
  spec.authors = ['Oleg Pudeyev']
7
7
  spec.email = ['code@olegp.name']
8
8
  spec.summary = %q{Serial control for amplifiers & A/V receivers}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seriamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2022-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport