Connecting to the Remote Control

[This is preliminary documentation and subject to change.]

Before your application can start sending commands to the remote control, your application must first open a connection for writing to the serial port of the computer connected to the remote control. To open a connection for writing and obtain the device handle, your application should call the CreateFile function, part of the Microsoft® Win32® application programming interface (API), and pass the name of the port such as COM1 along with the GENERIC_WRITE, OPEN_EXISTING, and FILE_ATTRIBUTE_NORMAL flags. Because your application should only require sending a sequence of commands that consists of one or two one-byte values at a time, it should not require passing the FILE_FLAG_OVERLAPPED flag. This file-attribute flag specifies an asynchronous transfer of data for operations that take a significant amount of time to process.

After opening the connection, your application should configure the settings of the serial port device according to the parameters of the remote control to ensure the two devices follow the same protocol and communicate properly. To configure these settings, your application should first call the Win32 GetCommState function and retrieve the device-control block (DCB) structure for the serial device. Next, your application should assign the remote control's parameters to this DCB structure such as the baud and the number of data bits per byte. Finally, your application should call the Win32 SetCommState function and pass this reassigned DCB structure to configure the serial port device.

After the connection to the remote control is open and configured, your application should send a sequence of commands to the remote control that set the remote control in automatic mode. Your application should also set a flag that indicates a connection to a serial port is open and the remote control is in automatic mode.