大家好,我正在尝试控制 Onkyo 接收器的主音量。问题是它在我到达第 10卷之前一直有效。第 0-9 卷工作得很好(将音量从 0 提高到 9)。但是,当我转到第 10 卷时,它显示的音量为16。第 11 卷=17卷,第 12 卷=18 卷等等。
excel表是这样说的:
"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)
我正在寻找转换器,我注意到10代表十六进制的 A。但即使发送该MVLA也无济于事。
我会错过什么?
更新(并解决)
Dim vol As Integer = Trim(lanSent(1).Replace("AVVOL", ""))
Dim vol2 = vol.ToString("X2")
Call avReceiver.remoteCommands("MVL" & vol2)