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.
Photo

MIP tcp/ip stack running on Netduino mini !!


  • Please log in to reply
66 replies to this topic

#41 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 01 March 2014 - 05:34 PM

I guess that D8 does not equal (Cpu.Pin)8 in reference to a standard netduino 1?
 
Would this be 62 at a guess?
 
And D10 would be 64?
 
Many thanks
 
Andy

You should be using the constants/enums corresponding to the pins on your Netduino instead of the numerical values from the original code.

#42 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 01 March 2014 - 05:48 PM

I have the boards connected as follows:

 

(left netduino / right ENC28)

 

Gnd = gnd

3.3v = vcc

Reset = reset

D13 = SCK

D12 = MISO

D11 = MOSI

D10 = CS

D8 = INT (D8 also has a 10K resistor going to ground)

 

The board is from ebay... http://www.ebay.co.u...=item35c89fc698

 

I have added in SecretLabs.NETMF.Hardward.Netduino, so my profile is as follows:

 

case InterfaceProfile.Netduino1:
                    // MOSI(D12), SCK(D13), MISO(D11), INT(D8), CS(D10) 
                    Start(MacAddress, name, SPI.SPI_module.SPI1, SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D8, SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D10);
                    break;

My interrupt method is as follows:

irq = new InterruptPort(irqPin, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLevelLow);

I now get the error:

 

Error: a3000000
 
Waiting for debug commands...
 
The program '[19] Micro Framework application: Managed' has exited with code 0 (0x0).
 


#43 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 01 March 2014 - 05:59 PM

I think that error was an issue with the address odata.netflix.com not returning a dns entry.

 

I managed to get an IP from my DHCP server:

 

Link is now up :)
Setting IP Address to 192.168.1.51
DHCP SUCCESS!  We have an IP Address - 192.168.1.51; Gateway: 192.168.1.254
Updating Gateway Mac from ARP
 

 

but get this error:

 

An unhandled exception of type 'System.Exception' occurred in NetworkingService.dll
 
Additional information: Domain Name lookup for odata.netflix.com failed. 
 
 
Dropping 0 packet(s)
Packet Count is3: 0
1*** ERXRDPT: 0
1*** ERXWRPT: 1062
2*** ERXRDPT: 0
2*** ERXWRPT: 1062
Packet Count is4: 0
Packet Count is5: 0
3*** ERXRDPT: 0
3*** ERXWRPT: 1062
4*** ERXRDPT: 0
4*** ERXWRPT: 1062
4*** Setting Next Packet Pointer to: 0
A first chance exception of type 'System.Exception' occurred in NetworkingService.dll
An unhandled exception of type 'System.Exception' occurred in NetworkingService.dll
Additional information: Domain Name lookup for odata.netflix.com failed. 
 


#44 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 01 March 2014 - 08:13 PM

It seems you have no name server configured or one that does not know of netflix.

What happens when you try www.google.com?

#45 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 01 March 2014 - 08:24 PM

Hmm, same issue with google?

 

Erm does that mean my dns server isn't working correctly? I don't seem to have an issue on my laptop? Is there anything I can do to check/resolve this on a network level or could it be an issue with the driver?

 

One interesting thing I noticed was that when I edit the debug info to print out my dns server, it printed out the value of both the primary and secondary in one strange output:

 

Link is now up :)
Setting IP Address to 192.168.1.51
DHCP SUCCESS!  We have an IP Address - 192.168.1.51; DNS Server: 192.168.1.1.192.168.1.254; Gateway: 192.168.1.254
Updating Gateway Mac from ARP
 
This value came from:
 
Adapter.DomainNameServer.ToAddress()


#46 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 01 March 2014 - 08:50 PM

Yes, the two ns entries look clashed but it would surprise me if that's not just the print out looking funny.

Bring up a DOS box on your PC and type "nslookup www.google.com", what do you get?

You should get an ip number, try that on your Netduino.

Also try accessing your gateway 192.168.1.254 from your Netduino.

#47 Tim Long

Tim Long

    New Member

  • Members
  • Pip
  • 9 posts

Posted 01 March 2014 - 08:55 PM

Wow, a TCP/IP stack in C#! What find. It will be useful just as an educational thing.

 

So when using mIP, do we still need the stuff built into the firmware? Is there a way to reclaim that 'wasted' program memory back?

 

--Tim



#48 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 01 March 2014 - 09:05 PM

If you got a Netduino with networking, you should probably stick to that since it's faster and has a smaller memory footprint but yes, you can flash non-network firmware and rely on mip alone for tcp/ip.

Mip is 100% managed code which is great in many ways but at the same time makes it less effective in terms of system resources than the stack compiled into the firmware of the networked Netduino models.

