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.

bgreer5050's Content

There have been 28 items by bgreer5050 (Search limited from 29-March 23)


By content type

See this member's


Sort by                Order  

#63835 Deploy over TCP

Posted by bgreer5050 on 10 August 2015 - 01:36 PM in Netduino Plus 2 (and Netduino Plus 1)

Is it possible to deploy an app over tcp/ip yet ?  How about debug over tcp/ip ?

 

Thanks




#63816 Detect if Ethernet Cable is Connected

Posted by bgreer5050 on 07 August 2015 - 05:59 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris.  

 

Was the 

NetworkInterface.OperationalStatus Property ever implemented in one form or another ?

 

Thanks

Bill




#63717 Time In Netduino 3

Posted by bgreer5050 on 30 July 2015 - 12:42 PM in Netduino 3

I guess.  I'll look for an external RTC as there is no internal RTC.  Can you recommend an external RTC for the Netduino 2 Plus ?




#63680 Time In Netduino 3

Posted by bgreer5050 on 28 July 2015 - 11:08 AM in Netduino 3

Does the Netduino 3 remember it's time when re-boot ?  I currently have several Netduino 2 Plus units in the field and one problem I continually encounter is time stamp issues.  I have events that I record and send up to a server.  I need my events time stamped but have to rely on connecting to a time server after every boot up.  

 

One thing that I have done in the past is mark the event with an attribute of timeUpdated and if it was not updated then the event would not be sent up to the server until time was updated.  The issue here is that I update the time stamp on my event by doing a TimeSpan on my original time at boot up and the current time once updated and add the difference, but this gets ugly if there is another re-boot before the time is updated.

 

I would also like to hear how others may be handling the same issue.




#63490 MFDeploy Requirements

Posted by bgreer5050 on 13 July 2015 - 04:28 PM in Netduino Plus 2 (and Netduino Plus 1)

I typically load my Netduinos using Visual Studio.  I have someone in the field that does not have VIsual Studio and will be using MFDeploy to load with files I send him.  What requirements is there for MFDeploy to work ?  WIll he need both the .NET Microframework SDK and the Netduino SDK ?

 

Thanks

 

P.S. The devices are Netduino Plus 2 with 4.3

 

 




#63256 Introducing Netduino 3 Wi-Fi

Posted by bgreer5050 on 26 June 2015 - 12:47 PM in Netduino 3

Is there sample code in the SDK download showing how to connect provide the network with credentials or do you have to provide the credentials using MFDeploy ? 




#63235 Inconsistent Results When Writing to SD Card

Posted by bgreer5050 on 25 June 2015 - 01:38 AM in Netduino Plus 2 (and Netduino Plus 1)

The solution is to add 

VolumeInfo.GetVolumes()[0].FlushAll();

after flushing the stream writer.  

using (var filestream = new FileStream(@"SD\Logging\log.txt", FileMode.Append,FileAccess.Write))
{
StreamWriter streamWriter = new StreamWriter(filestream);
streamWriter.WriteLine(strLog + " - " + DateTime.Now.Ticks.ToString());

streamWriter.Flush();
}

VolumeInfo.GetVolumes()[0].FlushAll(); // Force write to sd card
}




#63231 Inconsistent Results When Writing to SD Card

Posted by bgreer5050 on 24 June 2015 - 10:49 PM in Netduino Plus 2 (and Netduino Plus 1)

I have a static class called Logger with two methods

  1. VerifyFileExists
  2. LogToSD
public static class Logger
    {
        public static void VerifyFileExists()
        {
            try
            {
                if (!File.Exists(@"SD\Logging\log.txt"))
                {
                    if (!Directory.Exists(@"SD\Logging"))
                    {
                        Directory.CreateDirectory(@"SD\Logging");
                    }
                    FileStream _fs = File.Create(@"SD\Logging\log.txt");
                    _fs.Flush();

                }
            }
            catch(System.IO.IOException ex)
            {
                Debug.Print(ex.Message);
            }
        }


        public static void LogToSD(string strLog)
        {
            try
            {
                //FileStream fs = new FileStream(@"SD\Logging\log.txt",FileMode.Append,FileAccess.ReadWrite)
                using (var filestream = new FileStream(@"SD\Logging\log.txt", FileMode.Append,FileAccess.Write))
                {
                    StreamWriter streamWriter = new StreamWriter(filestream);
                    streamWriter.WriteLine(strLog + " - " + DateTime.Now.Ticks.ToString());

                    streamWriter.Flush();
                }
            }
            catch(System.IO.IOException exc)
            {
                Debug.Print(exc.Message);
            }
        }

    }

I call these methods from Main:

 public static void Main()
        {

            Logger.VerifyFileExists();

            Logger.LogToSD("Line One");
            Logger.LogToSD("Line Two");
            Logger.LogToSD("Line Two");
            Logger.LogToSD("Line Two");
            Logger.LogToSD("Line Two");
            Logger.LogToSD("Line Two");
            Logger.LogToSD("Line Two");
        }

