OnkyoReceiverのマスターボリュームを制御しようとしています。問題は、ボリューム10に到達するまで機能することです。ボリューム番号0〜9は問題なく機能します(ボリュームを0から9に上げます)。ただし、ボリューム10に移動すると、ボリュームは16として表示されます。11巻=17、12巻=18など。
エクセルシートには次のように書かれています。
"00"-"64" Volume Level 0 - 100 ( In hexadecimal representation)
そして、シリアルコマンドは次のとおりです。
Public Function remoteCommands(ByVal theCommand As String) As Boolean
Dim Stream As NetworkStream
Dim Client As New TcpClient()
Dim streamw As StreamWriter
Dim i As Int32
On Error GoTo blah
Client.Connect(main.avIP, 60128)
Stream = Client.GetStream()
Dim returndata As String = ""
If Client.Connected And Stream.CanWrite Then
streamw = New StreamWriter(Stream)
Dim sendBytes(theCommand.Length + 18) As Char
sendBytes(0) = "I"
sendBytes(1) = "S"
sendBytes(2) = "C"
sendBytes(3) = "P"
sendBytes(4) = Chr(0)
sendBytes(5) = Chr(0)
sendBytes(6) = Chr(0)
sendBytes(7) = Chr(16)
sendBytes(8) = Chr(0)
sendBytes(9) = Chr(0)
sendBytes(10) = Chr(0)
sendBytes(11) = Chr(theCommand.Length + 3)
sendBytes(12) = Chr(1)
sendBytes(13) = Chr(0)
sendBytes(14) = Chr(0)
sendBytes(15) = Chr(0)
sendBytes(16) = "!"
sendBytes(17) = "1"
For i = 0 To (theCommand.Length - 1)
sendBytes(18 + i) = theCommand.Chars(i)
Next
sendBytes(theCommand.Length + 18) = Chr(13) '&HD
streamw.Write(sendBytes)
Dim bytes(Client.ReceiveBufferSize) As Byte
Stream.Read(bytes, 0, CInt(Client.ReceiveBufferSize))
returndata = Encoding.ASCII.GetString(bytes)
streamw.Flush()
Else
MsgBox("error: Stream.Canwrite failed")
End If
Client.Close()
End Function
そして、これは私が上記の関数を呼び出す方法です:
Dim vol As String = Trim(lanSent(1).Replace("AVVOL", ""))
If Len(vol) = 1 Then
vol = "0" + vol
Else
Select Case vol
Case 10
vol = "a"
Case 11
vol = "b"
End Select
End If
Call avReceiver.remoteCommands("MVL" & vol)
コンバーターを探していたところ、16進数で10がAを表していることに気づきました。しかし、そのMVLAを送信しても何も起こりません。
私は何が欠けているでしょうか?
更新(および解決済み)
Dim vol As Integer = Trim(lanSent(1).Replace("AVVOL", ""))
Dim vol2 = vol.ToString("X2")
Call avReceiver.remoteCommands("MVL" & vol2)