#49 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 01 March 2014 - 09:56 PM

Server:  UnKnown
Address:  192.168.1.1
 
Name:    www.google.com
Addresses:  2a00:1450:400c:c03::67
 173.194.67.147
 173.194.67.103
 173.194.67.99
 173.194.67.104
 173.194.67.105
 173.194.67.106
 
Tried the first IP and it worked :)
 
Although this is great in terms of my netduino project, it means my network config has gone a little wrong. :(


#50 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 02 March 2014 - 08:40 AM

It seems name servers does not get configured correctly via DHCP with MIP even though there is one in your network.

Perhaps ns info somehow gets garbled after all - maybe you could debug the method that printed the ns info earlier and see if it is actually stored like that, e.g. if in fact MIP thinks that "192.168.1.1.192.168.1.254" is the configured ns - if so, there could be some problems with string handlng during DHCP processing.

#51 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 March 2014 - 09:23 PM

Hi Hanz,

 

When I dig in to the payload that is used to populate the options hash table.

 

I see that for options._buckets[6].value there is an 8 byte array containing the values for both IP addresses.

 

This mean that in this line where bucket 6 is assigned to the ns, there is an invalid ip address being assigned.

 

I updated the packet handler, so I could see what was going on and it seems to now work correctly, so I think this is a bug?

 

        /// <summary>
        /// Take care of a packet of DHCP stuff
        /// </summary>
        /// <param name="payload"></param>
        public static void HandlePacket(byte[] payload)
        {
            //Debug.WriteLine("Handling DHCP packet");
            
            // Check Transaction ID!
            if (transactionID == null || payload[46] != transactionID[0] || payload[47] != transactionID[1] || payload[48] != transactionID[2] || payload[49] != transactionID[3]) return;
            
            // To determine the type, we need to find the magic cookie, then find option 0x35h
            // 02 == Offer, 05 == ACK, 06 = NAK
            var options = ParseOptions(payload);


            //Debug.WriteLine("DHCP PKT");


            if (options.Contains("53"))
            {
                //Debug.WriteLine("Rec'd DHCP OFFER - 1");


                if (((byte[])(options["53"]))[0] == 0x02)  // Offer
                {
                    //Debug.WriteLine("Rec'd DHCP OFFER");


                    ushort ipHeaderLength = (ushort)((payload[14] & 0x0f) * 4);
                    PendingIpAddress = Utility.ExtractRangeFromArray(payload, ipHeaderLength + 38, 4);
                    if (options.Contains("54")) Adapter.Gateway = (byte[])options["54"];  // DHCP Server
                    if (options.Contains("6")) Adapter.DomainNameServer = Utility.ExtractRangeFromArray((byte[])options["6"], 0, 4); //DNS Server
                    if (options.Contains("6")) Adapter.DomainNameServer2 = Utility.ExtractRangeFromArray((byte[])options["6"], 4, 4); //Secondary DNS Server
                    if (options.Contains("1")) Adapter.SubnetMask = (byte[])options["1"];  // Subnet
                    if (options.Contains("3")) Adapter.Gateway = (byte[])options["3"];  // Router
                    if (options.Contains("58")) RenewTimer.Change((int)(((byte[])options["58"]).ToInt() * 1050), TwoHoursInMilliseconds); // Got a Renew time
                    if (options.Contains("51")) RenewTimer.Change((int)(((byte[])options["51"]).ToInt() * 750), TwoHoursInMilliseconds); // Got a Lease Time (I am using 750, so we renew after 75% of lease has been consumed)
                    Adapter.GatewayMac = Utility.ExtractRangeFromArray(payload, 6, 6);  // Initial gateway MAC.  Will get confirmed/updated by an ARP Probe


                    SendMessage(DHCP.Request);
                }
                else if (((byte[])options["53"])[0] == 0x05)  // ACK or Acknowledgement
                {
                    // Parse out the Gateway, DNS Servers, IP address, and apply set all the variables with it...


                    //Debug.WriteLine("Rec'd DHCP ACK");


                    if (options.Contains("54")) Adapter.Gateway = (byte[])options["54"];  // DHCP Server
                    if (options.Contains("6")) Adapter.DomainNameServer = Utility.ExtractRangeFromArray((byte[])options["6"], 0, 4); //DNS Server
                    if (options.Contains("6")) Adapter.DomainNameServer2 = Utility.ExtractRangeFromArray((byte[])options["6"], 4, 4); //Secondary DNS Server
                    if (options.Contains("1")) Adapter.SubnetMask = (byte[])options["1"];  // Subnet
                    if (options.Contains("3")) Adapter.Gateway = (byte[])options["3"];  // Router
                    if (options.Contains("58")) RenewTimer.Change((int)(((byte[])options["58"]).ToInt() * 1050), TwoHoursInMilliseconds);  // Got a Renew time
                    if (options.Contains("51")) RenewTimer.Change((int)(((byte[])options["51"]).ToInt() * 750), TwoHoursInMilliseconds);  // Got a Lease Time (I am using 750, so we renew after 75% of lease has been consumed)
                    Adapter.GatewayMac = Utility.ExtractRangeFromArray(payload, 6, 6);  // Initial gateway MAC.  Will get confirmed/updated by an ARP Probe


                    transactionID = null;
                    Adapter.AreRenewing = false;
                    Adapter.IPAddress = PendingIpAddress ?? Adapter.IPAddress;


                    Adapter.startupHold.Set();  // This will release the Adapter.Start() Method!  (if waiting)


                    Debug.WriteLine("DHCP SUCCESS!  We have an IP Address - " + Adapter.IPAddress.ToAddress() + "; DNS Server: " + Adapter.DomainNameServer.ToAddress() + "; Gateway: " + Adapter.Gateway.ToAddress());


                    ARP.SendARP_Probe(Adapter.Gateway);  // Confirm Gateway MAC address
                }
                else if (((byte[])options["53"])[0] == 0x06)  // NACK or Not Acknowledged!
                {
                    Debug.WriteLine("DHCP N-ACK");
                    transactionID = null;
                    Adapter.AreRenewing = false;


                    // We have failed to get an IP address for some reason...!
                    Adapter.IPAddress = null;
                    Adapter.Gateway = null; 
                    Adapter.GatewayMac = null;
                }
            }
        }


#52 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 02 March 2014 - 09:59 PM

Good job!

 

I guess it's sort of a bug but mostly because mIP hasn't been tested with all that many routers yet  :)

 

