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

Multiple Netduinos within one local Network


  • Please log in to reply
18 replies to this topic

#1 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 23 November 2012 - 07:45 AM

Hello all together, i´ve received a second Netduino from a friend of mine. So i thought about setting up a small sensor network in my flat. Sensing different things for the beginning just the climate within and outside of the flat. Whatever this works fine! Both Netduinos are running (basically) the same programs. But... when i connect them both to the local Network just one of them works. My start up progress: - switching on Netduino #1 (IP: 192.168.1.100) - within the start up #1 sets it´s IP and starts working - checking connection from my Laptop (IP 192.168.1.20) ping to #1 -> works fine - switching on Netduino #2 (IP: 192.168.1.200) - same start up sequence like #1 - checking connection Laptop -> #2 -> works fine - want to call #1 doesn´t work anymore - pinging returns timeout tried solutions: - different network ports - different network IP´s - different style of connecting (switching on, then connecting networkcable, etc.) - basically the network connection if the Netduino which is connected first stops working when the second one is connected Any ideas or am I just missing something? Regards and thanks for help Runner

#2 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 23 November 2012 - 08:11 AM

How do you set the Netduinos IP? Via code, DHCP or fixed IP set on the router? Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#3 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 23 November 2012 - 08:24 AM

each netduino gets a fixed IP IPs are set with this function: System.Net.IPAddress IPNetduino = System.Net.IPAddress.Parse(NetduinoIP); #1: 192.168.001.122 #2: 192.168.001.222 Laptop: 192.168.001.020 the netduinos send the data to port 49000 of my Laptop. Is the port connection fixed and just for one device?

#4 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 23 November 2012 - 09:28 AM

ok one device per port....found it.. :P thanks

#5 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 23 November 2012 - 09:58 AM

OK, it's always nice to see things work out :) Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#6 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 23 November 2012 - 11:16 AM

Hey Markus, I´m sorry but the solution i mentioned above isn´t working.. But it sounded like a good reason for the failure... Have to leave to the university but a small update to the Network config: Netduino #1 IP: 192.168.1.21 Port: 49001 Netduino #2 IP: 192.168.1.22 Port: 49002 Laptop: IP: 192.168.1.20 Port: 49001 and 49002 The Laptop is running a Lab View program which opens 2 UDP protocol ports (both same IP but different ports) same result as before... everything is connected to a switch hard- and software works fine with just one Netduino connected.

#7 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 23 November 2012 - 01:25 PM

Are you working with sockets? Probably you could post some code? How do you receive the data at the netduinos? Do you keep the sockets open or do you close them sometimes? I'm also not sure if UDP is supported by netduinos, only worked with TCP/IP. Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#8 Lunddahl

Lunddahl

    Advanced Member

  • Members
  • PipPipPip
  • 152 posts
  • LocationEurope, Denmark

Posted 24 November 2012 - 12:46 PM

This could be because the two netduinos end up having the same MAC address, how is the MAC address set on a netduino, do they come with different MAC addresses from the factory, and if so, where is it stored? I would like to know the above for the NP2 as well? - Ulrik

#9 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 November 2012 - 01:04 PM

Are you working with sockets?
Probably you could post some code? How do you receive the data at the netduinos? Do you keep the sockets open or do you close them sometimes?
I'm also not sure if UDP is supported by netduinos, only worked with TCP/IP.

Greets, Markus


Netduino Plus do support the UDP: I used it without problems, both client and listener.
Cheers
Biggest fault of Netduino? It runs by electricity.

#10 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 24 November 2012 - 04:05 PM

This could be because the two netduinos end up having the same MAC address, how is the MAC address set on a netduino, do they come with different MAC addresses from the factory, and if so, where is it stored?

I would like to know the above for the NP2 as well?

- Ulrik


I have a NP2 and cannot set the MAC address, so maybe the OP does indeed have two with same address on LAN. My unit does have an address printed on the back, and MFDeploy does in fact show that address (even without my having explicitly setting it), however my DHCP server clearly shows the request from 00:04:a3:00:00:00 which a Microchip address, presumably a factory default for the ENC28J60.

