Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 9 of 13

TREQ-M4 Mobile Data Terminal Manual: Chapter 6. Application Development, pages 51 to 60

Pages 51 to 60 of 98, from TREQ-M4 Mobile Data Terminal Manual

The original document is the PDF (2.4 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the QSI Corp TREQ-M4, Beijer TREQ-M4 and Micronet TREQ-M4

Page 51

CHAPTER 6

APPLICATION DEVELOPMENT 6.1 Introduction This chapter describes the process of developing and debugging applications for the TREQ-M4 and assumes familiarity with the C programming language and Windows application remote debugging procedures. (If necessary, consult the Microsoft MSDN library for a refresher on remote debugging.) This information is intended for integrators and application developers as a guide in setting up the TREQ-M4 for application development and as a reference for programmatic interfaces (API) to software drivers for various terminal peripherals. The TREQ-M4 is a Windows CE-based computer with specialized hardware peripherals that make it suitable for vehicular applications. Application development and debugging procedures for the TREQ-M4, as well as the software driver API, are similar to other Windows CE-based devices. This chapter provides instructions and references for TREQ-M4-specific functionality. For example, the TREQ-M4 has a serial port, but the serial port driver interface is not documented in this manual because the interface is a standard, well-known API.

6.1.1

Glossary API Application Program Interface SDK Software Development Kit IDE Integrated Development Environment

6.1.2

Related Documents • Microsoft Visual Studio 2005 MSDN Library • Microsoft Visual Studio 2008 MSDN Library • Windows Embedded CE 6.0 Documentation http://msdn.microsoft.com/en-us/library/bb159115.aspx

• Shared Windows Mobile 6 and Windows Embedded CE 6.0 Library http://msdn.microsoft.com/en-us/library/bb158484.aspx

TREQ-M4 Mobile Data Terminal

41

Page 52

Setup

Application Development

6.2 Setup 6.2.1

Prerequisites The following are required before setting up the TREQ-M4 for application development. Either an Ethernet or Serial connection is required (both are included here for completeness). Ethernet connection: The host can communicate with the TREQ-M4 during a remote debugging session over an Ethernet network. The TREQ-M4 should be connected to the same network and on the same subnet as the host. The network can be established using either the internal 10/100 Ethernet adapter or an external USB adapter. Use the DM9CE1 connectoid to configure the internal Ethernet connection (refer to section 4.1.6, “Network and Dial-up Connections”). Use the Windows CE Wireless Zero Configuration tool that automatically launches when the USB WiFi adapter is inserted to configure the wireless Ethernet connection (refer to section 7.2, “Wireless Ethernet”). Use the AX887721 connectoid to configure the USB-to-wired Ethernet adapter (refer to section 7.3, “Ethernet (over USB)”). Serial connection: The host can communicate with the TREQ-M4 during a remote debugging session via ActiveSync over a serial connection. The connection must be a “full” serial port, meaning that all of the following serial protocol signals must be connected to and supported by the host PC: RX, TX, RTS, CTS, DTR, DSR, and DCD. The TREQ-M4 Developer’s Kit includes a USB-to-serial converter that can be used for the ActiveSync connection. Software Development Kit: The SDK is an MSI installable file distributed by Beijer Electronics. The SDK should be installed so that the host IDE knows how to connect to the TREQ-M4. The SDK also provides headers and libraries that correspond to the available services and features included in the TREQ-M4 Windows CE image. Integrated Development Environment: Microsoft Visual Studio 2005 and/or Microsoft Visual Studio 2008 should be installed as a development environment for the TREQ-M4 application. These programs are used to compile and remotely debug the application.The latest service packs and updates for these Microsoft programs must be installed.

6.2.2

SDK Installation The latest Software Development Kit is available from the Beijer Electronics website (http://www.beijerelectronicsinc.com). The SDK and Windows CE image release dates should match to ensure that all features and services in the image correspond to those offered in the SDK. Use the latest available SDK version if the release date of the most recent Windows CE image supersedes that of the SDK.

42

TREQ-M4 Mobile Data Terminal

Page 53

Application Development

Setup

To install the SDK on your PC host, download the .msi file from the Beijer Electronics website, right-click the file name, and select Install. After the installation is complete, verify that “TREQ-M4” appears in the Tools, Connect to Device dialog box in Microsoft Visual Studio 2005 and Microsoft Visual Studio 2008.

6.2.3

Target Setup

6.2.3.1 ActiveSync You can use the ActiveSync protocol to establish a remote debugging connection with the Integrated Development Environment. Refer to Chapter 5, “Connect to a PC Via ActiveSync” for ActiveSync setup instructions. 6.2.3.2 Manual Server If you do not use ActiveSync, you must set up a manual Ethernet client server on the TREQ-M4. You must configure this server to respond to debug or download connection requests from the host PC's IDE. ActiveSync has the advantage of easier setup because the IP address of the target is negotiated automatically; however, it also uses a slower connection over the serial port. At a TREQ-M4 command prompt window, navigate to \HardDisk\bin\client. Instructions for using conmanclient2.exe and cmaccept.exe can be found online at http://msdn2.microsoft.com/en-us/library/ms228708(VS.80).aspx. These instructions apply to both Microsoft Visual Studio 2005 and Microsoft Visual Studio 2008.

6.2.4

Microsoft Visual Studio 2005/2008 Take the following steps to configure Visual Studio to connect with the TREQ-M4 target. (Refer to Figure 26, “TREQ-M4 Device Connection with Visual Studio.”) 1. From the Visual Studio Tools menu, select Options, Device Tools, Devices. 2. Select TREQ-M4 from the “Show devices for platform” drop-down box. “TREQ-M4 ARMV4I Device” should be the only device listed in the “Devices” box. 3. Select Properties. 4. From the “Default output location on device” drop-down box, select the desired location for deploying the Visual Studio project executables and libraries. Select Root folder if you want to download to \HardDisk. The path to the directory in the root location is specified in the Visual Studio Project Properties dialog box. 5. Click [Configure]. 6. If using ActiveSync, select Obtain an IP address automatically using ActiveSync. If using the ConMan Ethernet client (manual server), select Use specific IP address, and type in the IP address of the TREQ-M4. Detailed instructions are available online at http://msdn2.microsoft.com/en-us/library/ms228708(VS.80).aspx.

TREQ-M4 Mobile Data Terminal

43

Page 54

Setup

Application Development

Figure 26 TREQ-M4 Device Connection with Visual Studio

44

TREQ-M4 Mobile Data Terminal

Page 55

Application Development

Setup

7. Verify the device connection. From the Tools menu, select Connect to Device. Refer to Figure 27.

Figure 27 Visual Studio, Connect to TREQ-M4 Device 8. Make sure the selected platform is “TREQ-M4,” and the device is “TREQ-M4 ARMV4I Device.” The status bar at the bottom of the Visual Studio workspace window should indicate a successful connection. You can use Visual Studio to construct sample native and managed applications to test the Build, Deploy, and Debug process. Take the following steps. 6.2.4.1 Native 1. From the Visual Studio File menu, select New Project. 2. Select Visual C++, Smart Device, and MFC Smart Device Application in the window on the right. 3. Select a directory for the project, and click [OK]. 4. Click [Next]. Move the “TREQ-M4 SDK” to the “Selected SDKs” column. It should be the only selected SDK (move any others to the left). 5. Continue to configure the application with the next few dialog boxes as desired.

TREQ-M4 Mobile Data Terminal

45

Page 56

Setup

Application Development

6. Enable the Device toolbar from the View, Toolbars menu. 7. Make sure that the “Target Device” drop-down list shows “TREQ-M4 ARMV4I Device.” If not, click [Device Options] (next to the drop-down list), and select TREQ-M4 from the “Show devices for platform” drop-down list. 8. Right-click the project from the Solution Explorer window, and select Properties to bring up the Property Pages for the project. 9. In Configuration Properties, Debugging and Deployment, set the Remote Executable and Remote Directory parameters, respectively (see Figure 28). These parameters determine the path in the TREQ-M4 file system where the executable will be deployed and executed.

Figure 28 Visual Studio, Native Project Properties

46

TREQ-M4 Mobile Data Terminal

Page 57

Application Development

Setup

6.2.4.2 Managed The TREQ-M4 comes with the .NET Compact Framework v3.5 pre-installed. Most applications targeting the .NET Compact Framework v2.0 are compatible with v3.5. Visual Studio 2005 will deploy, install, and debug with the .NET Compact Framework v2.0 by default, if “Deploy the latest version of the .NET Compact Framework” is checked (see Figure 29). Uncheck this box to debug with the preinstalled version (v3.5). Visual Studio 2005 does not have an option to deploy and install v3.5. Visual Studio 2008 offers a selection between v2.0 and v3.5 at the time of project creation (refer to step 2 below). If “Deploy the latest version of the .NET Compact Framework” is checked (see Figure 29), Visual Studio will deploy, install, and debug with the selected version. 1. From the Visual Studio File menu, select New Project. 2. In Visual Studio 2005, select Other Languages, Visual C#, Smart Device, Windows CE 5.0, and Device Application in the window on the right. In Visual Studio 2008, select Visual C#, Smart Device, and Smart Device Project in the window on the right. In the “Add New Smart Device Project” dialog box, select Windows CE as the target platform, the desired .NET Compact Framework version (v3.5 is installed by default on the TREQ-M4), and Device Application from Templates. 3. Select a directory for the project, and click [OK]. 4. Enable the Device toolbar from the View, Toolbars menu. 5. Make sure that the “Target Device” drop-down list shows “TREQ-M4 ARMV4I Device.” If not, click [Device Options] (next to the drop-down list), and select TREQ-M4 from the “Show devices for platform” drop-down list. 6. Right-click the project from the Solution Explorer window, and select Properties to bring up the Property Pages for the project. 7. In Devices, select TREQ-M4 ARMV4I Device from the Target device drop-down list. 8. In Devices, select the desired Output file folder (see Figure 29, “Visual Studio, Managed Project Properties”). This parameter determines the path in the TREQ-M4 file system where the executable will be deployed and executed.

TREQ-M4 Mobile Data Terminal

47

Page 58

Setup

Application Development

Figure 29 Visual Studio, Managed Project Properties

6.2.5 Remote Tools Microsoft provides several remote tools with the Visual Studio 2005 and Visual Studio 2008 installation, such as Remote Registry Editor and Remote Zoom In (for screen capture). These tools work over an established remote debugging connection. Follow the procedures outlined in sections 6.2.1 through 6.2.3 to set up this connection. Note that there may be a delay the first time a remote tool requests to connect to the TREQ-M4 target. The platform manager framework copies required libraries and executables for running the remote tool during this time. Subsequent connection requests will not have this delay unless the TREQ-M4 has been rebooted since the last request.

48

TREQ-M4 Mobile Data Terminal

Page 59

Application Development

Software Drivers

Refer to the following MSDN links for additional information about the Microsoft remote tools: http://msdn.microsoft.com/en-us/library/aa935548.aspx http://msdn.microsoft.com/en-us/library/aa935675.aspx

6.3 Software Drivers Software access and control of specialized hardware peripherals on the TREQ-M4 are provided through device driver and registry interfaces. These interfaces utilize the standard Windows stream driver API (e.g., CreateFile, WriteFile, ReadFile, and DeviceIoControl) and registry access API (RegOpenKeyEx, RegQueryValueEx, etc.). Most TREQ-M4 peripherals do not fit the typical model for stream devices that transfer large amounts of data, thus the traditional operations like read and write are not supported. The primary access and control mechanism is the DeviceIoControl function, which provides flexibility via custom IOCTL codes. Refer to Microsoft documentation for a detailed description of the driver and registry API functions. The following sections outline the behavior, supported IOCTL codes, and registry keys/values for each peripheral. IOCTL codes are described in the form of sample C code and in-line comments. The inputs and outputs of each IOCTL are described. Sample calls are provided to illustrate proper usage for each IOCTL. IOCTL defines and enumeration values for input and output parameters to the DeviceIoControl function are described in the file TreqPublic.h that is included in the software development kit distribution (\Program Files\Windows CE Tools\wce600\TREQ-M4\ Include\Armv4i\TreqPublic.h). For example, the keypad button key defines are listed in this header file. The sample code below references TreqPublic.h as appropriate. Registry keys/values are listed in a standard [key] “value” format. These keys/values may be queried or set programmatically via the registry access API or by using a utility program like RegEditCE.exe (refer to section 4.7.2, “Beijer Electronics” on page 32). NOTE

6.3.1

☞

The code in the following sections is included “as is” for illustration purposes only. It is recommended that the application developer check the return value for success or failure of device driver API calls.

Keypad The keypad driver initiates scans of four elastomeric function keys and reports presses to the GWES (graphical, window, and events) Windows CE subsystem. Single and multiple simultaneous presses are supported. Auto-repeat is supported, including variable initial delay and repeat rate. These parameters apply globally to all keys in the built-in keypad and to any externally connected USB keyboard and can be set via keypad driver DeviceIoControl calls or via the Keyboard control panel applet (refer to section 4.1.3, “Keyboard” on page 20). Although repeat rate and initial delay are global, auto-repeat enable/disable is selectable per key via DeviceIoControl calls to the keypad driver.

TREQ-M4 Mobile Data Terminal

49

Page 60

Software Drivers

Application Development

Each key can be individually assigned a virtual key code. Supported virtual key codes include all Windows CE standard supported codes (defined in winuser.h, found in the TREQ-M4 SDK distribution located at \Program Files\Windows CE Tools\wce600\TREQ-M4\Include\Armv4i) as well as custom codes enabling the assignment of mouse clicks and movements and the ability to launch applications and define key sequences. Key codes are assigned via DeviceIoControl calls to the keypad driver. Independent control of a press vs. a release key code is not supported; all actions occur on a press (as opposed to a key release). Refer to section 3.3, “Function Keys” for default key mappings. When assigned the appropriate key code (e.g., VK_RUN_APP or VK_SEQ), a key can launch an application defined by a string that is set via a DeviceIoControl call to the keypad driver. The application is always launched on a key press. When assigned the appropriate key code (e.g., VK_MOUSE_LEFT or VK_MOUSE_LEFTCLICK) a key can control mouse cursor movement or simulate a mouse button click. If repeat is enabled for that key, and a mouse movement code is assigned, holding down that key causes the mouse to move and then accelerate. The longer the key is held, the greater the acceleration. The acceleration factor can be set via DeviceIoControl calls to the keypad driver. The keypad driver implements a shifted and non-shifted state. This should not be confused with the use of the SHIFT key (VK_SHIFT). The shift state applies globally to all keys and can be enabled/disabled via DeviceIoControl calls to the keypad driver. A shifted state allows a second set of key code assignments that can be quickly enabled or disabled via a single driver call. The program KeyShiftCE.exe is a sample application that toggles the keypad shift state (refer to section 4.7.2, “Beijer Electronics” on page 32). Every key and shifted key has its own set of repeat and extended data storage (path or sequence information), so shifting the keys provides a complete new set of keys. When the shift state is changed, any keys being held down will be “released” by the driver before the state change occurs (this prevents a stuck-down key state because held keys are not re-registered as new presses in the new shift state). Key sequences are distinctive. No mouse commands may be embedded in a key sequence, and the repeat flag does not work for a key inside a sequence. Instead, key sequences have a flag indicator to indicate whether or not to release the current key and all previous keys that were down. Not specifying the release flag simply means that the release will occur when the key goes up. To use auto-repeat with a sequence, mark the VK_SEQ identifier (the first key) as auto repeat. Besides the normal VK_keys given by WinCE, a VK_RUN_APP may be embedded in a key sequence. Using the VK_RUN_APP in a sequence always causes a release for previous keys in the sequence, regardless of whether or not the release flag was specified. API, described via code examples: HANDLE hDevice; hDevice = CreateFile(TEXT("KEY1:"), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); WORD key = TREQ_KEY0; // See TreqPublic.h for key defines WORD keyCode = VK_RETURN; // See TreqPublic.h for key code defines // Use keyCode |= TREQ_KEY_REPEAT; to enable repeat for key, // otherwise it is disabled DWORD keyIn = (keyCode << 16) | key;

50

TREQ-M4 Mobile Data Terminal