Main Site Documentation

Mac address on ENC28 Module not provided


#1

Hi,

ist there no MAC-address provided to the ENC28-Module when purchased from GHI?
I’ve got some cerberus-boards with enc28-mods attached. If connected to my network with dhcp enabled they all get the same Ip-address. Do i have to get an address for every module?


#2

Yes, you have to assign your own MAC address. Here’s some code I’m currently using.


private static readonly byte[] _macAddress = new byte[] { 0x00, 0x75, 0x65, 0xde, 0xac, 0xaa };
       

        private void InitializeNetwork_Dhcp()
        {
            try
            {
                var nis = NetworkInterface.GetAllNetworkInterfaces();

                if (nis == null || nis.Length == 0)
                {
                    throw new IndexOutOfRangeException("No network interface was found.  Make sure you have the ethernet firmware installed and a NIC attached.");
                }
                _ni = nis[0];
                _ni.PhysicalAddress = _macAddress;
                _ni.EnableDhcp();                

                // There's a bug in the current SDK.  If connection becomes available after startup then IPAddress does not seem to get populated.
                while (_ipAddress == "0.0.0.0")
                {
                    _ipAddress = _ni.IPAddress == "0.0.0.0" ? IPAddress.GetDefaultLocalAddress().ToString() : _ni.IPAddress;
 #if DEBUG
                    Debug.Print("Waiting for IP address..." + IPAddress.GetDefaultLocalAddress());
 #endif
                    Thread.Sleep(1000);
                }
 #if DEBUG
                Debug.Print("IP Address:" + _ipAddress);
 #endif
                UpdateDisplay("IP: " + _ipAddress);
            }
            catch (Exception exception)
            {
                throw new ArgumentException("Could not resolve host via DNS.", exception);
            }
        }


#3

This is what I use if I need a MAC address:

http://www.miniwebtool.com/mac-address-generator/


#4

Thx Mike, that’s what I was looking for :slight_smile:


#5

@ fp - Welcome to the community!


#6

Thank you guys! I will try to change the mac-address with MFDeploy first.

The default mac-address of my cerberus boards is 00-04-a3-00-00-00. Is the first part the address-room of GHI, or could it happen, that I choose an address which is already taken by another device in the network?


#7

ENC28’s don’t have allocated MAC addresses. Use the link Mike provided above, grab some addresses for your use and go crazy. I don’t think Cerb family chips have inbuilt Ethernet, meaning you’ll need to use code to set your MAC on each device (not MFDeploy).


#8

Sure, it works with MFDeploy. Each one of my devices now gets a different ip-address.
I’ve used the link from mike to generate the addresses. But i want to avoid that there is another device in my network from another manufacturer, which has got the same mac-address.