Main Site Documentation

Trouble with ethernet shield


#1

Hi, Ive just bought FEZ domino and am attempting to run it with an arduino ethernet shield.
I’ve done the modifications as recommended here and on attempting to run the example webserver gode i get the following exception:

    #### Exception System.Exception - 0x00000000 (1) ####
    #### Message: Fail[invalid ip,port]

    #### GHIElectronics.NETMF.Net.SocketNative::accept [IP: 007f] ####
    #### GHIElectronics.NETMF.Net.Sockets.Socket::Accept [IP: 0023] ####
    #### MySocketServer::Main [IP: 0085] ####
A first chance exception of type 'System.Exception' occurred in GHIElectronics.NETMF.W5100.dll
An unhandled exception of type 'System.Exception' occurred in GHIElectronics.NETMF.W5100.dll

Additional information: Fail[invalid ip,port]

I get this whether the ethernet cable is connected or not and regardless of what ip/ port combination I supply.

Anyone got any insight into this?


#2

I had the same error when I connected wrong pins between FEZ and Wiznet. What shield exactly are you using ?


#3

Its the official arduino shield with the reset pin routed to digital 9


#4

here is some minimal code that can allow you to verify that the shield is working as expected. http://www.tinyclr.com/forum/13/2665/ If you can’t PING the device at that point, then there’s something else wrong.


#5

Were you able to ping the IP address?


#6

Hi I’ve just tried that example posted above.
The device still does not respond to ping(I have tried bot direct connection via a crossover cable and through a switch), however, the tx/rx lights blink in sync with the ping requests.
One thing I did notice was that server.LocalEndPoint.ToString() returns 0.0.0.0:0, would this be indicating that it cannot bind to an ip correctly?


#7

The above example works - so that most likely means you have some other issue that’s related to hardware. You did of course change the pin definitions to the actual pins you’re using on your shield, didn’t you??

The TX/RX lights don’t mean much in that context, the wiz5100 chip will do that; I really think you really have a hardware issue. Perhaps you need to confirm you have all the pins connected as you would expect - can you step into a program that just toggles the pins on your shield and measure the voltage with a multimeter, making sure they go to 3v3 when you set them high?


#8

Make sure that you use the correct network settings according your network.


#9

@ eejit

I've done the modifications as recommended here 

What modifications ? Please explain.


#10

As per modifications I’ve routed the reset pin on the shield to dio pin 9 and ive routed the SPI pins from the ICSP connector on the shield to the appropriate pins on the board.

Network conf and the hardware is definitely ok, I’ve tested the shield on an arduino with the same network settings and it works fine


#11

Could you please show me the code and picture on how you connected the Reset pin?


#12

the resset pin is connected as shown in http://www.ghielectronics.com/downloads/FEZ/Domino/Broch_FEZ_Domino.pdf and the icsp is wired as shown in http://wiki.tinyclr.com/index.php?title=FEZ_and_Arduino_Ethernet_Shield_05

The code Ive been trying to run is the minimal code that i was linked to in this thread:

    public class Program
    {
        public static void Main()
        {
            byte[] ip = { 192, 168, 2, 100 };
            byte[] subnet = { 255, 255, 255, 0 };
            byte[] gateway = { 192, 168, 2, 1 };
            byte[] mac = { 43, 185, 44, 2, 206, 127 };
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,(Cpu.Pin)FEZ_Pin.Digital.Di9, true);
            NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 2, 1 });
            Socket serversocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,ProtocolType.Udp);
            EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 2000);
            serversocket.Bind(remoteEndPoint);
            int i = 1;
            while (true)
            {
                if (serversocket.Poll(-1, SelectMode.SelectRead))
                {
                    byte[] inBuf = new byte[serversocket.Available];
                    int count = serversocket.ReceiveFrom(inBuf, ref remoteEndPoint);
                    Debug.Print(new String(Encoding.UTF8.GetChars(inBuf)));
                }
            }
        }
    }

#13

I would rather see the image of your board.

The code looks fine. I am not sure how to help you more.
Did bend out the reset pin? as in the document you mentioned?


#14

eejit,

http://www.arduino.cc/en/Main/ArduinoEthernetShield
Is this the Ethernet Shield that you have?

If so, you probably do not need to reroute the reset to pin Di9.
The problem of the reset had been solved by the manufacturer on this Version of the shield!

The Ethernet Shield shown on the Brochure is an earlier version of the shield.
That version have the problem with the Reset, as mentioned on the Brochure.

As Joe mentioned, if you could show the picture of your Shield, that would help to determine the problem better.

Make sure that you have all the References added, and also make sure that you do not miss any ‘using …’ at the beginning of the code.