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

Member Since 28 Sep 2010
Offline Last Active Nov 10 2013 06:45 PM
-----

Posts I've Made

In Topic: Understanding the build output sizes

17 October 2010 - 06:06 PM

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.

In Topic: Understanding the build output sizes

17 October 2010 - 02:38 PM

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?

In Topic: Simple Netduino Webserver

17 October 2010 - 03:57 AM

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.

In Topic: Simple Netduino Webserver

17 October 2010 - 03:11 AM

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.

In Topic: Simple Netduino Webserver

17 October 2010 - 01:02 AM

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.