In part-4 of this getting started series, we will talk about the application development environment for Compact 2013 and work through the steps to develop a simple C# application from Visual Studio 2013 IDE and deploy the application to the target device, EduCake for testing and debug.

Compact 2013 Application Development

There are multiple options to develop Compact 2013 application.  From the VS2013 IDE, you can develop application for Compact 2013 device using C, C++, C# or Visual Basic.

With a properly configured OS runtime image, it’s possible to develop Compact 2013 application without the need to install Platform Builder for Compact 2013 and develop your own OS image.

To develop application for a Compact 2013 device, you need the following:

To test and debug the application, you need the following:

  • A Compact 2013 target device preloaded with OS runtime image configure to support application deployment from Visual Studio 2013.



Compact 2013 OS Image for Application Development

Continue with the MyOSDesign project created in part-2 of this series, let’s work through the steps to include additional components to the project, needed to support application development:

  • Launch MyOSDesign project.

  • From the Catalog Items View window, add additional components to the OS design project, as shown in Fig-01.

Fig-01:  Catalog Items View window

  • AutoLaunch

When included in an OS image, the AutoLaunch application is configurable to launch one or more application during startup.

  • CoreCon

When included in an OS design project, the CoreCon component add the necessary files to establish CoreCon connectivity between VS2013 IDE and target device to download application to the device for debugging and testing.

  • IP Address Broadcast

As part of the application development process, to deploy application to the target device, you need to know the device’s IP address.  This component is designed to help you acquire IP address from the target device.

When selected, this component add an application to the OS design, configure to launch during startup to broadcast the device’s IP address via UDP. 

A Windows desktop application, IPAddressDiscovery, to listen for the UDP broadcast message from the target device is provided as part of the BSP, in the BSP’s \Misc folder.



By default, OS design project is created with KITL enabled.  KITL is known to cause connectivity problem for application development. Work through the following steps to disable KITL:

  • From VS2013 IDE, select PROJECT | MyOSDesign Properties to bring up the MyOSDesign Property Pages screen, as shown in Fig-02.

   

 Fig-02:  Disable KITL build option

  • From MyOSDesign Property Pages screen, click on Build Options on the left pane.

  • On the right, change the Enable Kernel Independent Transport Layer (KITL) build option to No.

  • Click on Apply and then click on OK to close the screen.

Create an SDK from MyOSDesign

To support application development, we need to generate an SDK from the OS design project.  Go through the following steps to create an SDK from the project:

  • From the Solution Explorer window on VS2013 IDE, right mouse click on the SDKs folder and select Add New SDK, as shown in Fig03.

Fig-03:  Add New SDK

  • The SDK wizard brings up a screen to create the new SDK.

  • Enter SDK name, product name, version info, company name and website, as shown in Fig-04.

Fig-04:  Create new SDK – SDK info

  • On the left pane, click on Install and enter file name for the SDK, as shown in Fig-05.

Fig-05:  Create new SDK – SDK info

  • Click Apply and then OK

Build and Generate OS Runtime Image

To build the OS design project, select BUILD | Build Solution from the VS2013 IDE.

If the build process ends with error, review the build.log and build.err files in the following directory to identify the causes:

C:\WINCE800\

After the OS design build process is completed, an OS runtime image, NK.bin, is generated in the following directory:

C:\WINCE800\OSDesigns\MyOSDesign\MyOSDesign\RelDir\86Duino_80B_Release

Build and Generate SDK

From the Solution Explorer window, right mouse click on Compact2013_SDK_86Duino_80B and select Build to build the SDK, as shown in Fig-06.

Fig-06:  Build the SDK

After the build process is completed, the SDK file, Compact2013_SDK_86Duino_80B.msi, is generated in the following directory:

C:\WINCE800\OSDesigns\MyOSDesign\MyOSDesign\SDKs\SDK1\MSI

