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.

g.d.carter's Content

There have been 6 items by g.d.carter (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#3954 Understanding the build output sizes

Posted by g.d.carter on 17 October 2010 - 06:06 PM in Netduino Plus 2 (and Netduino Plus 1)

I assume this is the line I am looking for:

Deploying assemblies for a total size of 3304 bytes

This is in the Output window under the output from Micro Framework Device Deployment.



#3947 Understanding the build output sizes

Posted by g.d.carter on 17 October 2010 - 02:38 PM in Netduino Plus 2 (and Netduino Plus 1)

So what values should I be looking at in this output to determine where I'm at.

The very first number that it outputs:
Total: (11024 RAM - 91748 ROM - 50406 METADATA)

This would lead me to believe that I am over the 48KB of ROM data? But I assume this includes some of the assemblies. Is there a FAQ or a wiki that will help me understand this output?



#3940 Understanding the build output sizes

Posted by g.d.carter on 17 October 2010 - 04:02 AM in Netduino Plus 2 (and Netduino Plus 1)

When I compile my project I get the message:

Total: (11024 RAM - 91748 ROM - 50406 METADATA)


   AssemblyRef    =      100 bytes (      25 elements)

   TypeRef        =      904 bytes (     226 elements)

   FieldRef       =       64 bytes (      16 elements)

   MethodRef      =     1224 bytes (     306 elements)

   TypeDef        =     2688 bytes (     336 elements)

   FieldDef       =     1060 bytes (     524 elements)

   MethodDef      =     3352 bytes (    1671 elements)



   DebuggingInfo  =     1688 bytes



   Attributes      =       48 bytes (       6 elements)

   TypeSpec        =       28 bytes (       7 elements)

   Resources Files =       72 bytes (       3 elements)

   Resources       =      304 bytes (      38 elements)

   Resources Data  =     1184 bytes

   Strings         =     8232 bytes

   Signatures      =     6654 bytes

   ByteCode        =    30015 bytes


Does this include the firmware, or is that separate? Does someone know exactly how much RAM/ROM we have to work with and what values I should look at in here to see if I am getting close?



#3939 Simple Netduino Webserver

Posted by g.d.carter on 17 October 2010 - 03:57 AM in Netduino Plus 2 (and Netduino Plus 1)

Here is the code I ended up implementing for this.

The main function that was supplied by Hari that I modified.
        private static string ProcessRequest(string receivedStr)
        {
            //-- Parse the first line of the request: "GET /led/1 HTTP/1.1\r" --
            string firstLine = receivedStr.Substring(0, receivedStr.IndexOf('\n'));
            string sReturn = "Command executed at " + DateTime.Now.ToString();
            string[] words = firstLine.Split(' ');
            string[] parts = words[1].Split('/');
            string cmd = parts.Length > 1 ? parts[1] : "";
            string param1 = parts.Length > 2 ? parts[2] : "";
            string param2 = parts.Length > 3 ? parts[3] : "";
            bool bValue;

            bValue = param2 == "1" ? true : false;

            //-- Add more commands and param handling here --
            switch (cmd)
            {
                case "led13":
                    sReturn = ProcessOutputPort(led13, param1 ,ref bValue);
                    break;
                case "led12":
                    sReturn = ProcessOutputPort(led12, param1,ref bValue);
                    break;
                case "in0":
                    sReturn = ProcessInputPort(in0, param1,ref bValue);
                    break;
                case "in1":
                    sReturn = ProcessInputPort(in1, param1,ref bValue);
                    break;
                default:
                    sReturn = "Unknown Command at " + DateTime.Now.ToString();
                    break;
            }

            //-- Optional string to return to caller --
            return sReturn;
        }


The code to process InputPorts

        private static string ProcessInputPort(InputPort inport, string sAction,ref Boolean bValue )
        {
            string sreturn;
            switch (sAction)
            {
                case "state":
                    bValue = inport.Read();
                    sreturn = "Port is " + (bValue ? "On" : "Off");
                    break;
                default:
                    sreturn = "Unknown Parameter at " + DateTime.Now.ToString();
                    break;
            }
            return sreturn;
        }

And the code for the output ports
        private static string ProcessOutputPort(OutputPort outport, string sAction,ref Boolean bValue)
        {
            string sreturn;
            switch (sAction)
            {
                case "state":
                    bValue = outport.Read();
                    sreturn = "Port is " + (bValue ? "On" : "Off");
                    break;
                case "set":
                    outport.Write(bValue);
                    sreturn = "Port set to " + (bValue ? "On" : "Off");
                    break;
                default:
                    sreturn = "Unknown Parameter at " + DateTime.Now.ToString();
                    break;
            }
            return sreturn;
        }

Now I just need to make the changes to do something instead of just write back to the browser that I determined something.



#3938 Simple Netduino Webserver

Posted by g.d.carter on 17 October 2010 - 03:11 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Yacko,

Welcome to the Netduino community.

One quick thought...you could create a collection of your InputPorts/OutputPorts along with a set of string identifiers...and then evaluate your input against that collection.

Chris

I had thought about that but I was having problems mixing inputport and outputport types in one collection and being able to use them in the same collection.



#3935 Simple Netduino Webserver

Posted by g.d.carter on 17 October 2010 - 01:02 AM in Netduino Plus 2 (and Netduino Plus 1)

First I do love this code, although I would like to switch it to an interrupt based web server, but I'll get to that later. For learning how to use a simple web server this was a great example. I am trying to make a change to grab or change the value of an IO port based on the 3 values. I could write this with a ton of code and many objects but I'm sure there is a better way to do this I hope someone can point out.

Here are my static ports.

        static OutputPort led13 = new OutputPort(Pins.GPIO_PIN_D13, false);
        static OutputPort led12 = new OutputPort(Pins.GPIO_PIN_D12, false);
        static InputPort in0 = new InputPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled);
        static InputPort in1 = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled);

Here is a rough copy of the ProcessRequest function that I have been working on.

        private static string ProcessRequest(string receivedStr)
        {
            //-- Parse the first line of the request: "GET /led/1 HTTP/1.1\r" --
            string firstLine = receivedStr.Substring(0, receivedStr.IndexOf('\n'));
            string sReturn = "Command executed at " + DateTime.Now.ToString();
            string[] words = firstLine.Split(' ');
            string[] parts = words[1].Split('/');
            string cmd = parts.Length > 1 ? parts[1] : "";
            string param1 = parts.Length > 2 ? parts[2] : "";
            string param2 = parts.Length > 3 ? parts[3] : "";
            object selport;

            //-- Add more commands and param handling here --
            switch (cmd)
            {
                case "led13":
                    selport = (OutputPort) led13;
                case "led12":
                    selport = (OutputPort)led12;
                case "in0":
                    selport = (InputPort) in0;
                case "in1":
                    selport = (InputPort)in1;
                default:
                    sReturn = "Unknown Command at " + DateTime.Now.ToString();
                    break;
            }
            

            if (selport != null)
            {
                switch (param1)
                {
                    case "state":
                        if (selport.Read())
                            sReturn = "Led is On at " + DateTime.Now.ToString();
                        else
                            sReturn = "Led is Off at " + DateTime.Now.ToString();
                        break;
                    case "set":
                        if (typeof(selport) == typeof(InputPort))
                        {
                            selport.Write(param2 == "1");
                        }
                        break;
                    default:
                        sReturn = "Unknown Parameter at " + DateTime.Now.ToString();
                        break;
                }

            }


            //-- Optional string to return to caller --
            return sReturn;
        }

Is there an easier way to do this with mixed Input and Output ports?




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.