enc28j60 ile linux sunucu iletişim hatası

merhaba. enc28j60 ile arduinoyu ağa bağlayıp sorunsuz ip alıyorum. ağda bir linux bir de windows sunucu var. windows sunucudan aşağıdaki kod ile istemci olarak cevap alabiliyorum. ama IP adresini değiştirip linux sunucudan veri almak istediğimde tutarsız çalışıyor. 10 dk içerisinde ard arda ve ara vererek test ediyorum sadece 1-2 sefer cevap alabiliyorum. linux sunucuda “iftop” komutu ile trafik izliyorum. sadece cevap alabildiğim zamanlarda istek listeye geliyor. cevap alamadığım zamanlarda istek ağ kartına bile gelmiyor. (Yani ben ağ kartına bile gelmediğini düşünüyorum iftop uygulamasına bile düşmediği için) kodu notifiymyadnroid örneğinden değiştirerek oluşturdum. dediğim gibi windows sunucuan talep edilen isteklerde sorunsuz çalışıyor kod: // This demo shows how to send a notification to the Notify My Android service // // Warning: Due to the limitations of the Arduino, this demo uses insecure // HTTP to interact with the nma api (not HTTPS). The API key WILL be sent // accross the wire in plain text. // // 2015-04-10 http://opensource.org/licenses/mit-license.php

#include <ethercard.h>

const char apihost PROGMEM = “192.168.0.12”;

static byte mymac = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };

byte Ethernet::buffer[900];
Stash stash;
static byte session;

static void notifyMyAndroid () {
byte sd = stash.create();

stash.print(“apikey=”);
stash.print(“0”);

stash.save();
int stash_size = stash.size();

// Compose the http POST request, taking the headers below and appending
// previously created stash in the sd holder.
Stash::prepare(PSTR(“POST /publicapi/notify HTTP/1.1” “\r\n”
“Host: $F” “\r\n”
“Content-Length: $D” “\r\n”
“Content-Type: text/html” “\r\n”
“\r\n”
“$H”),
apihost, stash_size, sd);

// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();

Serial.println("Session: " + (String)session);
}

void setup () {
Serial.begin(57600);
Serial.println(“\nStarting Notify My Android Example”);

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

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

//ether.using_dhcp = true;

/if (!ether.dnsLookup(apihost))
Serial.println(F(“DNS lookup failed for the apihost”));
/

ether.hisip[0] = 192;
ether.hisip[1] = 168;
ether.hisip[2] = 0;
ether.hisip[3] = 12;

ether.printIp("SRV: ", ether.hisip);

notifyMyAndroid();
}

void loop () {
ether.packetLoop(ether.packetReceive());

const char* reply = ether.tcpReply(session);
if (reply != 0) {
Serial.println(“Got a response!”);
Serial.println(reply);
}
}

linux:
https://i.imgsafe.org/c6140c375f.png

windows:
https://i.imgsafe.org/c614181a21.png

linux sunucun ubuntu 16.04 server
</ethercard.h>

aynı networkde hem linux hem windows sunucuları kurun. ayni kodun içinde iki sunucuya da bağlanmayı deneyin. aklıma gelen sizin mac adresini lokal rooter yada modem bufferladığı için sizin ip değişimini farkedemiyor olabilir. denemenizde modem yada rooteri de resetleyin

öncelikle teşekkürler ama başarısız oldu. ağda donanımsal bir framework kullanıyorum IP adresini otomatik verdittirip ping ile test ediyorum. enc28j60 'a erişimde sorun yok. Şimdi thingspeak’a erişimdede sorun yaşadığımı farkettim. Aynı şekilde tutarsız çalışıyor bazı gönderdiğim verileri iletirken bazılarını iletmiyor. Ama notifymyandroid 'e erişimde sıkıntı yok. o sorunsuz tüm verileri iletiyor. Başka bir ağ üzerinde tekrar test edeceğim. Sanmıyorum ama sorun belki ağ içi izinlerden kaynaklanıyor olabilir.

thingspeak e veri yollarken once soketi aç veri yolla soketi kapat seklinde olsun. veri aralıkları 15 saniyeden kısa olmasın. bu sekılde işe yarıyor. diğer durumlarda sorun bitmiyor

http://jeelabs.org/pub/docs/ethercard/ Buradaki kütüphaneyi kullanıyorum. Soket açıp kapatmayı elle yapabilcek bi method bulamadım sınıflarda. Otomatik yapıyor biri. Ayrıca dediğim gibi notfymyandroid sunucularında ve windows sunucularda sorunsuz çalışıyor.

kutuphanenin kendi orneklerini ınceleyin. kutuphaneye baktım tcp soket kapama yokmuş. başka bir adresi yalandan açmayı deneyi veri yolladıktan sonra. enj28j60 kutuphaneleri nedense fazla guncellenip bakım yapılmıyor detaylı işlere pek gelmiyor. arduinonun kendi ethernet modulu ile çalışmak lazım.

doğru hocam çok sıkıntılı. bir de global değişkenleri çok hoyrat kullanıyor. kendilerinin notifymyandroid örneği nanonun %80 sram 'ini dolduruyor.