Git Product home page Git Product logo

ethernet2's Introduction

Deprecated/Archived Library

This library is no longer going to be used, since the official Arduino library has been updated and works great https://github.com/arduino-libraries/Ethernet

License

Copyright (c) 2009-2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

ethernet2's People

Contributors

0neblock avatar dmorina avatar ivan-perez avatar ladyada avatar njh avatar per1234 avatar tdicola avatar toddtreece avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethernet2's Issues

Unnecessarily slow Ethernet interfaces due to none ideal SPI clock

On default the W5500 is running with a 8MHz SPI clock with up to 359.712kb/s transfer rate to a PC.

Using an Arduino Due board the W5500 can run with a 28MHz SPI clock with up to 505.500kb/s transfer rate to a PC.

The SPI clock rate depends on the CPU (board), the W5500, and the layout of the board.
Experience user should have a chance to choose his own SPI clock settings.

Please implement a simple method that users can set the SPI speed (e.g. like implemented in SD.cpp already).

Dieter Burandt

IP address for Ethernet shield

I forget the IP address of Ethernet shield. How can I know it?

I open network and sharing center there is a new device connect but its didn't sent or receive.
Then I search on cmd config/all there is no new device that i can ping on to get IP address.
I try to connect it to switch to see the plugged in device there is no thing it didn't appear.
Also i try to connect it to router and follow tutorial and there is no result. is there is any certain protocol?

Memory leak, despite fixes

  • Arduino board: Own PCB with ATmega1284P-PU and WIZ850io (WIZnet Networking Module with W5500 and MAG Jack)
  • Arduino IDE version 1.8.5

I have been using this Ethernet2 library for sending data from a datalogging board I designed. I have managed to send data using the WIZ850io/W5500 and library, repeatedly sending data to a server via POST requests without issue.

I have run into problems, though, when using repeated calls to Ethernet.begin([MacAddress]), which I have to do as I need to de-power the WIZ850io/W5500. I need to do that as the whole project is running off battery power (data is being sent out over a modem using cellular/mobile data) and the WIZ850io uses quite a bit of power.

Each time Ethernet.begin([MacAddress]) is re-called (after the WIZ850io is de-powered, the ATmega1284 sleeps, then the WIZ850io is powered up again), an extra 26 bytes of RAM is lost, never to return. Though the ATmega1284 has more memory than smaller ICs, this runs out after 500 or so calls to Ethernet.begin([MacAddress]).

While data are being sent fine and reliably, the memory leak causes the processor to seize up after a number of Ethernet restarts.

I found mention of a memory leak fix on a different version of this library here:

https://github.com/arduino-org/Arduino/pull/72/files?diff=unified

It seems that the setting of DhcpClass* _dhcp = NULL; mentioned there, in file Ethernet2.h, is done in a similar, but different way in this library, and the check for _dhcp != NULL and subsequent delete _dhcp; before the _dhcp = new DhcpClass() line, in Ethernet2.cpp, is done in the same way in this library.

Yet, I still seem to get a memory leak, so I’m wondering if there is anywhere else that memory needs to be freed, or if there is another way to structure the code so that the _dhcp = new DhcpClass() is done only once, but the rest of the Ethernet.begin([MacAddress]) function can be called to renew/refresh the connection to the W5500 IC?

Null termination

Hello

Here is the problem I noticed.
I am using Ethernet2 library with Ethernet shield and Arduino Uno.
I receive messages over UDP from a "box" that I have no control over.
The issue I am facing is when I receive the data 16 bytes, it is being truncated when encounters a null termination.

Example.
Box sends (data captured on UDP tool)
hex code. 62 00 00 00 00 D2 00 00 00 00 00 00 62 00 00 00 (in Decimal code: 98 0 0 0 0 210 0 0 0 0 0 0 98 0 0 0)

On Arduino side, I receive the 62, then nothing after that.

One thing to note is that when I did my own testing and sending data from my pc. it is consistent, when I send the exact data above, it stop. If replace the 00 with comma or 01, I receive the entire data packet..

I am using this something similar to your example....
#include <Ethernet2.h>
....
Udp.read(udpRawData, 40);
... iterating through the udpRawData in for loop.

Question
Is the library expecting null terminated string? if so how to go around this. I know I will be receiving fixed length of bytes. Is there a way to bypass the null terminated check?

ESP32+Ethernet2.h+Encryption+PubSubClient

Hi all,

I have an Adafruit Feather ESP32 and FeatherWings ethernet module and I am having issues to encrypt the comunicaciont with MQTT Broker.
In this case I have tried the following libraries with out success:
1.- Ethernet2.h+WiFiClientSecure+PubSubClient.h
2.- EHT.h+WiFiClientSecure.h+PubSubClient.h

In the past I use ESP32+LAN8720 with the libraries EHT.h+WiFiClientSecure.h+PubSubClient.h and work as expected.

Do you know if there is any other posibility to implement Encryption in ESP32 and MQTT Broker?

cannot declare variable 'server' to be of abstract type 'EthernetServer' (ESP32)

Hi!, i'm on platformIO and i'm finding any way to get compiled correctly when i declare EthernetServer server(80);
src/main.cpp:5:16: error: cannot declare variable 'server' to be of abstract type 'EthernetServer'

#include <Arduino.h>
#include <Ethernet2.h>


EthernetServer server(80);

void setup() {

}

void loop() {
}

