Pages: [1] 2   Go Down
Author Topic: Enc28J60 socket API  (Read 3884 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, all.

I try to write socket API for enc28j60 ethernet but it seems to be very hard.

None of dozen of libs for enc28j60 including turicas(https://github.com/turicas/Ethernet_ENC28J60/), simon monk's (http://www.doctormonk.com/2010/03/simplified-ethernet-library-for-28j60.html), ethercard (https://github.com/jcw/ethercard) work properly.
Some stops to response to ping after few ping successfull pings, some just don't work for me for some strange reason, some of them does not allow to send response after it's sent once.

The only lib that seems to be good is uIP port for AVR (https://github.com/sde1000/NanodeUIP) and it already has psocks libs which provides socket API.
But it does not work in some cases (f.e. when response is sent right after data is received) and it's pretty difficult to debug network packets (~10.000 lines without debugger).
I've spent almost 2 months trying to make it working and finally failed)

Any ideas how to get functionality similar to w5100 lib?
The next methods are required:
Code:
bool available();
int read();
void write(int);

Thanks in advance.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was able to do the same (https://github.com/4ntoine/ArduinoCommander-ethernet) in few hours for W5100-based ethernet shield since i finally received it. May be, someone will be more lucky with Enc28J60 than me  smiley Anyone? https://github.com/4ntoine/ArduinoCommander-ethernet/wiki/Contribution
« Last Edit: July 13, 2012, 12:57:51 pm by 4ntoine » Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Just Do it (with Arduino of course)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I tried the libraries as well, and indeed it if far from obvious. My HW is a DINo from KMtronic, and I managed to get the web server example (using an old, maybe modified Ethershield) running. Ethercard always failed, though it looks to be smarter and more optimized. I consider using the Nanode variant, did you try that one ?
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, i played with Nanode a week or two.
It is designed to reply to GET response once so i was unable to work with it as with stream (use
Code:
write(int outComingByte)
method)
Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Just Do it (with Arduino of course)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you think it would be feasible to align the library API with the Wiz5100 one ? How complex would that be ? Because things like IPAddress class etc. should be the same, shouldn't they ?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very complex, I believe.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you think it would be feasible to align the library API with the Wiz5100 one ? How complex would that be ? Because things like IPAddress class etc. should be the same, shouldn't they ?
Yes it would be great! Turicas tried to do the same https://github.com/turicas/Ethernet_ENC28J60:
Quote
In a near future I want to replace all ip_arp_udp_tcp layer in the socket layer, so the architecture will be more like the standard Ethernet library:

{Ethernet.cpp, Server.cpp, Client.cpp} ↔ socket.c ↔ enc28j60.c

When this goal is reached we can create a single socket.c that communicate with one or another controller (W5100 or ENC28J60).
Actually i don't remember why it was not working for me, but i like the idea to have the same interface for w5100 and enc28j60
Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Just Do it (with Arduino of course)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Nick, could you elaborate ?

I believe probably 30-40% of the differences are linked to "programming style" and naming conventions more than functionalities. Things like MAC addresses or SPI instructions could be the same. On the 28J60, there seems to be a buffer so that you can "push" the parts of the packet and then kind of "flush" it. Sounds close to Serial API, and WIZ5100 library was reworked in order to be closer to Serial IIRC ? (or maybe it's a very bad idea because the meaning of fluch is completely different ?)

On the other hand, the TCP part on both circuits seems very different, since 5100 can handle TCP itself while 28J60 can't (what in practice limits connections one received packet / socket).

Any idea which of EtherShield or EtherCard would be a better start ? Anybody wanting to collaborate on that ? The first step wouldn't include any programming, only collaborate to understand the differences... And why not, put the result somewhere in the playground.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Nick, could you elaborate ?

I believe the Enc28J60 chip has much less functionality on the chip, compared to the Wiz5100 one. Thus it is cheaper. And harder to work with.

I got one of those cheaper Ethernet boards, and when I found that doing fairly simple stuff was incredibly complex, I pushed it to one side.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any idea which of EtherShield or EtherCard would be a better start ?

In the meaning of closest API psock is the closest, but it's very difficult to debug using Serial.print(..) only without hardware debugger.
Also take into account that psock is designed in a very complex way in the meaning of working with threads, so it's behaviour is pretty strange: it can go out of infinite loop in a thread and move back later.
So you have to understand psock threads idea first. I believe that with hardware debugger and/or deep knowledge of TCP  it's much more easy.

Another approach can be to get one of existing tiny TCP implementation (f.e. lwIP http://savannah.nongnu.org/projects/lwip/) and port to ATMega/Arduino + Enc28j60 thought i'm not sure that it can be done as it works with hardware closely.

Quote
Anybody wanting to collaborate on that ? The first step wouldn't include any programming, only collaborate to understand the differences... And why not, put the result somewhere in the playground.
I've created stubs for enc28j60 https://github.com/4ntoine/ArduinoCommander-ethernet/tree/master/Ethernet to make it easier as client-side (ArduinoCommander) is ready.
Or one can create simple Echo sketch..
« Last Edit: August 09, 2012, 12:20:05 am by 4ntoine » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This tcp implementations can help:
http://code.google.com/p/avr-uip/
http://code.google.com/p/avr-net/
Logged

Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any idea which of EtherShield or EtherCard would be a better start ? Anybody wanting to collaborate on that ? The first step wouldn't include any programming, only collaborate to understand the differences... And why not, put the result somewhere in the playground.

Why not turicas's? He seems to have already done most of the job. I haven't tried his work yet, though. Maybe I'll find some time to do it in the weekend. Oh, and I've found another one: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291904599/8. Quite rough and I can't get it to work, but has some good points:

Quote
- write function can assembly one big packet from smaller chunks

- buffer (1536bytes) for TCP/UDP data directly on enc28j60 chip. Thanks to this we can use "available" and "flush".

I think compatibility with Arduino Ethernet library is now within your reach Wink

BTW, I am currently using EtherCard on KmTronic's DINo with good results, anyway. @4ntoine: Are you sure your code is OK? With a 700-800 byte packet buffer it's quite easy to run out of RAM smiley-sad.
« Last Edit: August 10, 2012, 12:57:57 pm by SukkoPera » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
@4ntoine: Are you sure your code is OK? With a 700-800 byte packet buffer it's quite easy to run out of RAM smiley-sad.

This can probably be the reason. But i used libs examples to test if it's working in common case first so buffer size is used as is.
I try to modify StandardFirmata sketch to work over Ethernet (TCP) using enc28j60, so most part of the sketch seems to be mature and stable.
Firmata messages are quite short, no longer than 50 bytes (except one message).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I did tcp implementations that can help.
It's still in work, but it's working for small (250) packets.
https://github.com/dovrose/Socket-network-for-enc28j60---arduino

I would love to have comments
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I did tcp implementations that can help.
It's still in work, but it's working for small (250) packets.
https://github.com/dovrose/Socket-network-for-enc28j60---arduino

I would love to have comments

Great! Can you show usage by integrating into https://github.com/4ntoine/ArduinoCommander-ethernet/issues/1?
Logged

Pages: [1] 2   Go Up
Jump to: