Research on Communication Technology Based on Windows CE

1. Introduction to Windows CE Communication

Windows CE is an operating system for mobile computing and embedded applications. Its outstanding advantages are modularity, customization, completeness, real-time performance, powerful communication functions, and Win32-based application programming interfaces. Windows CE supports two basic communication technologies: serial communication and network communication.

Discuss the two basic communication technologies supported by Windows CE, namely serial communication and network communication, and describe how to establish various serial connections and network connections based on Windows CE platform through Win32 API. For the various connection implementation methods, point out the difference between it and the desktop computer.

2. Serial communication in Windows CE

Serial communication requires that the receiving and sending parties have a direct point-to-point connection. This communication method can be realized through a serial cable or an infrared transceiver (ie, IR transceiver). From a software point of view, various serial communication devices are identified by COM port names (such as COM1, COM2, etc.). In Windows CE 2.x, the COM port is stored under the \ HKEY_LOCAL_MACHINE \ Drivers primary key in the registry. If a serial device is already installed in the system, you can view it through the \ HKEY_LOCAL_MACHINE \ AcTIve primary key in the registry. The serial communication based on the COM port is the same as the API function used for file reading and writing.

Unlike the desktop platform, when using an IR transceiver, Windows CE supports two infrared serial communication channels. One way is to treat the IR transceiver as a serial cable, called raw IR. The meaning of "raw" means that the transmitted data is not processed in any way, and the receiving and sending applications are responsible for conflict detection and other potential problems. The COM port assigned to raw IR is determined by the original equipment manufacturer (OEM) and listed in the registry. It is particularly important to note that the serial port must be set to IR mode (SETIR) through the EscapeCommfuncTIon function, not the ordinary serial mode (CLRID). Another way is a simplified serial communication method derived from an IrDA network protocol, called IrComm method. It allows applications to use the IrDA network protocol in exactly the same way as raw IR. From the programmer's point of view, the main difference between raw IR and IrComm is that they have different COM port assignments. In addition, for IrComm, it is not necessary to call the EscapeCommFuncTIon function to indicate that the corresponding serial port is in IR mode. Whether it is the common connection method using a serial cable, or the raw IR or IrComm method using an infrared transceiver, the steps for implementing serial communication in the Windows CE application program can be described as follows:

1) Determine the COM port to be opened through the registry;

2) Call CreateFile, use lpFileName to set the COM port name (such as COMl);

HANDLE CreateFile (LPCTSTR lpFileName, DWORD dwDesiredAccess);

lpFileName is the pointer of the COM port name, and dwDesiredAccess is the access (read and write) mode.

3) If it is raw IR mode, call EscapeCommFunction and set the COM port to IR mode;

BOOL EscapeCommFunction (HANDLE hFile, DWORD dwFunc);

hFile is the handle of the communication device. The handle is returned by CreateFile, and dwFunc takes the value SETIR, that is, the serial port is in IR mode.

4) Call SetCommTimeouts to set the communication pause time parameter;

BOOL SetCommTimeouts (HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts);

Among them, lpCommTimeouts is a structure pointer variable used to set time parameters.

5) Call ReadFile and WriteFile to send and receive data;

BOOL ReadFile (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead);

BOOL WriteFile (HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite);

Among them, hFile is the read / write file handle, lpBuffer is the read / write data buffer pointer, and nNmnberOfBytesToRead is the number of read / write data bytes.

6) Call CloseHandle to close the serial port.

BOOL CloseHandle (HANDLE hObject);

Except for the third step, the above steps are the same for all three serial communication methods.

3. Network communication in Windows CE

The network communication of Windows CE is based on a network stack organized by layers, as shown in Figure 1.

Network communication in Windows CE

figure 1

The network stack is actually a component of Windows CE. It is responsible for processing the data transmission in the network, decomposing the data from the application into several small segments, and adding the relevant address and segmentation information for each small segment Store and forward packets (packets), the addresses in the packets ensure that the data reaches the final destination endpoint. There are three ways to access the network stack: The first is the Winsock (port socket) method. This is a middle-layer transmission interface protocol. WinSock is responsible for processing all the details of the header information of the created packet, but it can ignore its data format. Windows CE network communication uses Winsock directly or indirectly. Using IrDA protocol to realize client / server network communication based on infrared socket (Irsock) is a characteristic of Windows CE platform. The second is the WinInet API method. WinInet API is Microsoft's Internet function interface based on Win32 platform. Windows CE's WinInet API has some restrictions or extensions. It provides advanced data protocols in addition to the common hypertext transfer protocol (HTTP) and file transfer protocol (FTP), and also provides Internet password protocols SST and PCT support. The API method avoids directly using WinSock to access the network and simplifies network programming. The third is the CIFS relocator method. Windows CE allows Windows CE-based devices to establish connections with remote hosts through support for Remote Access Service (RAS) customers. Here are some of the most commonly used high-level protocols for Windows CE, and discuss their network communication implementation methods.

3.1 Send ICMP request

ICMP (Internet Control Message Protocol) is a network layer Internet protocol used to learn about the status of IP services through other hosts. The typical usage is to send an ICMP request to test whether a host is connected to the Internet (called "Ping" operation). The method is to determine whether the host is available by sending an information packet to the accessed host (IP address) and waiting for its response. The basic steps are described as follows:

1) Call IcmpCreateFile to create a handle to send the request:

HANDLE WINAPI IcmpCreateFile (VOID): // When this function is called successfully, return ICMP handle

2) Call IcmpSendEcho, request ICMP response;

DWORD WINAPI IcmpSendEcho (HANDLE IcmpHandle, // Specify the ICMP handle opened by IcmpCreateFile

IPAddr DestinationAddress, // The IP address of the request response host

LPVOID RequestData, // Send the data contained in the buffer

WORD RequestSize, // Number of bytes in the send buffer

LPVOID ReplyBuffer, // Reply buffer

DWORD ReplySize, // Number of bytes in reply buffer

DWORD Timeout // Waiting time for request response, in milliseconds);

3) Call IcmpCloseHandle to close the ICMP handle created by IcmpCreateFile.

BOOL WINAPI IcmpCloseHandle (HANDLE IcmpHandle);

High brightness, the light source is made of imported ultra-high brightness LED series, 120LED / m or 144LED / m encryption arrangement is the fundamental guarantee of the overall luminous effect and high brightness. 

DIP & SMD LED lamps are options for different application.

Baiyang LED flex neon sign is widely used in shop,restaurant,home decoration,events as image wall,window sign,directional sign,brand logo,door head and gifts.send us the artwork and dimension.you are ensured to enjoy the unique private custom experience

Neon Letters

Neon Letters,Led Alphabet Letters,Led Light Up Letters,Custom Led Letters

Shenzhen Oleda Technology Co.,Ltd , https://www.baiyangsign.com