Using the Built-In Infrared Serial Port

The H/PC IR port supports point-to-point serial connections with any IrDA-compliant device. IR links are an ideal method for exchanging data between two H/PCs. You can establish connections between two IrDA-compliant devices whose ports are aligned within 15 degrees of each other. They must also be no more than three feet apart. IrDA specifications provide for serial IR links operating at speeds up to 115.2 KBps.

Some manufacturers supply only one universal asynchronous receiver transmitter (UART) to control the built-in serial port and the IR port. To access the IR port on H/PCs with a shared UART, you must redirect communications by using the EscapeCommFunction.

    To open and use the IR port on H/PCs with one UART for both ports
  1. Call CreateFile to open the built-in, nine-pin serial port, usually "COM1:."
  2. Call EscapeCommFunction with the handle obtained from CreateFile as the hFile parameter, and SETIR as the dwFunc parameter.

    The SETIR flag indicates the serial port is to be set to IR mode. EscapeCommFunction will return TRUE if an IR capable port has been selected.

  3. Fill the device control block structure DCB with the existing communication port settings by calling the GetCommState function.
  4. Configure the communication port by assigning values to the members of the DCB and calling the SetCommState function.
  5. Set the timeout values for read/write operations on the port with a call to the SetCommTimeouts function.
  6. Perform ReadFile and WriteFile operations on the device handle returned from CreateFile.

Windows CE supports Windows Sockets (Winsock) and the IR extensions to Winsock (IrSock) for developing communications applications for the H/PC.