MAC Address

I wasted a lot of time on this.

If I put more than 1 EMX on my network. It hangs etc…

Finally I found out that all the boards have the same MAC address.

I am not sure how that happened.

Does it come pre-programmed or do I need to program it at my end.

I want to do it from my program. In order to save production time.

How do I do it?

GHI provides you with the Mac address on a little sticker then it is up to you to program it or program your own. This should be explained in the emx manual

Changing the MAC address did not help. some part of the code is attached. Is there any issues you see…

                   
                    if (true)       //DHCP on
                    {
                        if (networkInterfaces[0].IsDhcpEnabled)
                        {
                            LocalIPAddress = networkInterfaces[0].IPAddress.ToString();
                            DispPrint(LocalIPAddress);

                            DispPrint("Renew DHCP Lease");
                            //networkInterfaces[0].RenewDhcpLease();
                        }
                        else
                        {
                            DispPrint("Enabling DHCP");
                            networkInterfaces[0].EnableDhcp();
                        }

                        //networkInterfaces[0].EnableDynamicDns();
                    }
                    else{
                        if (networkInterfaces[0].IsDhcpEnabled)
                        {
                            LocalIPAddress = networkInterfaces[0].IPAddress.ToString();
                            DispPrint(LocalIPAddress);

                            DispPrint("Current IP Address Released");
                            networkInterfaces[0].ReleaseDhcpLease();    //Release current Ip Address
                        }

                        DispPrint("Assigning Static IP");
                        networkInterfaces[0].EnableStaticIP(CommParser.IPAddress, CommParser.NetMask, CommParser.Gateway);

                        DispPrint("Assigning Static DNS");
                        networkInterfaces[0].EnableStaticDns(new string[] { CommParser.DNS });
                        //networkInterfaces[0].EnableStaticDns(new string[] { CommParser.Gateway });  //Temp
                    }

                    for (Int32 i = 0; i < networkInterfaces[0].DnsAddresses.Length; i++)
                    {
                        DispPrint("DNS[" + i + "]: " + networkInterfaces[0].DnsAddresses[i]);
                    }

                    String MACAddr = "";
                    for (Int32 i = 0; i < networkInterfaces[0].PhysicalAddress.Length; i++)
                    {
                        MACAddr += networkInterfaces[0].PhysicalAddress[i].ToString();
                        MACAddr += ".";
                    }
                    DispPrint("MAC: " + MACAddr);

                    LocalIPAddress = networkInterfaces[0].IPAddress.ToString();
                    DispPrint("IP: " + LocalIPAddress);

                    String tStrings = networkInterfaces[0].SubnetMask;
                    DispPrint("Subnet Mask: " + tStrings);

                    tStrings = networkInterfaces[0].GatewayAddress;
                    DispPrint("Gateway: " + tStrings);

//use DNS
System.Net.IPHostEntry entry = null;
entry = System.Net.Dns.GetHostEntry(ServerAdd);
if (entry == null)
{
    General.LED_Ether_OFF();
    DispPrint("DNS Error 1");
    return sTCPClient;
}
else
{
    ipAddress = entry.AddressList[0];
}

using (Socket clientSocket = new Socket(AddressFamily.InterNetwork,
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp))
            {

System.Net.IPEndPoint serverEndPoint = new System.Net.IPEndPoint(ipAddress, ServerPort);

clientSocket.Connect(serverEndPoint);

It is stuck in socket connect many times. But sometimes it just works.

14:09:Et:Renew DHCP Lease
14:09:Et:DNS[0]: 192.168.1.254
14:09:Et:DNS[1]: 148.129.0.160
14:09:Et:MAC: 0.26.241.0.66.204.
14:09:Et:IP: 192.168.1.204
14:09:Et:Subnet Mask: 255.255.255.0
14:09:Et:Gateway: 192.168.1.254

Any updates please…

I doubt that the problem you are seeing is related to mac address or DHCP.

I notice that you have System.Net.Dns.GetHostEntry() in the code. Does it always work on every deploy? If the answer is yes. Then you don’t have a problem with the networking stack. and I recommend that you check the server you are connecting to.
If you like try to connect to any http server on the web, this way you make sure that you are connecting with a reliable server.

If it is a wifi connection, make sure that the signal is good.

It is wired ethernet from The EMX.

notice that you have System.Net.Dns.GetHostEntry() in the code. Does it always work on every deploy?

What does this mean?

I cut and paste the same string when this fails on the internet explorer and I see it works. So I think the server is good.
I had once put yahoo.com and that also got stuck. So I think it is not server related

You mean that the server you are trying to access is a public web server? If this is true, and socket.connect() is not working, I don’t want to mislead you. but it could be a hardware or connectivity issue. The cable, the router.

Are you using EMX Development System or it is a custom hardware?

You need to investigate that more Microt, there is something wrong.

So I took it to my customer place thinking it could be just my router set up. And felt bad that it did not work.

Our competitor was able to connect to the customers web server with no issues. They are using some other .NET board inside.

Our set up is a custom EMX board.

There is also a private server running(for set up) on the same EMX at port 22 and that works without any issues. So I think the connections are good. It is only the client that is sending data to the server that hangs most of the time

We are very sorry to hear that :frowning:

.NET MF devices share the same TCP/IP stack. it is either RTIP stack by EBSnet which is the reliablly used for years or lwIP which is not used a lot yet with NETMF.
Currently we use RTIP with EMX.
So if the competitor is using a NETMF board, then it is most likely the same TCP/IP stack.

For the problem you are facing, is there a way that you sniff the Ethernet packets? It might give you some clue. Also if you have a code that shows the problem, we can check it for you.

Hi Joe

I did a wireshark trace and you can see the 192.168.1.204 in red.
Can i send you the trace by email. Will that help

Microt, your issue needs a one-on-one support. Please email us directly ghielec@ ghi…
If you have Joe’s email then you may also get to him directly.

We will post findings back here later.

Done…

Have also sent you sample code