Communications and Connectivity

One of the strengths of an H/PC is its ability to connect to and communicate with other computers and peripherals. This section discusses how to write applications that take advantage of these capabilities.

Programming a Built-in IR Port

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 an H/PC with a shared UART, you must redirect communications by using the EscapeComm function.

    To open and use the IR port on an H/PC with one UART for both ports

  1. Call the CreateFile function to open the built-in, nine-pin serial port, usually COM1:.
  2. Call the EscapeCommFunction function with the handle obtained from CreateFile as the hFile parameter and SETIR as the dwFunc parameter.

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

  3. Fill the DCB structure with the existing communication port settings by calling the GetCommState function.
  4. Configure the IR port by assigning values to the members of the DCB structure 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. Call the ReadFile and WriteFile functions on the device handle returned from CreateFile.

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

Note The Windows CE CreateFile function requires a colon appended to the device name. In most cases, COM1: designates the built-in serial port on an H/PC.