there's a way to make it run ?
instead on another pc with linux, the same zipped project is working, can you help me :( ?

suboptimal SPI usage in write function on Nucleo platform

  • Arduino board: Nucleo

  • Arduino IDE version: 1.8.5

I am working on with Nucleo board and since stm32's SPI setup is more complex (than setting couple of registers) calling SPI.beginTransaction causes long delays in communication.
Transfer requires at least one call to beginTransaction so theoretically it should be enough.

How does it look like in practice? After uploading WebServer example and fetching data in browser, developer tools are showing 600-700 ms of waiting time.
I've plugged in logic analyzer and used one pin for time tracing.

uint8_t W5500Class::write(uint16_t _addr, uint8_t _cb, uint8_t _data)
{
    digitalWrite(D8, HIGH);
    SPI.beginTransaction(wiznet_SPI_settings);
    setSS();  
    SPI.transfer(_addr >> 8);
    SPI.transfer(_addr & 0xFF);
    SPI.transfer(_cb);
    SPI.transfer(_data);
    resetSS();
    SPI.endTransaction();

    digitalWrite(D8, LOW);
    return 1;
}

uint16_t W5500Class::write(uint16_t _addr, uint8_t _cb, const uint8_t *_buf, uint16_t _len)
{
    digitalWrite(D8, HIGH);
    SPI.beginTransaction(wiznet_SPI_settings);
    setSS();
    SPI.transfer(_addr >> 8);
    SPI.transfer(_addr & 0xFF);
    SPI.transfer(_cb);
    for (uint16_t i=0; i<_len; i++){
        SPI.transfer(_buf[i]);
    }
    resetSS();
    SPI.endTransaction();

    digitalWrite(D8, LOW);
    return _len;
}

Here is result:
2018-05-29-001223_1567x529_scrot
By checking slopes of D8 and CS you can see that beginTransaction takes about 45 µs and takes longer than reset of function...
After commenting out beginTransaction and endTransaction I managed to halve the time needed for page load (around 260ms), and timing looks as follow:
2018-05-29-001619_1459x374_scrot

I checked the same on Arduino Nano and there were no observable time differences w/ w/o beginTransaction (around 230 ms):
2018-05-29-010549_763x352_scrot

If one is curious: this is SPI initialization on avr (yes, those two lines), and for Nucleo here is call to spi_init which looks like this on stm32duino...

Leonardo break when trying to initialize Ethernet object from class

Hi,

I created a project with some class (header and cpp files).
When I tried invoking Ethernet.begin(mac_addr); from the constructor of the class, Leonardo breaks after upload, and I am not able to upload anymore (pc can't detect Leonardo's usb port).
When invoking Ethernet.begin(mac_addr); from within setup() function in the ino file, the issue doesn't exist.

ESP32 Supported?

  • Arduino board: ESP32 DEV MODULE

  • Arduino IDE version :

1.8.5

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

SS_pin changed to 17; Orange LED constant on, Green LED flashing sometime; the IP address is not being used by another device on the network,

Serial output:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13256
entry 0x40078a90
connecting...
connection failed

CODE:

/*
Web client

This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen

*/

#include <SPI.h>
#include <Ethernet2.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.google.com"; // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 178, 177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// start the Ethernet connection:
Ethernet.begin(mac, ip);
//Serial.println("Failed to configure Ethernet using STATIC");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
//Ethernet.begin(mac, ip);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");

// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}

void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}

// if the server's disconnected, stop the client:
if (!client.connected()) {
// Serial.println();
// Serial.println("disconnecting.");
// client.stop();

// do nothing forevermore:
while (true);

}
}

Warning in compilation

Hi everybody,

Thanks a lot for the good job, making Wiz5500 available for us

When I compile I have some warnings (high level of verbose). I wonder if it is important or not.

Thanks again for the job.

Philippe

like:
C:\Program Files (x86)\Arduino\libraries\Ethernet2\src\Dns.cpp:313:58: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

 for (uint16_t i =0; i < htons(*((uint16_t*)&header[4])); i++)

                                                      ^

C:\Program Files (x86)\Arduino\libraries\Ethernet2\src\utility/util.h:5:22: note: in definition of macro 'htons'

                ((x)>> 8 & 0x00FF) )

                  ^

C:\Program Files (x86)\Arduino\libraries\Ethernet2\src\utility\socket.cpp:322:19: warning: unused parameter 's' [-Wunused-parameter]

void flush(SOCKET s) {

WIZ550io & dhcp

I'm using a Feather WICED with a WIZ550io module. If I don't call:

Ethernet.init( PA4 );

the WIZ550io module will never start. I have confirmed that SS is correctly set to PA4 (in feather.h), so it's not setting the pin itself that makes this work, but I presume that the init method also calls something that makes the Wiznet module work?

To reproduce, connect a WIZ550io module and use the "webclient" example for Ethernet2. This will just hang and never init the module:

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }

This will work every time and init with DHCP address within a second:

  Ethernet.init( PA4 );
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }

PS: you might want to correct the "congifure"-typo in the comments also ;-)

SPI settings in w5500.cpp

The default SPI settings in /utilityw5500.cpp is incorrect. The speed is set to 800000 (.8MHz). It should be 4000000(4MHz) or 8000000(8MHz).
SPISettings wiznet_SPI_settings(800000, MSBFIRST, SPI_MODE0);

AdvancedChatServer example is wrong

The AdvancedChatServer example has this defect:

void setup() {
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

There should be a dns_server in there
(look at the AdvancedChatServer example for ethernet vs. ethernet2)

` void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.