Professional Documents
Culture Documents
The basics are described in RX-Vx700_RS232C_Standard.pdf. All commands and their replies are made
up of printable ASCII strings, except for the initial STX (ASCII code 2) and terminating ETX (code 3). For
example, if a command is listed as 07E7E, it must be sent as the ASCII string “07E7E”, not as the five
bytes that make up the hexadecimal number 0x07E7E.
It’s important to realize that the receiver not only sends replies to commands from the host, it may also
issue unsolicited playback status reports whenever its internal status changes (e.g. when the volume is
turned up or down via the remote control or the main volume knob). Some applications can ignore these
status reports, but others rely on them. For example, the VolumeControl application does not initiate
communication, it just waits for volume changed status reports and then acts on them.
The VolumeControl and PEQedit applications were written with VB .NET 2008, and I assume they can
easily be ported to C#. All RS-232 communication uses the .NET SerialPort control.
Synchronous Model
An application like PEQedit waits for user input through its GUI before sending a command to the
receiver, and immediately after sending each command it reads the serial port synchronously to wait for the
associated reply. In this type of application, extra playback status reports are unwanted and can get in the
way. When reading a string from the serial port you need to make sure the string you just read was actually
the reply that you expected.
Asynchronous Model
An application that needs to monitor the current state of the receiver should use an asynchronous model and
listen for playback status reports (this is the way VolumeControl works). It uses the SerialPort
DataReceived event to read and buffer characters as they arrive, and when it sees the ETX character it
knows that a complete report has been received.
Many different reports are possible, and not all are relevant. So the event handler function just looks for the
reports it needs to, and ignores the rest. The relevant part of the code is shown below.
For debugging, PortMon can be very useful. This is a free download from Microsoft that lets you monitor
all serial port activity. You can also use VolumeControl with the /debug switch to display all the bytes it’s
receiving (see http://www.avsforum.com/avs-vb/showthread.php?p=14748684#post14748684), but you
won’t be able to run VolumeControl at the same time as another application that opens the serial port.
1
22-Jan-2009
For I = 1 To NumBytes
Val = SerialPort1.ReadByte()
Ch = Chr(Val)
If Val = 2 Or Val = &H11 Or Val = &H12 Or Val = &H14 Then 'STX, DC1, DC2 or DC4
Report(0) = Val
ReportSize = 1 ' Start of a new report
Else
Report(ReportSize) = Val
ReportSize = ReportSize + 1 ' Continuation of the current report
End If
'
' Add other cases here to handle different reports (signal type, etc.)
'
End If
Next
End Sub
2
22-Jan-2009
Note that the volume may be reported in two different ways. The first case applies when the user changes
volume using the receiver’s remote control or volume knob. The second case applies when your application
explicitly requested a volume report by sending the “main volume text request” command (“22001”). The
latter case is useful when you need to force a volume report at the start of your application. The two
methods return the volume in different formats, and the above event handler recognizes both of them.
As soon as a new volume value has been received you might want to update your application’s GUI, but
remember that the serial port event handler is running in a different thread and you have to be careful to
synchronize things if your main application thread may also be updating the GUI.
Initialization Commands
It can be useful to automatically turn on the receiver when required. You also need to set a few other
things, such as making sure command reports are enabled. The typical initialization sequence is (neglecting
error checking):
SerialPort1.Open()
The above command sequence will generate several reports from the receiver, including the long
Configuration command which is almost 200 bytes. When synchronously reading back a single report from
the receiver, just read everything up to the next ETX character like this,
If SerialPort1.IsOpen Then
Report = SerialPort1.ReadTo(Chr(3)) ' commands all end in ETX
Else
Report = Chr(3)
End If
Return Report
End Function
Remember that the receiver can generate extra playback status reports, so check the contents of the report
string carefully to make sure it’s the one you expected and not something else. If necessary read the next
report until you find the one you want.
The Yamaha documents describe the type of cable required (a null modem with some wires crossed), and
the RS-232 settings (9600 baud, 8 data bits, no parity, 1 stop bit, hardware handshaking).