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.

cSharper

Member Since 21 Jul 2015
Offline Last Active Oct 23 2015 01:16 PM
-----

Topics I've Started

Why do I have to reboot my device to change the IP address?

31 July 2015 - 06:44 PM

So I was able to a write code that gets my IP address from a file and changes it on initialization.

// Get and Update properties from those in the file on the SD
sd.GetAddressesFromFile();
var interf = NetworkInterface.GetAllNetworkInterfaces()[0];
interf.EnableStaticIP(sd.IP, sd.SubnetMask, sd.DefaultGateway);
//Debug print our IP address
Debug.Print(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);

And that works great. However when I send a request from my browser to update the IP address, the only way I can get it to actually change is doing a PowerState.RebootDevice();

 

I was just wondering what dependencies are in the RebootDevice method that cause the IP address to reset. I tried playing around with the ReleaseDhcpLease() and RenewDhcpLease() but they didn't really do anything for me. Here is my code that changes the IP address after I get it from the browser:

        private void UpdateAddressesRequest() {
            // If no values were actually updated, we don't need to run this method.
            if (sd.ChangeFlag == false)
                return;

            var interf = NetworkInterface.GetAllNetworkInterfaces()[0];            
            interf.EnableStaticIP(sd.IP, sd.SubnetMask, sd.DefaultGateway);
            interf.EnableStaticDns(new string[] { "172.16.1.1", "172.16.1.2" });

            sd.ChangeFlag = false;
            PowerState.RebootDevice(soft: false);
        }

SD Memory issue when writing

23 July 2015 - 04:19 PM

Hey all,

 

So I have an issue that has been causing my head to spin when writing to an SD card. I have searched all the threads and couldn't find anything like my issue.

I can read perfectly fine from the SD card, but when writing, it will only write over text that is currently in the file.

            string FilePath = @"\SD\yourfile.txt";

            using (var fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512))
            using (var sw = new StreamWriter(fs)) {
                sw.WriteLine("Will This String Write?");
                Thread.Sleep(1000);
                sw.WriteLine("done.");
                Thread.Sleep(1000);
                sw.Flush();
            }
            Debug.Print("We did something");

So for example if my text file contains the string "My String" then when I run the above program, the only thing in the text file will be "Will This" instead of the entire string. And if there is nothing in the file at all, then nothing is written. I have the lastest firmware and SDK's. In fact I recently just reinstalled everything. I am also using a 2GB sd card as recommended.

 

Thanks for your help!


System.NotSupportedException

21 July 2015 - 08:31 PM

Hello all,

I'm new to netduino,

 

Everytime I try and run any program, I get the following error:

 

An unhandled exception of type 'System.NotSupportedException' occurred in SecretLabs.NETMF.Hardware.Netduino.dll

 

I've recopied these dll's into my project folder, and even tried to make a new project and still get the same error.

I fortunately am able to continue through the error, but I'm curious as to what is causing it and how to fix it.

 

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.