onkyo_eiscp_ruby 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/mock_receiver.rb +2 -1
- data/bin/onkyo.rb +2 -2
- data/lib/eiscp.rb +1 -1
- data/lib/eiscp/dictionary.rb +6 -7
- data/lib/eiscp/dictionary/dictionary_generators.rb +3 -3
- data/lib/eiscp/dictionary/dictionary_helpers.rb +5 -5
- data/lib/eiscp/message.rb +1 -0
- data/lib/eiscp/parser/eiscp_parser.rb +7 -2
- data/lib/eiscp/parser/iscp_parser.rb +2 -4
- data/lib/eiscp/receiver.rb +6 -14
- data/lib/eiscp/receiver/command_methods.rb +1 -1
- data/test/tc_dictionary.rb +1 -1
- data/test/tc_message.rb +4 -1
- data/test/tc_parser.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35b01beb072ac7058ef54920b734aff8d4d098ecc702eb9edd21ee818ad7ca0
|
4
|
+
data.tar.gz: f1112ac834d03f1dea2e50aeed301ac8f0e802b55b00b0f317d7802515ffa84e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3a50446a0df21efd8dc6b2397daeb0cf791a997e7f0c27bb9d01c98b9e08fdc99cd68176b464882b29acc64a5f9cbe0748da690da51269f10f8f41f3d75dfc7
|
7
|
+
data.tar.gz: 65bafa48d392b8578435f006de9b27b8e58b9f16d7ccd7e2d527b38f23c0e2db187204c79f9c2dfe121021907735b51f73b82cef8fb82789ac362b5c3fec228f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/bin/mock_receiver.rb
CHANGED
@@ -11,7 +11,8 @@ module EISCP
|
|
11
11
|
#
|
12
12
|
class MockReceiver
|
13
13
|
DISCOVERY_IP = '255.255.255.255'
|
14
|
-
ONKYO_DISCOVERY_RESPONSE = Message.new('ECN',
|
14
|
+
ONKYO_DISCOVERY_RESPONSE = Message.new('ECN',
|
15
|
+
"TX-NR609/60128/DX/14DAE9E967C8\x19\r\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
|
15
16
|
|
16
17
|
# Create/start the server object.
|
17
18
|
|
data/bin/onkyo.rb
CHANGED
@@ -115,8 +115,8 @@ class Options
|
|
115
115
|
puts ' Value - Description>'
|
116
116
|
puts "\n"
|
117
117
|
command_hash[:values].each do |_value, attr_hash|
|
118
|
-
|
119
|
-
|
118
|
+
puts " '#{EISCP::Dictionary.command_value_to_value_name(command, _value)}' - "\
|
119
|
+
" #{attr_hash[:description]}"
|
120
120
|
end
|
121
121
|
puts "\n"
|
122
122
|
end
|
data/lib/eiscp.rb
CHANGED
data/lib/eiscp/dictionary.rb
CHANGED
@@ -14,14 +14,12 @@ module EISCP
|
|
14
14
|
extend DictionaryHelpers
|
15
15
|
|
16
16
|
class << self
|
17
|
-
attr_reader :zones
|
18
|
-
attr_reader :modelsets
|
19
|
-
attr_reader :commands
|
17
|
+
attr_reader :zones, :modelsets, :commands
|
20
18
|
end
|
21
19
|
|
22
20
|
DEFAULT_ZONE = 'main'
|
23
21
|
@yaml_file_path = File.join(__dir__, '../../eiscp-commands.yaml')
|
24
|
-
@commands = YAML.
|
22
|
+
@commands = YAML.safe_load(File.read(@yaml_file_path), permitted_classes: [Symbol])
|
25
23
|
@modelsets = @commands[:modelsets]
|
26
24
|
@commands.delete(:modelsets)
|
27
25
|
@zones = @commands.map { |k, _| k }
|
@@ -32,11 +30,12 @@ module EISCP
|
|
32
30
|
command = command[0]
|
33
31
|
@commands[zone][command][:values].each do |value|
|
34
32
|
value = value[0]
|
35
|
-
|
33
|
+
case value
|
34
|
+
when Array
|
36
35
|
@additions << [zone, command, value, create_range_commands(zone, command, value)]
|
37
|
-
|
36
|
+
when /^(B|T){xx}$/
|
38
37
|
@additions << [zone, command, value, create_treble_bass_commands(zone, command, value)]
|
39
|
-
|
38
|
+
when /^{xx}$/
|
40
39
|
@additions << [zone, command, value, create_balance_commands(zone, command, value)]
|
41
40
|
else
|
42
41
|
next
|
@@ -37,8 +37,8 @@ module EISCP
|
|
37
37
|
tmp.merge!((value[0] + v.to_s) =>
|
38
38
|
{
|
39
39
|
name: value[0].downcase + v,
|
40
|
-
description: @commands[zone][command][:values][value[0]
|
41
|
-
models: @commands[zone][command][:values][value[0]
|
40
|
+
description: @commands[zone][command][:values]["#{value[0]}{xx}"][:description].gsub(/\(.*[\]|)]$/, v),
|
41
|
+
models: @commands[zone][command][:values]["#{value[0]}{xx}"][:models]
|
42
42
|
})
|
43
43
|
end
|
44
44
|
tmp
|
@@ -52,7 +52,7 @@ module EISCP
|
|
52
52
|
tmp.merge!(v.to_s =>
|
53
53
|
{
|
54
54
|
name: v.downcase,
|
55
|
-
description: @commands[zone][command][:values]['{xx}'][:description].gsub(/\(.*[\]
|
55
|
+
description: @commands[zone][command][:values]['{xx}'][:description].gsub(/\(.*[\]|)]$/, v),
|
56
56
|
models: @commands[zone][command][:values]['{xx}'][:models]
|
57
57
|
})
|
58
58
|
end
|
@@ -52,9 +52,9 @@ module EISCP
|
|
52
52
|
def command_value_to_value_name(command, value)
|
53
53
|
zone = zone_from_command(command)
|
54
54
|
command_value = @commands[zone][command][:values][value][:name]
|
55
|
-
if command_value.
|
55
|
+
if command_value.instance_of?(String)
|
56
56
|
command_value
|
57
|
-
elsif command_value.
|
57
|
+
elsif command_value.instance_of?(Array)
|
58
58
|
command_value.first
|
59
59
|
end
|
60
60
|
rescue StandardError
|
@@ -65,13 +65,13 @@ module EISCP
|
|
65
65
|
def command_value_name_to_value(command, value_name)
|
66
66
|
zone = zone_from_command(command)
|
67
67
|
@commands[zone][command][:values].each_pair do |k, v|
|
68
|
-
if v[:name].
|
68
|
+
if v[:name].instance_of?(String)
|
69
69
|
return k if v[:name] == value_name.to_s
|
70
|
-
elsif v[:name].
|
70
|
+
elsif v[:name].instance_of?(Array)
|
71
71
|
return k if v[:name].first == value_name.to_s
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
nil
|
75
75
|
rescue StandardError
|
76
76
|
nil
|
77
77
|
end
|
data/lib/eiscp/message.rb
CHANGED
@@ -17,19 +17,24 @@ module EISCP
|
|
17
17
|
unit_type: msg.unit_type,
|
18
18
|
start: msg.start
|
19
19
|
)
|
20
|
-
packet.header =
|
20
|
+
packet.header = create_header(array)
|
21
|
+
packet
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_header(array)
|
25
|
+
{
|
21
26
|
magic: array[0],
|
22
27
|
header_size: array[1],
|
23
28
|
data_size: array[2],
|
24
29
|
version: array[3],
|
25
30
|
reserved: array[4]
|
26
31
|
}
|
27
|
-
packet
|
28
32
|
end
|
29
33
|
|
30
34
|
def self.validate(packet)
|
31
35
|
packet.header.header_size.size == packet.command.size
|
32
36
|
end
|
37
|
+
|
33
38
|
end
|
34
39
|
|
35
40
|
class EISCPParserException < RuntimeError; end
|
@@ -6,7 +6,7 @@ module EISCP
|
|
6
6
|
#
|
7
7
|
module ISCPParser
|
8
8
|
# Regexp for parsing ISCP messages
|
9
|
-
REGEX = /(?<start>!)?(?<unit_type>(
|
9
|
+
REGEX = /(?<start>!)?(?<unit_type>(?:\d|x))?(?<command>[A-Z]{3})\s?(?<value>.*?)(?<terminator>[[:cntrl:]]*$)/
|
10
10
|
def self.parse(string)
|
11
11
|
match = string.match(REGEX)
|
12
12
|
|
@@ -17,9 +17,7 @@ module EISCP
|
|
17
17
|
hash.delete_if { |_, v| v.nil? || v == '' }
|
18
18
|
|
19
19
|
# Convert keys to symbols
|
20
|
-
hash = hash.
|
21
|
-
memo[k.to_sym] = v
|
22
|
-
end
|
20
|
+
hash = hash.transform_keys(&:to_sym)
|
23
21
|
|
24
22
|
Message.new(**hash)
|
25
23
|
end
|
data/lib/eiscp/receiver.rb
CHANGED
@@ -133,12 +133,11 @@ module EISCP
|
|
133
133
|
# Sends an EISCP::Message object or string on the network
|
134
134
|
#
|
135
135
|
def send(eiscp)
|
136
|
-
if
|
137
|
-
|
138
|
-
|
139
|
-
if eiscp.is_a? EISCP::Message
|
136
|
+
connect if @socket.nil? || @socket.closed?
|
137
|
+
case eiscp
|
138
|
+
when EISCP::Message
|
140
139
|
@socket.puts(eiscp.to_eiscp)
|
141
|
-
|
140
|
+
when String
|
142
141
|
@socket.puts eiscp
|
143
142
|
end
|
144
143
|
end
|
@@ -148,8 +147,7 @@ module EISCP
|
|
148
147
|
def recv
|
149
148
|
data = String.new
|
150
149
|
data << @socket.gets until data.match(/\r\n$/)
|
151
|
-
|
152
|
-
message
|
150
|
+
Parser.parse(data)
|
153
151
|
end
|
154
152
|
|
155
153
|
# Sends an EISCP::Message object or string on the network and returns recieved data string.
|
@@ -190,13 +188,7 @@ module EISCP
|
|
190
188
|
info[:values].each do |value, _|
|
191
189
|
next unless value == 'QSTN'
|
192
190
|
|
193
|
-
|
194
|
-
# If we send any faster we risk making the stereo drop replies.
|
195
|
-
# A dropped reply is not necessarily indicative of the
|
196
|
-
# receiver's failure to receive the command and change state
|
197
|
-
# accordingly. In this case, we're only making queries, so we do
|
198
|
-
# want to capture every reply.
|
199
|
-
sleep DEFAULT_TIMEOUT
|
191
|
+
send_recv(Parser.parse("#{command}QSTN"))
|
200
192
|
end
|
201
193
|
end
|
202
194
|
end
|
@@ -16,7 +16,7 @@ module EISCP
|
|
16
16
|
Dictionary.commands[zone].each do |command, _values|
|
17
17
|
command_name = Dictionary.command_to_name(command).to_s.gsub(/-/, '_')
|
18
18
|
define_method(command_name) do |v|
|
19
|
-
instance_exec Parser.parse(command_name.gsub(/_/, '-')
|
19
|
+
instance_exec Parser.parse("#{command_name.gsub(/_/, '-')} #{v}"), &block
|
20
20
|
end
|
21
21
|
rescue StandardError => e
|
22
22
|
puts e
|
data/test/tc_dictionary.rb
CHANGED
data/test/tc_message.rb
CHANGED
@@ -8,7 +8,10 @@ class TestMessage < MiniTest::Test
|
|
8
8
|
DISCOVERY_STRING = DISCOVERY_PACKET.to_eiscp
|
9
9
|
|
10
10
|
def test_create_discovery_iscp_message
|
11
|
-
assert_equal(
|
11
|
+
assert_equal(
|
12
|
+
EISCP::Message.new(command: 'ECN', value: 'QSTN', terminator: "\r\n", unit_type: 'x',
|
13
|
+
start: '!').to_iscp, '!xECNQSTN'
|
14
|
+
)
|
12
15
|
end
|
13
16
|
|
14
17
|
def test_create_messages
|
data/test/tc_parser.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onkyo_eiscp_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rodrigues
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "\n Control Onkyo receivers over the network.Use the provided binary
|
14
14
|
or\n require the library for use in your scripts.\n "
|