Specifications
Remote Control and Receiver-Transceiver Specifications and Requirements
for Windows Media Center in Windows Operating Systems
113
// get next byte from host
byte b = getNextByteFromHost();
if ( errorState ) {
// if we're in an error state, see if we can exit the error state
// don't actually remove the next byte from the incoming buffer yet.
if ( peekNextByteFromHost() == CMD_RESUME ) errorState = false;
}
// only do processing if we're not in error state
if ( !errorState )
{
// switch on command byte
switch (b) {
case CMD_PORT_IR: handleIrCommand(); break;
case CMD_PORT_SYS: handleSysCommand(); break;
case CMD_PORT_SER: handleFlush(); break;
default:
if ( (b & 0xe0) == 0x90 ) {
// If the high 3 bits are 100, this is an IR packet.
// The length of the IR packet is in the low 5 bits
blastIr(b & 0x1f);
} else {
// otherwise, it's an illegal command
illegalCommand();
}
break();
}
}
}
}
void handleIrCommand() {
// get the next byte from the host.
byte b = getNextByteFromHost();
switch (b) {
case CMD_SETIRCFS: HandleSetIrcfs(); break;
case CMD_GETIRCFS: HandleGetIrcfs(); break;
// add code here to handle all the other PORT_IR commands.
default:
// any other commands are errors
illegalCommand();
}
}
void illegalCommand() {
// report the illegal command to the host
sendRspCmdIllegalToHost();
// set the device into an error state
errorState = true;
This behavior will be tested as part of our test suites. The expected interaction is as follows:
1. Test sends an illegal command to the device.
2. Test validates the RSP_CMD_ILLEGAL response.
3. Test sends a flush command to the device.
4. Test validates that the device does not respond.
5. Test sends a CMD_RESUME command to the device.
6. Test sends a flush command to the device.