For now I'm motoring on with my project, but this will have to be fixed at some point...

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 November 2012 - 06:42 PM

Hi Ulrik,

This could be because the two netduinos end up having the same MAC address, how is the MAC address set on a netduino, do they come with different MAC addresses from the factory, and if so, where is it stored?

I would like to know the above for the NP2 as well?

Each board comes with a unique MAC address from the factory. We then attach a removable sticker with this address to the back of the board.

Both Netduino Plus 1 and Netduino Plus 2 store the MAC address and IP settings in the NETMF Config flash sector on the MCU.

You can change this value in code or using MFDeploy's Network Configuration options.

Chris

#12 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 November 2012 - 06:45 PM

Hi ziggurat29,

I have a NP2 and cannot set the MAC address, so maybe the OP does indeed have two with same address on LAN. My unit does have an address printed on the back, and MFDeploy does in fact show that address (even without my having explicitly setting it), however my DHCP server clearly shows the request from 00:04:a3:00:00:00 which a Microchip address, presumably a factory default for the ENC28J60.

For now I'm motoring on with my project, but this will have to be fixed at some point...

This is a glitch in the ENC28J60 driver implementation. We were made aware of this shortly after launch and are working on a firmware update which will address the issue. The ENC28J60 chip should be getting its MAC address from the configuration flash sector.

In the meantime, have you tried setting your MAC address in code?
http://msdn.microsof...y/cc532879.aspx

This won't be necessary for the vast majority of users, and the firmware update should fix the issue for the rest...but in the meantime this should hopefully provide a workaround.

Chris

#13 Lunddahl

Lunddahl

    Advanced Member

  • Members
  • PipPipPip
  • 152 posts
  • LocationEurope, Denmark

Posted 24 November 2012 - 11:19 PM

This is a glitch in the ENC28J60 driver implementation. We were made aware of this shortly after launch and are working on a firmware update which will address the issue. The ENC28J60 chip should be getting its MAC address from the configuration flash sector.


Is it possible to read the configuration flash sector from managed code ?

In the meantime, have you tried setting your MAC address in code?
http://msdn.microsof...y/cc532879.aspx

This won't be necessary for the vast majority of users, and the firmware update should fix the issue for the rest...but in the meantime this should hopefully provide a workaround.


No, but if you have two Netduinos on the same physical ethernet segment, none of them will work if they have the same MAC address, and you will have to use the function Chris has linked to, to set the MAC address to different values on each Netduino.

If you don't understand what a physical ethernet segment is, just think of it as a you network.

There is no problem having a lot of netduinos with the same MAC address talk to each other over then internet, as long as they are not on the same physical network.

- Ulrik

#14 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 25 November 2012 - 05:08 PM

...
This is a glitch in the ENC28J60 driver implementation....
...
In the meantime, have you tried setting your MAC address in code?
http://msdn.microsof...y/cc532879.aspx
...



Interesting. OK, I did try several things. Basically it's doesn't work in general, but it was still interesting. I'll show you my test code for what it's worth:

public static void Main()
        {
            NetworkInterface[] ani = NetworkInterface.GetAllNetworkInterfaces();
            foreach ( NetworkInterface ni in ani )
            {
                string strIPorig = ni.IPAddress;
                byte[] abyMACorig = ni.PhysicalAddress;
                ni.ReleaseDhcpLease();
                string strIPrel = ni.IPAddress;
                byte[] abyMACset = new byte[] { 0x5c, 0x86, 0x4a, 0x01, 0x23, 0x45 };    //<== I changed last three for this post
                ni.PhysicalAddress = abyMACset;
                ni.RenewDhcpLease();
                byte[] abyMACnew = ni.PhysicalAddress;
                string strIPnew = ni.IPAddress;
            }

        }

