Main Site Documentation

TCP/IP support


#1

I’m trying to use the sample application for TCP/IP support, and am having consistent exceptions at line 40 (server.Accept()). The error is:

[quote]An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.W5100.dll

Additional information: Fail[invalid ip,port][/quote]

I’ve tried changing the DNS address, etc., but I can’t figure out what the issue might be. Anyone out there willing to help?

UPDATE: I noticed also that the sample’s call to WIZnet_W5100.Enable(…) seems to be missing a parameter. Is the fact that I need to supply an additional boolean (reserveSocket) an indication of a problem?


#2

Hi there

happy to help out.

I’ve grabbed the code from the brochure http://www.tinyclr.com/downloads/Shield/Broch_EthernatShield.pdf

Pasting that into a new project (console app template) and adding the references it needs, including the W5100 module, all errors are clean.

Here’s the relevant section of code that I have used:

const Int32 c_port = 80;
byte[] ip = { 192, 168, 0, 200 };
byte[] subnet = { 255, 255, 255, 0 };
byte[] gateway = { 192, 168, 0, 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, 0, 1 });
Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port);
server.Bind(localEndPoint);
server.Listen(1);

The sample does not seem to be missing the parameter for the enable call:
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9,true);

Where did you get the sample code? The above PDF?

If you take a step back, I am assuming you have the latest GHI SDK installed, and the firmware on your Domino updated to the latest?


#3

Also do you have the latest firmware?


#4

I believe I do have the lastest firmware (updated the .ghi in the Usbizi folder in the SDK install directory using TeraTerm). What should MFDeploy be telling me?

The shield I’m using is not the one you guys sell (sorry, got it a while back) but it is based on the W5100 chip. I’m wondering if I need to tweak some of the parameters? I got the sample code from a posting in the thread that announced the improved ethernet support, not the PDF.

I’ll walk through the tutorial code in the PDF (looks basically the same as what I have) and see if I can spot a difference. The fact that the error is in Accept(…) and that it’s complaining about a bad IP (or IP/Port combination) seems really odd. Google gives me all of 9 hits on that error string, which is a little scary – apparently I’m off in uncharted waters. :slight_smile:


#5

See getting started video and here is the latest version http://www.tinyclr.com/release-notes/


#6

Is it Arduino shield?
If so, you might have the problem with the reset button!
Please read the first and second paragraph in the brochure.
http://www.tinyclr.com/downloads/Shield/Broch_EthernatShield.pdf
the same on that Brett mentioned earlier.

I got the code from the brochure to work, but I had to change the third value of the IP from 0 to 1

byte[] ip = { 192, 168, 1, 200 };

#7

[quote]UPDATE: I noticed also that the sample’s call to WIZnet_W5100.Enable(…) seems to be missing a parameter. Is the fact that I need to supply an additional boolean (reserveSocket) an indication of a problem?
[/quote]

Where did you take this example from? This needs to be fixed. It is probably an old example.


#8

I found the code in this thread:
http://www.tinyclr.com/forum/15/947/


#9

Hi all,

I’m new to the FEZ community so maybe i’m doing something wrong.
But my problem is that i also het the error regarding ip/port.
I have the FEX Domino with a Seed Studio WIZNET Ethernet Shield (W5100)
I have flashed the firmware to the latest version and am using the latest SDK’s and so on.

Does someone know how to get this working?

this is part of the output:
The thread ‘’ (0x2) has exited with code 0 (0x0).
#### 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]

Uncaught exception
The thread ‘’ (0x1) has exited with code 0 (0x0).
Done.

Waiting for debug commands…

The program ‘[33] Micro Framework application: Managed’ has exited with code 0 (0x0).


#10

That is the error but where is the code? :slight_smile:

I am assuming your are flowing this doc? http://www.tinyclr.com/downloads/Shield/Broch_EthernatShield.pdf


#11

Indeed, that’s the code i’m using.


#12

Then have you checked the little jumpers that select the signals from ISP connector to standard connectors?

See pictures here http://www.tinyclr.com/forum/2/1794/#/2/


#13

Thanks, that seems to be the problem.
I’ll see if I can fix it when i’ve a got a good tiny soldering tool.