gauranggoyal123 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

w5200 library code #898

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What change would like to see?
Replace the current ethernet shield w5100.h and w5100.cpp files with the files 
attached.

Why? By removing the comment slashes on "#define W5200" in w5100.h will compile 
for a w5200 shield.

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

None detected so far.

Original issue reported on code.google.com by t...@prolectron.com on 24 Apr 2012 at 2:01

Attachments:

GoogleCodeExporter commented 8 years ago
I have been using the W5200 on a EKitZone Ethernet Shield and a Mega2560 and 
there are changes in Ethernet.h and Ethernet.cpp also.

In Ethernet.h, You need to change: 

#define MAX_SOCK_NUM 4

to

#if defined(W5200)
  #define MAX_SOCK_NUM 8
#else
  #define MAX_SOCK_NUM 4
#endif

In Ethernet.cpp, you need to change:

//W5100 only has 4 sockets
uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 
  0, 0, 0, 0 };
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 
  0, 0, 0, 0 };

to

#if defined(W5200)
// W5200 has 8 sockets
uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 
  0, 0, 0, 0, 0, 0, 0, 0 };
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 
  0, 0, 0, 0, 0, 0, 0, 0 };
#else
//W5100 only has 4 sockets
uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 
  0, 0, 0, 0 };
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 
  0, 0, 0, 0 };
#endif

As a side not the W5200 also has a physical Link Status register so it is 
possible to tell when the cable is unplugged, but this is not exposed in the 
current W5100 files.

from the W5200 datasheet:
0x0035 - PHY Status(PSTATUS)
PHYSTATUS(W5200 PHY status Register)[R/W][0x17]
PHYSTATUS is the Register to indicate W5200 status of PHY.

I believe exposing would help with the DHCP renewal issue, not sure how to 
reliably do the same on the W5100.

Thanks,
Gene

Original comment by Nightrad...@gmail.com on 25 Apr 2012 at 5:29

GoogleCodeExporter commented 8 years ago
Thanks, Gene! I forgot about those declarations. I did the _socket and 
_server_port init a bit different tho. Attached are my new Ethernet.h and 
Ethernet.cpp files with my changes. This is from the IDE v1.0.1-rc1 library.

Original comment by t...@prolectron.com on 25 Apr 2012 at 11:46

Attachments:

GoogleCodeExporter commented 8 years ago
After a little experimenting, I found that if I include the w5100.h file in 
Ethernet.h, I don't need to define MAX_SOCK_NUM again. I deleted that part from 
my test code.

Original comment by t...@prolectron.com on 25 Apr 2012 at 12:30

GoogleCodeExporter commented 8 years ago
Yes, in 0022 it was included, but for some reason that changed in 1.0, I do not 
know why it was changed?

Thanks,
Gene

Original comment by Nightrad...@gmail.com on 26 Apr 2012 at 3:07

GoogleCodeExporter commented 8 years ago
Also, is there any reason why the hostname is hard coded? In my code I have 
change

int begin(uint8_t *mac_address);

to

int begin(uint8_t *mac_address, const char *sHostname);

which I save and send instead of the hard coded "wiznet" string. All seems to 
work great. I have not tested the DHCP renewal yet.

Original comment by Nightrad...@gmail.com on 26 Apr 2012 at 3:14

GoogleCodeExporter commented 8 years ago
in attached file Ethernet.h 
--- cut ---
// W5200 change
#ifdef W5200
  #define MAX_SOCK_NUM 4
#else
  #define MAX_SOCK_NUM 8
#endif
--- cut ---
its wrong, need exchange 4 and 8

Original comment by alexis.z...@gmail.com on 14 Jun 2012 at 11:32

GoogleCodeExporter commented 8 years ago
All 4 files from IDE 1.0.1 with applied changes

Original comment by alexis.z...@gmail.com on 14 Jun 2012 at 11:43

Attachments:

GoogleCodeExporter commented 8 years ago
@alexis: I removed those MAX_SOCK_NUM defines from my Ethernet.h file. I 
included the w5100.h file instead, and so does yours. That file has all the 
defines. See comment 3 above. And those defines in w5100.h above appear to be 
correct.

Original comment by t...@prolectron.com on 15 Jun 2012 at 12:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
sorry, I just said that if 5200, then 8 sockets, but not vice versa
(nothing)

another problem: how to run it on the Mega ?
I tried, but could not run Wiz820io R1.0 on the Aruino Mega 2560 R3 and 
Seeeduino Mega 2560.
:-(
something is not properly initialized, if we at Mega.
SPI?
where to look?

Original comment by alexis.z...@gmail.com on 15 Jun 2012 at 1:55

GoogleCodeExporter commented 8 years ago
I have been using the W5200 on a mega2560 with the above changes, for many 
months now without issue.
 Using the "EKitsZone W5200 Ethernet Shield".

Original comment by Nightrad...@gmail.com on 19 Jun 2012 at 1:08

GoogleCodeExporter commented 8 years ago
I have tried most of the solutions mentioned, but no luck getting my device to 
connect. I used the 4 files from alexis... Grateful for some advice. I am using 
W5200 from Elecrow. Thank you.

Original comment by shankars...@gmail.com on 4 Nov 2014 at 3:09