If you haven't already, could you please report your findings on the mIP CodePlex site  or perhaps send a personal message about it Valkyrie-MT briefly describing the problem, what you did to fix it and the name/model of your router?

 

So I take it, you got TCP/IP up and running now then - that's great!



#53 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 March 2014 - 10:13 PM

Yep already on it on codeplex :)

 

My router is Thomson TG582n

 

I am running my own DHCP and DNS servers in server 2012.

 

TCP/IP is up and running, now just to see if it is possible to get the multi SPI to share with my MCP23S17s... Do you think it is possible?

 

Thanks for all help :)

 

Andy



#54 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 02 March 2014 - 10:30 PM

Great!

As for multi SPI, I could make an interface for the internal multi SPI mgr implementation of my MCP23S17 driver and expose that from outside the class.

You would then have to make some modificatins to your local mIP code to have it use the interface supplied by me rather than accessing the SPI module directly.

The latter would probably only be a little more than search and replace but still, you would break away from the main track of mIP. This is what I meant before when talking about the lack of a standard multi SPI mgr that can be shared between code originating between different contributors.

EDIT: Just discovered, mIP also includes a multi SPi mgr (borrowed from Stefan Thoolen's Toolbox)...

#55 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 March 2014 - 10:35 PM

Ahh that makes sense now, that would be great I would definitely be interested in that :) 



#56 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 04 March 2014 - 05:53 PM

I've managed to get all the examples working except the UDP one, do you know what is meant to happen with this one? Does it receive UDP messages and if so how do I test it?

 

My next step is to incorporate MQTT, not sure if anyone has managed this with mIp yet?

 

Many thanks

 

Andy



#57 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 12 March 2014 - 12:01 AM

Sorry post to wrong thread.



#58 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 12 March 2014 - 11:23 AM

I'm sorry but I really think you should refrain from posting the entire listing in this thread, not just because it's really long but because it has very little to do with mIP.

Please modify your last post, remove the code and instead attach it as a file to the MCP23S17 thread. In that new post, please also point out any specific problems that you want me to look into.

#59 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 13 March 2014 - 07:23 PM

Sorry post to wrong thread.

When re-reading my last post I realized that I may have sounded grumpy and if so, I'm sorry because I didn't mean to.

You're doing a great job Andy and I'm glad you have taken interest in this. Please do make a new post in the MCP23S17 thread and I'll do my best to help you.

#60 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 08 April 2014 - 10:51 PM

Hi Hanz,

 

Good news, with no amendments to mIp bar the fix in the dhcp.cs and just tweaking your MCP23S17 library to run on the MultiSPI manager, I have been able to get both devices working together.

 

I am still playing with the web server on the netduino in terms of creating input fields and handling the requests as this is my first attempt. If I get something up and running I will post a video.

 

I may see if I can get the neonmika web server running on a standard netduino, any way thanks again for the help.

 

Andy






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.