Compile an App

Now you’ve got a directory with the following files in it:

  • Makefile

  • MetaDataProcessor.exe

  • Microsoft.SPOT.Hardware.dll

  • Microsoft.SPOT.Native.dll

  • Microsoft.SPOT.TinyCore.dll

  • SecretLabs.NETMF.Hardware.Netduino.dll

  • SecretLabs.NETMF.Hardware.dll

  • mscorlib.dll

All you need to add is a program (named Program.cs) and a subdirectory (Properties) with a file called AssemblyInfo.cs in it.

Try it out with the program from Chapter 3. Here’s what needs to go inside your Program.cs:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace MonoNetduinoApp
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            while (true)
            {
                led.Write(true); // turn on the LED
                Thread.Sleep(250); // sleep for 250ms
                led.Write(false); // turn off the LED
                Thread.Sleep(250); // sleep for 250ms
            }
        }

    }
}

And here’s what you need inside of PropertiesAssemblyInfo.cs (you will need to create the Properties subdirectory):

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Blinky")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Blinky")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

With all that in place, type the command make at the terminal. You should see output similar to the following:

/usr/local/bin/mcs -nostdlib -target:library -out:MonoNetduinoApp.dll 
Program.cs Properties/AssemblyInfo.cs -r:SecretLabs.NETMF.Hardware.Netduino.dll
-r:Microsoft.SPOT.TinyCore.dll -r:Microsoft.SPOT.Hardware.dll 
-r:Microsoft.SPOT.Native.dll -r:mscorlib.dll 

wine MetaDataProcessor.exe -loadHints mscorlib mscorlib.dll -parse
MonoNetduinoApp.dll -minimize -endian le -compile MonoNetduinoApp.pe

When you’re done, you can copy the file MonoNetduinoApp.pe to the root of your memory card, put it in the Netduino, and power it up. It should start running the Netduino app you compiled on Mac OS X or Linux. If you have any troubles with this, check out the Mono forum (http://forums.netduino.com/index.php?/forum/12-mono/) at http://forums.netduino.com/ and post a question if you can’t find your answer there.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.166.31