I always get a Logger folder and a log.txt file, but less than half the time do I have text in my log.txt file as the result of the Logger.LogToSD calls.  Is there something wrong with my design pattern ?

 

I am running 4.3.2 on a Netduino Plus 2

 




#62274 Cellular For Netduino 2 Plus

Posted by bgreer5050 on 28 April 2015 - 04:53 PM in Netduino Plus 2 (and Netduino Plus 1)

I am looking for a recommended shield to use with the Netduino Plus 2 along with the type of Sim card that I would need.  I am in the in the USA, Midwest so there are a lot of carriers.  

 

Thanks




#62222 How do I read a network stream ?

Posted by bgreer5050 on 22 April 2015 - 04:46 PM in Netduino Plus 2 (and Netduino Plus 1)

I copied an example of how to use a socket and a stream to send a request to a server below.  It was from Nicky and there is a reference to the link at the end of this post.  How can I read the stream returned from the server in this example ?  What type of conversion can I expect to have to make so the response is human readable ?

public static void InStateToServer(int port)
{
   IPHostEntry host = Dns.GetHostEntry("192.168.2.231");
   IPEndPoint endPoint = new IPEndPoint(host.AddressList[0], 80);

   using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
   {
      socket.Connect(endPoint);

      using (NetworkStream ns = new NetworkStream(socket))
      {
         byte[] bytes = System.Text.Encoding.UTF8.GetBytes("GET /decoder_control.cgi?command=" + port + "&user=admin&pwd=abc HTTP/1.1\r\n");
         ns.Write(bytes, 0, bytes.Length);
      }
   }
}

Code From Nicky

http://forums.netdui...es-a-long-time/




#62148 I need help changing a static ip address programatically

Posted by bgreer5050 on 16 April 2015 - 05:45 PM in Netduino Plus 2 (and Netduino Plus 1)

I have my Netduino Plus 2 go out to a web service to look up some values that I would like it to use in my project.  One of the values that I have the Netduino check is its IP address.  There may be a reason for me to change an IP address of a Netduino that is in the field so I have a method in my project that I would like to change the static IP address when it is called.  The method takes a string.  

 

I am getting a SocketException with a code of 10022 for invalid argument.  This happens when I call this.Socket.Bind.  My class has a property called Socket to hold the Socket value.  Is it because my socket already has an endpoint ?  I adding this.Socket = null and then this.Socket = new (....... thinking we need a new socket to work with.  

 

Please advise how I can change my IP address from one static IP address to another.

 

 

 public void BindIPAddress(string strIPAddress)
        {
            try
            {
 
                Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP(strIPAddress, "255.255.240.0", "10.0.200.250");
                Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticDns(new string[] { "10.0.200.7", "10.0.100.5" });
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(strIPAddress), 80);
             
 
                this.Socket.Bind(ep);
                this.IpAddress = strIPAddress;
            }
            catch(SocketException exc)
            {
                Debug.Print(exc.Message);
                Debug.Print(exc.ErrorCode.ToString());
             
 
            }
            catch(Exception ex)
            {
                Debug.Print(ex.Message);
               
                
 
            }
            //Debug.Print(ep.Address.ToString());
        }



#62141 Netduino MAC Address Changed ??

Posted by bgreer5050 on 16 April 2015 - 02:59 PM in Netduino Plus 2 (and Netduino Plus 1)

I upgraded to 4.3 and changed the MAC address back to what it should be.  So far the problem has not re-occurred.  I am guessing that while manipulating the NIC card I was throwing an exception of some kind that caused the issue.  I'm not sure, but if I can re-create the problem I will post more details.

 

Thanks Chris




#62111 Netduino MAC Address Changed ??

Posted by bgreer5050 on 14 April 2015 - 09:19 PM in Netduino Plus 2 (and Netduino Plus 1)

I currently have 4.2 on the Netduino.  Should I update to 4.3 first ?




#62107 Netduino MAC Address Changed ??

Posted by bgreer5050 on 14 April 2015 - 05:50 PM in Netduino Plus 2 (and Netduino Plus 1)

I have a Netduino Plus 2.  The MAC address is not the same as it was yesterday.  Has anyone seen this before ?  I want my Netduinos to go out to a database and get specific values.  I wanted to use the MAC address as the unique identifier of the Netduino, but now I am scared to.  I know I can change the MAC address back using the MFDeploy utility.  Is there a way to do so programatically ?  

 

Original MAC: 5C:86:4A:01:12:46

New MAC: 00:04:a3:00:00:00

 




#61986 Interrupt Port and Debouncing

Posted by bgreer5050 on 30 March 2015 - 01:45 PM in Netduino Plus 2 (and Netduino Plus 1)