Install the Compact2013_SDK_86Duino_80B.msi SDK to support application development exercise in the next section.

Download OS Runtime Image to Target Device

Before getting into application development, we need to download OS runtime image to the target device, needed to test and debug the application.

With the development PC and target device attached to the same LAN, go through the following steps to download OS image to the target device:

  • Launch the IPAddressDiscovery.exe application on the development PC, from the following folder:

C:\WINCE800\Platform\86Duino_80B\Misc

  • With MyOSDesign project open, select TARGET | Attach Device from VS2013 IDE to initiate the download process.

  • Power on the EduCake.

  • As the OS image launches and the IPBroadcastCompact2013.exe excutes on the EduCake, the IPAddressDiscovery command prompt screen display IP address for the target device, as shown in Fig-07.

Fig-07:  IPAddressDiscovery showing target device IP address

Note:  The IPBroadcastCompact2013.exe application terminates itself after broadcasted 5 messages, with 2 second delay in between.

 

Develop Compact 2013 Application in C#

In this section, we will go through the steps to develop the IPBroadcastCompact2013 application in C# and deploy the application to run on the target device for testing and debugging.

Work through the following steps to create the application:

  • Launch a new instance of VS2013 and click on New Project.

  • From th left pane on the New Project screen, click on the following node:

\Other Languages\Visual C#\Windows Embedded Compact\Compact2013_SDK_86Duino_80B

  • On the center pane, click to select Console Application and enter a name for the application, IPAddressBroadcast, and  as shown in Fig-08.

Fig-08:  New C# application project for Compact 2013

  • Click on OK to continue.

  • Replace the codes in the Program.cs file with the following:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Net;

using System.Threading;

 

namespace IPAddressBroadcast

{

    class Program

    {

        static void Main(string args)

        {

            for (int i = 0; i < 5; i++)

            {

 

                System.Net.Sockets.UdpClient sock =

                                                new System.Net.Sockets.UdpClient();

 

                IPEndPoint iep =

                         new IPEndPoint(IPAddress.Parse("255.255.255.255"), 15000);

 

                byte data = Encoding.ASCII.GetBytes("86Duino");

                sock.Send(data, data.Length, iep);

                sock.Close();

 

                Thread.Sleep(2000);

 

            }

        }

    }

}

  • From VS2013 IDE, select BUILD | Build Solution to build the project.

  • From the Solution Explorer window, right mouse click on the IPAddressBroadcast project and select properties to bring up the property page, as shown in Fig-09.

Fig-09:  Application project property page.

  • Enter the target device’s IP address.

If the IPAddressDiscovery application is not running on the development machine, launch it now before the next step.

  • From VS2013 IDE, select DEBUG | Start Debugging to deploy the application to the target device.

As the IPAddressBroadcast application is deployed and run on the target device, the IPAddressDiscovery command prompt window detect and display IP address from the target device.

As you can see from the codes above, the program loops 5 times to send UDP broadcast message with 2 seconds delay in between, and terminate after the 5th iteration.

Application Debug

Continue from the previous step, let’s place a break point on the following line of code:

sock.Send(data, data.Length, iep);

Now, select DEBUG | Start Debugging from VS2013 IDE to deploy the application to the target device.

As the application execute on the target device, it halt on the above line of code, as shown in Fig-10.

Fig-10:  Application halt at breakpoint

At this point, you can press F11 to step through the code one line at a time and use debugging tools from VS2013 to view program variable value and operating status.

Next, press F5 for the application to continue.  As the application continue to execute, it halt again after looping back to the same line of code, with the breakpoint.

Remove the breakpoint and press F5 again for the program to continue to run until completion and terminate.

Summary

Compact 2013 provides an efficient development environment that enables you to develop managed code application and the facility for you to remotely debug the application, from Visual Studio IDE, as the codes execute on the target device.

If you have existing managed code application development skills, you can leverage the existing skills you have to develop application for Compact 2013 devices.