OK, some things:
* network intialization and dhcp has happened before Main, so it's mostly too late to change MAC via application code
* after PhysicalAddress setter, pinging fails to netduino as one might expect
* as you can see I attempted to work around by doing explicit DHCP release/renew around the change. These calls stimulate no actual DHCP activity, alas.
* the PhysicalAddress set action does persist across reboot, however. E.g., upon exist of this program, if I re-run it in the debugger, I have the new MAC address. and DHCP serves up the expected IP I reserved for this experiment.
* upon powercycling, though, this is lost, so it's not that interesting
* I guess if there was a was for the app to detect that it is a cold boot, set the address, do a warm boot, and then detect it is a warm boot and continue running, then that would be a possible work-around.

I would fix the firmware myself, but it is not clear to me how to build it, and I couldn't find anything interesting in the source I downloaded so I probably don't have the full package. I was somewhat expecting the Microchip code for the ENC28J60 somewhere, but couldn't find that either. Obviously I an assuming you are using that code at all, but I think the address is set in StackTsk.h in their code.

Anyway, I can carry on with other aspects of the project for now; I won't require two boards on the same network yet, but eventually I will.

-dave

#15 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 28 November 2012 - 05:55 AM

Hey!

Sorry was ill the last days.
Here some code:
System.Net.Sockets.Socket LVSocket = null;
System.Net.IPEndPoint LVEndpoint = null;
System.Net.Sockets.Socket uCSocket = null;
System.Net.IPEndPoint uCEndpoint = null;

// Path of the init File at the Sd Card
System.String Path = @"\SD\Config_INIT.txt";
// DEFAULT values if SD Card is not found or not inserted

// SETTINGS for Netduino #1
System.String LabViewIP = "192.168.1.20";                 
System.Int32 NetworkPort = 49001;                 
System.String NetduinoIP = "192.168.001.21";

// SETTINGS for Netduino #2
// System.String LabViewIP = "192.168.1.20";                 
// System.Int32 NetworkPort = 49002;                 
// System.String NetduinoIP = "192.168.001.22";

The program checks for an config file at the SD Card (works fine)
If no SD Card detected it will continue with:


System.Net.IPAddress IPLabview = System.Net.IPAddress.Parse(LabViewIP);
System.Net.IPAddress IPNetduino = System.Net.IPAddress.Parse(NetduinoIP);

Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP(NetduinoIP, "255.255.255.0", "192.168.0.0");

if (uCEndpoint == null)

{
  uCSocket = UDPConnector.RecieveSocket(uCSocket);
  uCEndpoint = UDPConnector.RecievePoint(uCSocket, uCEndpoint, IPNetduino, NetworkPort);
}

if (LVSocket == null)
{
  LVSocket = UDPConnector.SendSocket(LVSocket);
  LVEndpoint = UDPConnector.SendPoint(LVSocket, LVEndpoint, IPLabview, NetworkPort);
}

byte[] Recieved = UDPConnector.getMessage(uCSocket);


BTW I´m using CAT5 cables

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 November 2012 - 09:15 AM

Ulrik, dave, Runner: Thank you for the additional notes, repros, and code samples. This is our current #1 work item; we'll have an update for this soon. Chris

#17 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 04 December 2012 - 01:20 AM

for posterity of this thread, the 4.2.1.2 firmware does fix the 'mac address not setup from flash config' issue, so you should be good to use two NP2 on same LAN segment now. if you upgrade your flash, don't forget to re-set the MAC with mfdeploy.exe, since the flash upgrade will erase it. -dave

#18 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 04 December 2012 - 11:43 AM

MAC, IP and networkport of all devices are different! I have checked this several times... Trying to switch my code to TCP protocol. This will cost data transfer rate (UDP is faster cause there is no handshake), but i hope it will fix the communication problem

#19 Runner

Runner

    Member

  • Members
  • PipPip
  • 21 posts

Posted 05 December 2012 - 08:06 AM

Hello all! please just forget about this post. :) I have checked the IP´s am MAC address with MFdeploy. In the startup of my main function I was setting the new IP address for the Netduinos. unfortunately I have not recognized a function call to one of the classes I have written at the beginning. In the "lost" class I have had a function which was setting the MAC address. Really thanks for your help and from now on I will improve my code documentation! :) btw: UDP is working fine. Connection to both of the Netduinos is working! You guys are really great! Thanks




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.