How to use the new functionalities
#1
Posted 24 September 2010 - 07:07 PM
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
Posted 24 September 2010 - 07:13 PM
#3
Posted 24 September 2010 - 07:48 PM
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
Posted 24 September 2010 - 08:15 PM
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
Posted 24 September 2010 - 08:20 PM
#6
Posted 24 September 2010 - 08:24 PM
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface networkInterface in networkInterfaces) { networkInterface.EnableDhcp(); }
When I said hardcoded.. I really meant 'defaulted to'..
#7
Posted 24 September 2010 - 08:25 PM
#8
Posted 24 September 2010 - 08:27 PM
#9
Posted 24 September 2010 - 08:27 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
#10
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
Posted 24 September 2010 - 08:36 PM
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
Posted 24 September 2010 - 08:38 PM
#13
Posted 24 September 2010 - 08:43 PM
new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
And in the client:
SendTo instead of Send
In the server:
Bind instead of Listenand
ReceiveFrom instead of Receive
#14
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
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
Posted 24 September 2010 - 08:59 PM
#17
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
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
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.
Today LED's, tomorrow, the world!!! Well, OK, maybe servos.
#20
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