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

How to use the new functionalities


  • Please log in to reply
37 replies to this topic

#1 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 07:07 PM

Hi,

I've got my Netduino Plus in today.
And i'm wondering how to use the new functionality... I guess I must include some new assemblies? if so where can I find them?

Can I use this? Beta assmblies for SD card

And this one? Beta assmblies for ethernet

Thanks

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 07:13 PM

SD card: System.IO.dll Network: System.dll (for sockets) Microsoft.SPOT.Net.dll (if you want to change your IP settings from code) To change your static IP (or to test out the "unsupported" DHCP): Run MFDeploy. Target menu > Configuration > Network We haven't even made the announcement yet, and community members are already building stuff :) Fantastic! Chris Edit: There's also the System.Http assembly...which gives you the ability to download and parse web pages with ease. It _might_ be too big if you're running a sophisticated program--but it might not be. Feel free to play with it, and maybe we can free up some additional flash for code as well...

#3 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 07:48 PM

Aha.. cool.

For those interresed, here's how to list your network properties:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Microsoft.SPOT.Net.NetworkInformation;

namespace NetduinoApplication2
{
    public class Program
    {

        public static void Main()
        {
            // write your code here
            NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();

            foreach (NetworkInterface networkInterface in networkInterfaces)
            {
                Debug.Print("IP Address: " + networkInterface.IPAddress);
                Debug.Print("Subnet mask " + networkInterface.SubnetMask);
            }


        }

    }
}

Seems like my netduino plus is hardcoded to IP static IP address 192.168.5.150/24

#4 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:15 PM

Here's how to send data:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Microsoft.SPOT.Net.NetworkInformation;
using Microsoft.SPOT.Net;
using System.Net.Sockets;
using System.Net;
using System.Text;

namespace NetduinoApplication2
{
    public class Program
    {

        public static void Main()
        {

            using (System.Net.Sockets.Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {

                IPHostEntry entry = Dns.GetHostEntry("192.168.5.111");
                IPAddress address = entry.AddressList[0];
                IPEndPoint endpoint = new IPEndPoint(address, 80);

                socket.Connect(endpoint);
                socket.Send(Encoding.UTF8.GetBytes("Hallo Netduino plus"));
            }

        }

    }
}


#5 Steven Behnke

Steven Behnke

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationLas Vegas, NV

Posted 24 September 2010 - 08:20 PM

It is very cool. I can't wait to get home and plug mine in. Though I don't have a route to a 192.168.x.x network from my home 172.16.15.x subnet, so I'm not sure if I can get it to change the ip or not. Hopefully I can.

#6 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:24 PM

Sure you can.. I guess this would be the easiest:

            NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();  
  
            foreach (NetworkInterface networkInterface in networkInterfaces)  
            {  
                networkInterface.EnableDhcp();
            }

When I said hardcoded.. I really meant 'defaulted to'..

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 08:25 PM

Steven, Sorry, forgot that part! I just updated my original post in the thread... To change your static IP (or to test out the "unsupported" DHCP): Run MFDeploy. Target menu > Configuration > Network Chris

#8 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:27 PM

Oh.. won't EnableDhcp() work ?

#9 Steven Behnke

Steven Behnke

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationLas Vegas, NV

Posted 24 September 2010 - 08:27 PM

Ah, very cool. Thanks for that! I've got a 1 gig microSD card all ready to go as well. Hopefully it will work with SPI.

Steven,

Sorry, forgot that part! I just updated my original post in the thread...

To change your static IP (or to test out the "unsupported" DHCP):
Run MFDeploy. Target menu > Configuration > Network

Chris



#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 08:29 PM

Oh.. won't EnableDhcp() work ?


DHCP is built in...but we're asking users to use static IP for their first projects to make sure we get any kinks worked out with the networking before we start introducing any other variables to the equation :)

Chris

#11 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:36 PM

To make it complete.. here is how to receive data

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Microsoft.SPOT.Net.NetworkInformation;
using Microsoft.SPOT.Net;
using System.Net.Sockets;
using System.Net;
using System.Text;

namespace NetduinoApplication2
{
    public class Program
    {

        public static void Main()
        {

            using (System.Net.Sockets.Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {

                socket.Bind(new IPEndPoint(IPAddress.Any, 80));
                socket.Listen(1);

                using (Socket commSocket = socket.Accept())
                {
                    if (commSocket.Poll(-1,SelectMode.SelectRead))
                    {
                        byte[] bytes = new byte[commSocket.Available];
                        int count = commSocket.Receive(bytes);

                        Debug.Print(new String(Encoding.UTF8.GetChars(bytes)));
                    }
                }                
            }
        }
    }
}

Have fun !!!

#12 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:38 PM

Btw.. I haven't tested the code above yet.. I'll have to get a switch to connect the netduino.. i'm on wireless only atm

#13 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:43 PM

And for UDP, use:

new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))

And in the client:

SendTo instead of Send

In the server:

Bind instead of Listen
and
ReceiveFrom instead of Receive


#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 08:44 PM

Btw.. I haven't tested the code above yet.. I'll have to get a switch to connect the netduino.. i'm on wireless only atm


Are you running on a Windows PC with an Ethernet jack? You could set up network connection sharing and plug the Netduino into your PC...

Chris

#15 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 08:49 PM

Are you running on a Windows PC with an Ethernet jack? You could set up network connection sharing and plug the Netduino into your PC...


Good idea... won't I be needing a cross cable for that?

#16 Steven Behnke

Steven Behnke

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationLas Vegas, NV

Posted 24 September 2010 - 08:59 PM

Is there a way to put a .Net assembly on the SD card, load it and then run it from the Micro .Net Framework? Maybe some sort of primitive task switcher could be made.

#17 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 09:03 PM

Good idea... won't I be needing a cross cable for that?


In theory, yes. But some PCs have auto-detect and will swap the RX/TX if you use teh "wrong" cable.

#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 September 2010 - 09:05 PM

Is there a way to put a .Net assembly on the SD card, load it and then run it from the Micro .Net Framework? Maybe some sort of primitive task switcher could be made.


Why yes, yes there is. You can use AppDomains and load assemblies on the fly :)

You do have dozens of KB of memory (not MBs)--so keep that in mind.

Chris

#19 Eric Burdo

Eric Burdo

    Advanced Member

  • Members
  • PipPipPip
  • 130 posts

Posted 24 September 2010 - 09:05 PM

In theory, yes. But some PCs have auto-detect and will swap the RX/TX if you use teh "wrong" cable.



Yeah... my router will do that too... rather handy.
~ Eric D. Burdo ~ http://brick-labs.com/

Today LED's, tomorrow, the world!!! Well, OK, maybe servos.

#20 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 24 September 2010 - 09:17 PM

In theory, yes. But some PCs have auto-detect and will swap the RX/TX if you use teh "wrong" cable.


Ha.. connected a cable to my notebook and all the lights come on.. I guess it's working.
Will be testing more tomorrow.. bedtime now.




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.