|
在WinCE/PPC应用程序的开发过程中,经常使用模拟器来代替实机进行调试工作。 PPC2000及以前版本的模拟器,都是使用开发机上的真实目录来虚拟模拟器上的目录,所以将文件复制到相应的开发机目录中,便能在模拟器上访问。而从PPC2003开始,则是使用了Virtual PC的技术来构建模拟器,模拟器所有的内容都在一个bin镜像文件中,所以只能用远程文件查看器“Remote File Viewer”来访问模拟器上的目录和传输文件。 然而,如果您正在开发的程序与RAPI、Synchronization Providers相关的时候,那就不得不使用ActiveSync来连接模拟器了。 Windows Mobile 5.0 的模拟器直接支持ActiveSync连接,PPC2003模拟器则不然,因此要稍费功夫进行一下设置。 PPC2003模拟器连接ActiveSync的有两种方式,一种是串口方式,一种是虚拟网络方式,笔者将此两种方式的具体说明原文摘录如下: How to: Use ActiveSync with the EmulatorConnecting to the emulator through ActiveSync is important for convenience in moving files between the desktop computer and the emulator, as well as for testing and debugging custom ActiveSync synchronization providers. The emulator supports ActiveSync between the host computer (with Microsoft ActiveSync version 3.7 installed) and the emulator image. To use ActiveSync with the emulator, two available serial ports on the development workstation and a serial cable are required. The cable should be a straight-through cable, sometimes called an extension or a null modem cable (Belkin part number F2N209-6 or equivalent). Note To use a GSM radio that is connected to the emulator simultaneously with ActiveSync, the workstation might require additional serial ports. Serial ports COM1 through COM4 are the only usable ports within the emulator. For more information about setting up this option, see How to: Use Radio-Provided Wireless GSM Telephony in the Emulator. To configure the development development workstation to use ActiveSync - Connect each end of the serial cable to an available serial port (for example, COM1 or COM2).
- 'Ensure that the following registration key is set (COM# can equal COM1-COM4):
[HKLM\SOFTWARE\Microsoft\Windows CE Services]"SerialPort"="COM#" - If a Pocket PC device is connected to the workstation, remove the device from its cradle and disconnect the cradle from the workstation.
- In the ActiveSync application, on the File menu, click Connection Settings.
- Ensure that the Allow serial cable or infrared connection to this COM port check box is selected.
- Set the communications (COM) port in the drop-down list box to COM2 (or one of the COM ports to which the serial cable is connected).
- Click OK to close the Connection Settings dialog box.
- If you are using eMbedded Visual C++, do the following:
- On the Tools menu, click Configure Platform Manager.
- In the device list, click Pocket PC 2003 Emulator and then click Properties.
- Click the Configure button to the right of the Startup Server drop-down list box.
- In the drop-down list box next to Serial Port 1, click COM1 (or the other COM port to which the serial cable is connected).
- Click OK to close the Emulation Configuration Settings dialog box.
- Click Test.
- If you are using Visual Studio .NET 2003, do the following:
- On the Tools menu, click Options.
- Click Devices Tools, and then click Devices.
- In the Show devices for platform drop-down list box, click Pocket PC.
- In the Devices box, click Pocket PC 2003 Emulator.
- Click the Configure button to the right of the Startup server drop-down list.
- Click Hardware, and then click the COM port that is connected to the serial cable in the Serial port 1 drop-down list box.
- Click OK twice to save the configuration.
- Click Test.
- When the emulator image is loaded and Platform Manager has completed its test, press and hold CTRL (equivalent to the Action key on the device) and then click and hold the clock in the upper right of the title bar. When the shortcut menu appears, click Run.
Note When the emulator image loads, ActiveSync might try unsuccessfully to connect to it. If a dialog box appears, asking whether to disconnect the port from ActiveSync or retry, click retry. - In the Run dialog box, type repllog and then click OK. The Repllog.exe file is the device-side part of ActiveSync that initiates a connection to the partner computer.
- ActiveSync on the desktop computer side of the development workstation detects when a client is trying to connect without an established partnership, causing the New Partnership Wizard to be displayed. (The same wizard appears when a new or cold-booted device is connected to a desktop computer.) In this wizard, first choose whether to establish a partnership or to connect as a guest.
Note Establishing a guest connection is convenient when the sole purpose of the connection is to transfer files by means of ActiveSync. - Type a name to be used to identify the partnership and to set the device name of the emulator image.
- Select the types of information to be synchronized with the emulator.
- After a partnership is established, use the Save Emulator State option when exiting the emulator. This option preserves the partnership and data for future use in the emulator. For more information, see How to: Shut Down the Emulator.
When the New Partnership Wizard is complete, ActiveSync synchronizes the selected data to the emulator. Thereafter, any change made to the information (either in the emulator or on the desktop computer) is synchronized. How to: Use ActiveSync over Virtual SwitchTo use ActiveSync over virtual switch - Configure the emulator to use virtual switch. For more information, see How to: Change Ethernet Support in the Emulator.
- Start the emulator.
- To open the SDK command prompt, click Start, point to All Programs, click Microsoft Pocket PC 2003 SDK, and then click Pocket PC 2003 SDK.
- Run emuascfg, specifying the /PPC flag for the emulator, and then press ENTER.
Note The use of emuascfg is dependent on having the .NET Framework installed. Otherwise, the "The dynamic link library mscoree.dll could not be found..." error message appears. If you need to download and install the .NET Framework, visit the .NET Framework Software Development Kit Version 1.1 download page. - When the command is finished running, close the command prompt window.
- In ActiveSync, in the Connection Settings dialog box, confirm that Allow Network (Ethernet) and Remote Access Service (RAS) server connection with this desktop computer is selected.
- Switch to the emulator.
- Open ActiveSync in the emulator.
- Click Sync.
The emulator now connects to the desktop computer through Ethernet. How to: Change Ethernet Support in the EmulatorWhen developing an application for deployment on devices that might not be configured to form a network, turning off Ethernet support enables application testing in a disconnected state. Applications that are running in the emulator cannot be debugged when Ethernet support is disabled. To change Ethernet support in the emulator - Shut down the emulator if it is running.
- In eMbedded Visual C++, on the Tools menu, click Configure Platform Manager.
- In the device list, click Pocket PC 2003 Emulator, and then click Properties.
- Click the Configure button to the right of the Startup Server drop-down list box.
- Select a network option.
- Click OK to close the Emulation Configuration Settings dialog box.
- Click TEST to restart the emulator.
- Wait for the Testing Device Connection dialog box to show an OK button.
- Click OK to close the Testing Device Connection dialog box.
- Click OK to close Device Properties dialog box.
- Click OK to close the Windows CE Platform Manager Configuration dialog box.
- Three emulator-network options are available: Disabled, Network address translation, and Virtual switched. The capabilities of each option are as follows:
- Disabled
The network card is not available to the emulator. - Network address translation:
Uses the same IP as the host computer. Allows commands only when started by the emulator. The emulator sends out requests for information and can receive replies to its own requests. However, it cannot receive unsolicited information. - Virtual switched:
Note This option is available in the Microsoft eMbedded Visual C++ version 4.0 emulator only. Microsoft Visual Studio® .NET does not support the virtual switch option. Gives the device an IP. Uses Dynamic Host Configuration Protocol (DHCP) to get an IP. The device appears on the network at the IP. Is available for incoming and outgoing messages.
|