I think the problem that I am having is being caused by debouncing but I am not sure why I am experiencing it since I believe I have code that should mitigate it.

 

I declare an Interrupt (heartBeatInput):

 

 heartBeatInput = new InterruptPort(Pins.GPIO_PIN_D1, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);

 

 

In my OnInterrupt event I check for the value of data2 to see if the pin is high or low.  I have D1 pulled down to ground with a 4.7k resistor.  I trigger the input by touching D1 to 3.3v and here is where I get confused.  First of all, I do expect a little debouncing, but I a, seeing the Interrup event handled so many times that I believe it is causing am Out of Memory exception that I am seeing.  I expect my heartBeatInput_OnInterrupt to not fire again until I call   heartBeatInput.ClearInterrupt().  I call the ClearInterrupt method in my handleHeartBeat method. But it does fire, so I am checking for the value of data2.  

 

Why is heartBeatInput_OnInterrupt firing again before the ClearInterrupt is called ?  How can I better handle this problem ?

 

 

********************************************************* CODE **********************************************************

      static void heartBeatInput_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            //Debug.GC(true);
            //Debug.EnableGCMessages(true);
            try
            {
 
                Debug.Print(data2.ToString());
                
                if (data2 == 1)
                {
                    bool blnHandle = false;
 
                    TimeSpan ts = time - timeOfLastHeartbeat;
 
                    // TODO Make this a variable that is declared above
                    if (ts.Ticks > 1500000) //Must be greater than 1.5 seconds
                    {
                        blnHandle = true;
                    }
                    else
                    {
                        blnHandle = false;
 
                    }
                    //}
                    if (blnHandle == true)
                    {
                        Debug.Print("Handle = True");
                        handleHeartBeat(time.ToUniversalTime());
                    }
                    else
                    {
                        //Debug.Print("DO NOT HANDLE");
                    }
 
                }
            }
            catch(Exception ex)
            {
                Debug.Print(ex.Message);
                Thread.Sleep(4000);
            }
            //Debug.GC(true);
        }

 

 

 

 

 

 

 

 private static void handleHeartBeat(DateTime time)
        {
            totalRuntimeMilliseconds += getMillisecondsSinceLastHeartBeat(time);
            totalNumberOfCycles++;
            numberOfHeartBeatsSinceLastStateChange++;
            TimeSpan ts = time - timeOfLastHeartbeat;
            double totalMillisecondsSinceLastCycle = ts.Ticks / 10000.0;
            Debug.Print(totalMillisecondsSinceLastCycle.ToString());
 
            if (currentSystemState == SystemState.DOWN &&
            numberOfHeartBeatsSinceLastStateChange > numberOfHeartBeatsRequiredToChangeState &&
            totalMillisecondsSinceLastCycle < (cycleMillisecondsLength * 1.5))
            {
 
                setSystemSateToRun(time);
            }
            timeOfLastHeartbeat = time;
 
            heartBeatInput.ClearInterrupt();
            //Debug.GC(true);
            //Debug.Print("Number of cycles: " + totalNumberOfCycles
            //    + "  Total cycle time: " + totalRuntimeMilliseconds);
        }



#61873 Troubleshooting Memory

Posted by bgreer5050 on 15 March 2015 - 03:10 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks Chris.  I will take your advice into account and pre-allocate.




#61834 Inconsistent Server Response

Posted by bgreer5050 on 10 March 2015 - 05:40 PM in Netduino Plus 2 (and Netduino Plus 1)

I create a thread in my main method that calls WebServer2.Start. There is a Socket called socketGetIP that is used in the main method of my program to get a DHCP when the Netduino boots up.  I reuse the socket in the method below to listen for web requests.  The issue I am trying to resolve today is the responsiveness of the "server".  If I put a breakpoint at  EndPoint clientEndPoint = clientSocket.RemoteEndPoint then the page renders everytime.  If the breakpoint is disabled then the page may render 1 out of 5 or 1 out of 10 times.  Why the inconsistent response ?

 

