Pages: [1]   Go Down
Author Topic: Unstable Connection ENC28J60 / HanRun HR911105A with Nano  (Read 2785 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

I have trouble to get a stable connection with a HanRun HR911105A with a Arduino Nano 3.0

I'm using the Libary "ethercardMaster"  (https://github.com/jcw/ethercard)

My problem:
After some (random) time, the connection to the Server is getting unstable - I get no results back. I'am testing yesterday 10 hours to get that fixed, but without success. I also make a very big workarround to automatically restart the board if the connection is hanging, but this is no solution :-(

Sometime it works 1 minute, sometime 2 hours....

Thank you very much for any help! :-)

This is the Code (Democode, called Webclient):
Code:
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "www.softairforum.org";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  Serial.begin(57600);
  Serial.println("\n[webClient]");

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
    
  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());
  
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
  }
}

Here an example Result:
Code:

[webClient]
IP:  192.168.178.38
GW:  192.168.178.1
DNS: 192.168.178.1
SRV: 78.47.199.9

......

<<< REQ >>>
HTTP/1.0 404 Not Found
Connection: close
Content-Type: text/html
Content-Length: 345
Date: Thu, 27 Dec 2012 11:01:01 GMT
Server: lighttpd/1.4.19

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DT...

<<< REQ
<<< REQ
<<< REQ
<<< REQ
<<< REQ
« Last Edit: December 27, 2012, 06:02:44 am by erf2012 » Logged

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

Hello,

Unfortunately, I get the same kind of errors, but often after several days which makes testing / debugging quite difficult
The first step I did to reduce the number of errors was to go from 3V3 to 5V alimentation as I noticed that my Nano copy was delivering a mere 3.1V wich was not sufficient

Still investigating ...
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you guy manage a solution for this problem?

Thanks
Logged

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

I managed to reduce the frequency of errors by optimizing memory usage (using tips found on this very forum), but still have connection issues (i.e. sometimes 2 days after restart, sometimes 3 weeks)
I now suspect a memory allocation issue somewhere in my code ...
Logged

Pages: [1]   Go Up
Jump to: