Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

magarcan

Member Since 05 Sep 2011
Offline Last Active Jan 19 2012 08:05 AM
-----

Topics I've Started

Binary files

17 January 2012 - 09:07 AM

Hi all! I used to be AVR developer, an I need some thing I used to use. What I want to do is, obtaining a binary file from my code, and be able to write it in Netduino without need to rebuild my code. Do you know any way to do this?

See current method.

10 January 2012 - 05:16 PM

Do you know any way to see current method name?

I know this two options, but they are for Framework:

1)
MethodBase method = (new StackTrace(true)).GetFrame(0).GetMethod();
string methodname = method.DeclaringType.FullName + "." + method.Name;

2)
MethodBase method = MethodInfo.GetCurrentMethod();
string methodname = method.DeclaringType.FullName + "." + method.Name;
Any idea about how to do it in Micro Framework?

Serial port in emulator

19 October 2011 - 02:41 PM

I'm building an app, that uses serial port. Are there any way to get access to serial ports using the emulator? What I want to do is read from a serial port using the emulator. I've tested this in Netduino+ and it works ok, but I also want to test in emulator. Thanks!!

Loading assemblies dynamically

10 October 2011 - 11:13 AM

I'm having some space issues so I want to try this. Could be possible load some of my assemblies dynamically in order to leave some ROM free??

I'm working over this code:
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using Microsoft.SPOT;
//using SecretLabs.NETMF.IO;

namespace MonoNetduinoBootloader
{
    public class Program
    {
        public static void Main()
        {
            FileStream assemblyStream;
            Assembly assembly;
            object netduinoAppClassInstance;
            MethodInfo startupMethod;

            // for Netduino and Netduino Mini: mount the SD card
            try
            {
                // uncomment for netduino
                //StorageDevice.MountSD("SD", Microsoft.SPOT.Hardware.SPI.SPI_module.SPI1, (Microsoft.SPOT.Hardware.Cpu.Pin)54);

                // uncomment for netduino mini
                //StorageDevice.MountSD("SD", Microsoft.SPOT.Hardware.SPI.SPI_module.SPI1, (Microsoft.SPOT.Hardware.Cpu.Pin)12);

                // netduino plus will auto-mount SD card
            }
            catch
            {
                Debug.Print("SD card could not be mounted.  Please verify that SD card is inserted.");
                return;
            }

            // make sure the assembly exists
            try
            {
                // open the netduino app assembly, built using Mono.
                assemblyStream = new FileStream(@"\SD\MonoNetduinoApp.pe", FileMode.Open, FileAccess.Read, FileShare.None);
            }
            catch
            {
                Debug.Print("Netduino app not found.  Please copy MonoNetduinoApp.pe to root folder of SD card.");
                return;
            }

            // attempt to load the assembly into RAM
            try
            {
                // read the assembly into RAM
                byte[] assemblyData = new byte[assemblyStream.Length];
                assemblyStream.Read(assemblyData, 0, assemblyData.Length);

                // load the assembly
                assembly = Assembly.Load(assemblyData);
            }
            catch
            {
                Debug.Print("Netduino app corrupted.  Please check MetaDataProcessor settings.");
                return;
            }
            finally
            {
                assemblyStream.Dispose();
            }


            // using reflection: get the type of the MonoNetduinoApp's startup class; get the statup class's type; using the startup class's, get a reference to the type's Main method.
            try
            {
                netduinoAppClassInstance = AppDomain.CurrentDomain.CreateInstanceAndUnwrap("MonoNetduinoApp, Version=1.0.0.0", "MonoNetduinoApp.Program");
                Type netduinoAppClassType = assembly.GetType("MonoNetduinoApp.Program");
                startupMethod = netduinoAppClassType.GetMethod("Main");
            }
            catch
            {
                Debug.Print("Netduino app invalid.  Please verify that class name is MonoNetduinoApp and startup method is Main.");
                return;
            }

            // run the MonoNetduinoApp's startup routine (MonoNetduinoApp.Program's Main method)...starting our app.
            startupMethod.Invoke(netduinoAppClassInstance, new string[] { });
        }
    }
}
As you can see, this is the code of Mono Bootloader. My idea is load some assemblies like:
  • using Microsoft.SPOT.Native
  • using Microsoft.SPOT.Hardware
  • System.IO
And some others...

The problem comes with this:
netduinoAppClassInstance = AppDomain.CurrentDomain.CreateInstanceAndUnwrap("MonoNetduinoApp, Version=1.0.0.0", "MonoNetduinoApp.Program");
Type netduinoAppClassType = assembly.GetType("MonoNetduinoApp.Program");
startupMethod = netduinoAppClassType.GetMethod("Main");

Can I add more than one assembly?? If I want to load an entire class, what have I to write in netduinoAppClassType.GetMethod??

Thanks!!!

How big is my program

03 October 2011 - 10:40 AM

Hi! I'm having some issues and I think they are related with deployment size. How can I see how big is my program and who is using my free bytes?

I'm using lots of references, are there any way to see how big is each one??

After compiling I can see something like this:
Deploying assemblies for a total size of 1080 bytes

Assembly: mscorlib (4.1.2821.0) (3880 RAM - 33236 ROM - 19134 METADATA)
Assembly: Microsoft.SPOT.Native (4.1.2821.0) (1144 RAM - 6516 ROM - 4479 METADATA)
Assembly: Microsoft.SPOT.Hardware (4.1.2821.0) (1752 RAM - 11440 ROM - 7371 METADATA)
Assembly: Microsoft.SPOT.Net (4.1.2821.0) (704 RAM - 5060 ROM - 2452 METADATA)
Assembly: System (4.1.2821.0) (872 RAM - 5992 ROM - 3206 METADATA)
Assembly: Microsoft.SPOT.IO (4.1.2821.0) (740 RAM - 4620 ROM - 2522 METADATA)
Assembly: System.IO (4.1.2821.0) (1548 RAM - 13292 ROM - 5862 METADATA)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.1.2821.0) (512 RAM - 3488 ROM - 1543 METADATA)
Assembly: Microsoft.SPOT.Hardware.Usb (4.1.2821.0) (580 RAM - 3740 ROM - 1844 METADATA)
Assembly: SecretLabs.NETMF.Hardware (4.1.0.0) (256 RAM - 1108 ROM - 491 METADATA)
Assembly: SecretLabs.NETMF.Diagnostics (4.1.0.0) (180 RAM - 440 ROM - 166 METADATA)
Assembly: NetduinoPlusApplication1 (1.0.0.0) (164 RAM - 264 ROM - 90 METADATA)
Assembly: SecretLabs.NETMF.Hardware.NetduinoPlus (4.1.0.0) (268 RAM - 816 ROM - 423 METADATA)

Total: (10920 RAM - 90012 ROM - 49583 METADATA)
What does RAM and METADATA mean?? What is the ROM amount available in my Netduino Plus?? I seen in specifications it is 64 KB and 128KB without networking. What does it mean?

Thanks!!!

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.