G80 failing to update MAC address

Hi,

I am trying to change the MAC address on a Reaper but it is crashing when selecting either the ‘load’ or ‘apply’ options in the network configuration of FEZconfig. The board becomes unresponsive and it also seems to cause a problem with the FEZconfig application as I cannot successfully reload the firmware without rebooting the PC.

Firmware is 4.3.8.1 and yes I am using an external power source.

Am I doing something wrong in FEZconfig? I need to resolve this quite urgently.

Cheers

After a message which states that the network config update was successful I get the two messages in the attached images.

Then, after resetting the board, the response to a ping is;

[quote]Pinging…
Failure - Device is not connected or not responding. [/quote]

And then the board vanishes from the list of attached devices (no others are connected).

:think:

Edit; so I don’t have to reboot the PC to reload the firmware, but I do have to kill the FEZconfig process that is still running after the application has been closed.

Edit2; I have tried to set the MAC address in the application using,


However, even though debugging in VS reports that this has taken effect, Wireshark reports the device's MAC address is unchanged.

Edit3; So the change of address done in the application has taken effect after restarting the device and I'm happy that I have a solution. I'd still like to be doing this in FEZconfig though really as I will have half a dozen, or more, devices running the same application on the same network and now they will need to have a software version specific to each unit.

@ wolfbuddy - We were able to reproduce the issue with FEZ Config, but we do not have a fix at this time. Can you provide a complete example that shows setting PhysicalAddress failing?

@ John, so it shouldn’t require a reset to take effect?

This is my class constructor;

public EthernetHandler(string monitorIP, string subnetMask, string gatewayAddress, 
            string sendingPort, string receivingPort, byte[] MAC)
        {
            // initialise ethernet adapter
            ethernet = new EthernetENC28J60(FEZReaper.Socket9.SpiModule, FEZReaper.Socket9.Pin6, FEZReaper.Socket9.Pin3);
            
            // set static IP address
            ethernet.EnableStaticIP(monitorIP, subnetMask, gatewayAddress);

            // set new MAC address
            ethernet.PhysicalAddress = MAC;
            
            // set up sending socket
            deviceIPAddress = IPAddress.Parse(monitorIP);
            portNum = int.Parse(sendingPort);
            sendingEndPoint = new IPEndPoint(IPAddress.Any, portNum);
            sendingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            sendingSocket.Bind(sendingEndPoint);
            
            // set up receiving socket
            portNum = int.Parse(receivingPort);
            receivingEndPoint = new IPEndPoint(IPAddress.Any, portNum);
            receivingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            receivingSocket.Bind(receivingEndPoint);

            // open the ethernet interface
            ethernet.Open();
        }

Do you need more?

Sorry, I just realised I should of posted the whole class;

using GHI.Networking;
using GHI.Pins;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;

namespace EthernetApp
{
    public class EthernetHandler
    {
        
        //---------------------------------------------------------
        #region Declare variables
        
        private static EthernetENC28J60     ethernet;

        private static Socket               sendingSocket,
                                            receivingSocket;

        private static IPAddress            deviceIPAddress,
                                            clientIPAddress;

        public static IPEndPoint            senderIPEndPoint;

        private static EndPoint             sendingEndPoint,
                                            receivingEndPoint,
                                            clientEndPoint;

        public static EndPoint              senderEndPoint;

        private static int                  portNum,
                                            receivedCount;

        private static byte[] receivedBytes = new byte[20];

        #endregion
        //---------------------------------------------------------

        public EthernetHandler(string monitorIP, string subnetMask, string gatewayAddress, 
            string sendingPort, string receivingPort, byte[] MAC)
        {
            // initialise ethernet adapter
            ethernet = new EthernetENC28J60(FEZReaper.Socket9.SpiModule, FEZReaper.Socket9.Pin6, FEZReaper.Socket9.Pin3);
            
            // set static IP address
            ethernet.EnableStaticIP(monitorIP, subnetMask, gatewayAddress);

            // set new MAC address
            ethernet.PhysicalAddress = MAC;
            
            // set up sending socket
            deviceIPAddress = IPAddress.Parse(monitorIP);
            portNum = int.Parse(sendingPort);
            sendingEndPoint = new IPEndPoint(IPAddress.Any, portNum);
            sendingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            sendingSocket.Bind(sendingEndPoint);
            
            // set up receiving socket
            portNum = int.Parse(receivingPort);
            receivingEndPoint = new IPEndPoint(IPAddress.Any, portNum);
            receivingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            receivingSocket.Bind(receivingEndPoint);

            // open the ethernet interface
            OpenEthernet();
        }

        public int SendBytes(byte[] bytes, string port, ArrayList connectedClientIPs) 
        {
            try
            {
                foreach ( string IP in connectedClientIPs ) // won't send anything if there are no clients connected
                {
                    // create an end point for each client
                    clientIPAddress = IPAddress.Parse(IP);
                    portNum = int.Parse(port);
                    clientEndPoint = new IPEndPoint(clientIPAddress, portNum);
                    // send to each client
                    sendingSocket.SendTo(bytes, clientEndPoint);
                    // ------------------------------------------------------------------------
                    //DebugMessageHandler.DebugMessage("Sent datagrams to: " + IP, 0, true, false);
                    // ------------------------------------------------------------------------
                }
                return connectedClientIPs.Count;
            }
            catch (Exception)
            {
                // ------------------------------------------------------------------------
                DebugMessageHandler.DebugMessage("Failed to send datagrams", 0, true, false);
                // ------------------------------------------------------------------------
                return 0; 
            }
        } 

        public byte[] ReceiveData()
        {
            // Creates an IPEndPoint to capture the identity of the sending host.
            senderIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
            senderEndPoint = (EndPoint)senderIPEndPoint;

            // This call blocks
            receivedCount = receivingSocket.ReceiveFrom(receivedBytes, ref senderEndPoint);

            return receivedBytes;
        }

        public void OpenEthernet() { ethernet.Open(); }

        public bool IsEthernetCableConnected
        {
            get { return ethernet.CableConnected; }
        }

        public bool IsEthernetReady
        {
            get 
            {
                if (ethernet.Opened && ethernet.NetworkAvailable)
                    return true;
                else return false;
            }
        }

    }
}

@ wolfbuddy - Using the below test program, the proper MAC address was seen in our network traffic. The board was rebooted after the MAC address was first set.


using System.Net;
using System.Text;
using System.Threading;
using GHI.Networking;
using GHI.Pins;
using Microsoft.SPOT;

public class Program {
    public static void Main() {
        var total = 0;
        var result = new byte[8192];

        using (var netif = new EthernetENC28J60(...)) {
            netif.PhysicalAddress = new byte[] { 0, 0, 0, 0, 0, 0 };
            netif.Open();
            netif.EnableStaticIP("0.0.0.0", "0.0.0.0", "0.0.0.0");
            netif.EnableStaticDns(new string[] { "0.0.0.0" });

            while (true) {
                using (var req = HttpWebRequest.Create("http://www.bing.com/robots.txt") as HttpWebRequest) {
                    using (var res = req.GetResponse() as HttpWebResponse) {
                        using (var stream = res.GetResponseStream()) {
                            do {
                                total += stream.Read(result, total, result.Length - total);
                            } while (total < res.ContentLength);

                            Debug.Print(new string(Encoding.UTF8.GetChars(result, 0, total)));
                        }
                    }
                }

                total = 0;

                Thread.Sleep(1000);
            }
        }
    }
}

@ John - Sorry, I must be missing something. ??? You also needed to reboot for the MAC address change to take effect?

@ wolfbuddy - Yes, the board was rebooted for the new address to appear.