EDIT: I noticed my request is null sometimes.  Why would this be ?  I have a querystring attached to the URI.

 

 

 

  public static class WebServer2
    {
 
        public static bool blnKeepAlive = true;
 
        //-----------------------------------------------------------------------------------------------------
        public static void Start()
        {
 
            while (blnKeepAlive==true)
            {
                try
                {
                    try
                    {
                        Program.socketGetIP.Listen(10);
                    }
                    catch(Exception ex)
                    {
                        Debug.Print(ex.ToString());
                    }
                    ListenForRequest();
                    // Program.socketGetIP.
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                    Program.blnNetworkUp = false;
                    Thread.Sleep(30000);
                    blnKeepAlive = false;
                }
            }
        }
 
        //-----------------------------------------------------------------------------------------------------
        private static void ListenForRequest()
        {
 
            while (blnKeepAlive == true)
            {
                try
                {
                    Program.blnWebServerUp = true;
                    Debug.Print("Web Server Up");
                    using (Socket clientSocket = Program.socketGetIP.Accept())
                    {
                        //Get clients IP
                        IPEndPoint clientIP = clientSocket.RemoteEndPoint as IPEndPoint;
 
                        EndPoint clientEndPoint = clientSocket.RemoteEndPoint;
                        // TODO Use socket available ?
                        //int byteCount = cSocket.Available;
 
                        int bytesReceived = clientSocket.Available;
 
                        if (bytesReceived > 0)
                        {
 
                            //Get request
 
                            byte[] buffer = new byte[bytesReceived];
 
                            int byteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None);
 
                            string request = new string(Encoding.UTF8.GetChars(buffer));
 
                            Debug.Print(request);
 
                            //Compose a response
                            string OperationMessage = ProcessWebRequest(request);
                            string response = InfoPage(OperationMessage); // Program.currentSystemState.ToString(); // "Hello World";
 
                            string header = "HTTP/1.0 200 OK\r\nContent-Type: text; charset=utf-8\r\nContent-Length: " + response.Length.ToString() + "\r\nConnection: close\r\n\r\n";
 
                            clientSocket.Send(Encoding.UTF8.GetBytes(header), header.Length, SocketFlags.None);
 
                            clientSocket.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None);
 
                            //Blink the onboard LED
                            Program.blnWebServerUp = true;
                            Program.blnNetworkUp = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                    Program.blnWebServerUp = false;
                    Program.blnNetworkUp = false; // TODO Do we need this here
                    Debug.GC(true);
                    Thread.Sleep(120000);
                    blnKeepAlive = false;
                    
                }
            }
 
        }
 
        //-----------------------------------------------------------------------------------------------------



#61832 Troubleshooting Memory

Posted by bgreer5050 on 10 March 2015 - 03:55 PM in Netduino Plus 2 (and Netduino Plus 1)

For the Netduino Plus 2, at what value should I start worrying that my code is inefficient ?




#61821 Troubleshooting Memory

Posted by bgreer5050 on 09 March 2015 - 06:16 PM in Netduino Plus 2 (and Netduino Plus 1)

How do I view how much memory I have available when debugging the Netduino Plus 2 ?  I added Debug.EnableGCMessages(true) thinking this would show me the memory situation in the output window.  Do I need to use Debug.GC(true) as well ?  If so, what is the recommended practice as far as where to place the Debug.GC.  Do I place it before a potential problem routine starts or should it be the first line of the routine ?




#61620 Terminal Screws for Headers

Posted by bgreer5050 on 15 February 2015 - 03:14 PM in Netduino Plus 2 (and Netduino Plus 1)

I'm looking to wire my inputs using terminal screws.  I see all kinds of terminal screws that will fit into the Arduinos.  Can someone share a part number they have used successfully with a Netduino Plus 2 ?  

 

Thanks




#61590 Rebooting Netduino 2 Plus

Posted by bgreer5050 on 10 February 2015 - 07:42 PM in Netduino Plus 2 (and Netduino Plus 1)

Is it possible to reboot the Netduino 2 Plus via code ?

 

Thanks




#61560 How do the input pins work ?

Posted by bgreer5050 on 07 February 2015 - 10:25 PM in Netduino Plus 2 (and Netduino Plus 1)

Anyone ?




#61538 How do the input pins work ?

Posted by bgreer5050 on 06 February 2015 - 04:43 PM in Netduino Plus 2 (and Netduino Plus 1)

Can I use input pins in both fashions:

 

  • Send 3.3 volts to the pin and the controller will detect the pin as interrupted.
  • Ground the pin and the controller will detect the pin as interrupted.

If this is the case, does the controller automatically detect this ?

What is best practice ?

 

 




#61485 How to not short circuit my Netduino ?

Posted by bgreer5050 on 03 February 2015 - 07:23 PM in Netduino Plus 2 (and Netduino Plus 1)

I am a beginner.  I have a relay that is opens and closes a set of contacts.  Can I send 5 volts from the 5 volt pin on the Netduino and send it thorough the relay to the #1 pin which I will declare as an Input ?  Do I need to set pin 1 to ResistorMode.PullUp and/or do I need to add a resistor to the circuit ?

 

I am afraid of shorting the Netduino, but I am not going from the positive straight to the ground so I have to believe it's safe.

 

Thanks

 

P.S. Will order a book today so I don't clutter the forum with such basic questions.   :)




#61343 Where is MFDeploy ?

Posted by bgreer5050 on 23 January 2015 - 11:35 AM in Netduino Plus 2 (and Netduino Plus 1)

Sorry.  It's early.

 

http://www.microsoft...on.aspx?id=5475





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.