Main Site Documentation

W5100 sample code


#1

Hi, we have hooked up a W5100 device to our panda, but we are struggling to find any simple sample code to use the new WIZnet_W5100 assembly, most of the code seems to be referring to a previous beta, is there an up to date example on how to use the GHIElectronics.NETMF.Net.WIZnet_W5100 class,
thanks


#2

for example most of the code has this call…


WIZnet_W5100.Enable( SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
     (Cpu.Pin)FEZ_Pin.Digital.Di9);

but there seems to be an extra parameter on the Enable call in the assembly


public static void Enable(
	SPI_module spi,
	Pin CS,
	Pin Reset,
	bool ReserveSocket
)


#3

I notice this thread is on the same issue

http://www.tinyclr.com/forum/15/947/

we see the same problem, any thoughts


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


#4

There are four sockets on the w5100. If you will be using dns, then you need to reserve a socket for it’s use.

The first betas automatically had a socket reserved, giving the user three sockets to use.

If you were building a server, which did not use dns, the fourth socket was unavailable.

The reserve parameter was added at the end of the beta to give the user the option to control the reservation of the fourth socket. Now, you can accept four sessions on a server.


#5

Basically what Mike had said…

ReserveSocket was added after beta so all you had to do to use old code is to add a last parameter of true or false. If not sure what that is, use true.


#6

OK got it sorted, the trouble was with the cs for reference you need to wire up the following pins on the WIZ5100…

VCC
GND

SCLK -> SPI SCLK
/SCS -> SPI CS
MOSI
MISO

/RESET


#7

now works well, good job monkeys (Joe)


#8

Ethernet shield brochure and GHI NETMF library documentation have some examples too.


#9

I’m using this DFRobot ethernet shield (W5100 chip) http://www.dfrobot.com/index.php?route=product/product&keyword=ethernet&category_id=48&product_id=52 with my Panda.
The first example (simple web server) from the Ethernet brochure works just fine within the local network (192.168.1.111:8080 static IP, port forwarding from my router). I’m not able to connect to the web server using the address 188.26.xxx.yyy:8080
The same setup works with Arduino, but not with Panda. It just lights up the communication LED’s 3 times, then I get a server is taking too long to respond message.
Please help, I’m not familiar with sockets… what debug messages should I use to see what’s happening?

Thank you!


#10

you don’t need debug messages, you need network monitor. Download it from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=983b941d-06cb-4658-b7f6-3088333d062f&displaylang=en and install it on a PC. Then capture what traffic is being sent to the device from your internet facing device.

Personally I always suspect port forwarding setups :slight_smile:


#11

Thank you, Brett, but I’m afraid that I don’t understand much from the output :frowning:

A few output lines (IP edited by my where xxx.yyy). PC address is 192.168.1.100, Ethernet shield on Panda is 192.168.1.111, router is 192.168.1.1

[quote]3 14:30:40 02.12.2010 8.3925780 chrome.exe 192.168.1.100 188.26.xxx.yyy TCP TCP:Flags=…S., SrcPort=2810, DstPort=HTTP Alternate(8080), PayloadLen=0, Seq=2274523199, Ack=0, Win=65535 ( Negotiating scale factor 0x1 ) = 65535 {TCP:1, IPv4:1}

4 14:30:40 02.12.2010 8.3925780 192.168.1.1 192.168.1.111 ARP ARP:Request, 192.168.1.1 asks for 192.168.1.111

5 14:30:40 02.12.2010 8.4228510 chrome.exe 192.168.1.100 188.26.xxx.yyy TCP TCP:Flags=…S., SrcPort=2811, DstPort=HTTP Alternate(8080), PayloadLen=0, Seq=758498030, Ack=0, Win=65535 ( Negotiating scale factor 0x1 ) = 65535 {TCP:2, IPv4:1}

6 14:30:40 02.12.2010 8.6435540 chrome.exe 192.168.1.100 188.26.xxx.yyy TCP TCP:Flags=…S., SrcPort=2812, DstPort=HTTP Alternate(8080), PayloadLen=0, Seq=3819894829, Ack=0, Win=65535 ( Negotiating scale factor 0x1 ) = 65535 {TCP:3, IPv4:1}

7 14:30:41 02.12.2010 9.3984370 192.168.1.1 192.168.1.111 ARP ARP:Request, 192.168.1.1 asks for 192.168.1.111

8 14:30:42 02.12.2010 10.4033200 192.168.1.1 192.168.1.111 ARP ARP:Request, 192.168.1.1 asks for 192.168.1.111
[/quote]
and so on, 3 or 4 times…


#12

You will need to filter out all other traffic and leave Panda traffic only. That will make things easier to look at. I haven’t used Network Monitor, but in Wireshark you can do filter by IP. There should be something similar in Network Monitor.


#13

The problem was that I didn’t changed the MAC.
I still don’t know why it only worked with 192.168.1.111:8080, but now it works with both addresses (192.168… and 188.26…)
Maybe there’s a obvious reason, I don’t know much about networking, still have a lot to learn…

//        byte[] mac = { 43, 185, 44, 2, 206, 127 };
        byte[] mac = { 222, 173, 190, 239, 254, 237 }; // the mac that worked with Arduino

Thank you Brett and Architect for your help!


#14

[quote]OK got it sorted, the trouble was with the cs for reference you need to wire up the following pins on the WIZ5100…

VCC
GND

SCLK -> SPI SCLK
/SCS -> SPI CS
MOSI
MISO

/RESET[/quote]

I got the same message as Peter Kenyon:
Additional information: Fail[invalid ip,port]

What should i wire up?? I don’t see the indicated pins on my arduino ethshield
Can you maybe post a pic of it??

Thanks,

Jeroen


#15

hullie,
It’s seem like you have the version 5 of the Ethernet Shield from Arduino…
Unfortunately, there are no traces from pin 11 (MOSI), 12 (MISO) and 13(CLK) on the Shield.
They want to have the compatibility to both Arduino & Arduino MEGA, so they moved the connection to the ICSP at the bottom of th uSD socket.

If you want to use the shield with FEZ (Domino or Panda) you need to rewire those SPI pins to
to ICSP

look at this thread before the end of page 1 and at the end of the post of the pictures of how I modified the Shield.

http://www.tinyclr.com/forum/1/1439/#/2/


#16

Hi Sam!

Ok, thanks for the quick reply. I’ll have a look at it.

Hullie


#17

Sam,

I am waiting on one of these. Will use your wiring trick. Thank you.


#18

Does anybody know, if the seeedstudio shield works without rewiring?
http://www.robotshop.com/seeedstudio-wiznet-ethernet-arduino-shield.html
Thanks!
Hullie


#19

Look from the Schematic provided in the downloaded zip files.
I would say YES! No rewiring is needed! :wink:


#20

Ok, thanks again Sam. We’ll give it a try!

Best regards,
Hullie