Giter VIP home page Giter VIP logo

esp8266-ping's People

Contributors

bhelterline avatar bluemurder avatar per1234 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

esp8266-ping's Issues

No error on pinging unreachable host

There is a small problem with the library. When pinging a non existing host on the local area network using an IP address, the library returns 0 and not -1. As a result the example program says that the host was reached in 0ms.

Regards.

Exception 2

Hi

I am getting a fatal exception (2) after a successful ping:

WiFi connected
IP address: 192.168.1.134
Attempt #1. Pinging 192.168.1.22
Echo response received from 192.168.1.22 in 212ms.

Exception (2):
epc1=0x3ffee1f0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffee1f0 depc=0x00000000

ctx: sys 
sp: 3ffffd40 end: 3fffffb0 offset: 01a0

This is the output of the ESP Exception Decoder in the Arduino IDE

Decoding 14 results
0x40227442: ping_coarse_tmr at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/glue-lwip/esp-ping.c line 254
0x4022746d: ping_coarse_tmr at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/glue-lwip/esp-ping.c line 263
0x40100690: free at /home/michel/Development/arduino-1.8.5/portable/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/umm_malloc/umm_malloc.c line 1739
0x40210388: mem_free at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/mem.c line 152
0x4020a35c: cyclic_timer at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 165
0x402273b0: ping_coarse_tmr at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/glue-lwip/esp-ping.c line 230
0x4020a428: sys_check_timeouts at /local/users/gauchard/arduino/arduino_esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 351
0x40228bc0: ets_timer_handler_isr at ?? line ?
0x40228bcd: ets_timer_handler_isr at ?? line ?
0x40228c12: ets_timer_handler_isr at ?? line ?
0x40228813: ets_snprintf at ?? line ?

According to https://gist.github.com/solusipse/b3a13e6578d97db97c27 an exception 2 is a

InstructionFetchErrorCause

error.

I can run another ping library, https://github.com/dancol90/ESP8266Ping, without problem on the same hardware: Wemos D1 mini without any connected pins.

Do you have any idea what I am doing wrong?

Regards.

Exception (2): epc1=0x3ffeea88 epc2=0x00000000 - With NodeMcu V3

Hi bluemurder,

Thanks for the library.

I'm facing an exception with PingIp. You can find the error and the code below.

..........................
WiFi connected with ip 192.168.0.100
Echo response received from 8.8.8.8 in 48ms.
Echo response received from 8.8.8.8 in 47ms.

Exception (2):
epc1=0x3ffeea88 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffeea88 depc=0x00000000

ctx: sys
sp: 3ffffd40 end: 3fffffb0 offset: 01a0

stack>>>
3ffffee0: 40226fd6 00000006 00000000 40227006
3ffffef0: 00000001 00000000 00000000 00000000
3fffff00: 00000000 00000020 00000407 00000000
3fffff10: 3ffeec94 3ffefd44 3fff0c6c 40100690
3fffff20: 00000407 00000000 0000002a 40210150
3fffff30: 402212bc 3ffecc70 3fff02c4 3ffefd40
3fffff40: 40226f44 3ffefd44 00000006 4020a1f0
3fffff50: 3fff0c24 000000c5 00000000 0000002a
3fffff60: 402287e4 3ffee438 3ffee460 60000600
3fffff70: 00a6c6c0 3ffee460 3ffee438 402287f1
3fffff80: 40228836 3fffdab0 00000000 3fffdcb0
3fffff90: 3ffee470 3fffdab0 00000000 40202a83
3fffffa0: 40000f49 40000f49 3fffdab0 40000f49
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset

// CODE //

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Pinger.h>

void setup()
{
Serial.begin(115200);
delay(10);

// We start by connecting to a WiFi network

Serial.println();
Serial.println("Connecting to WiFi");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}

Serial.println();
Serial.print("WiFi connected with ip ");
Serial.println(WiFi.localIP());
}

void loop()
{
// Ping Google DNS
int responseTime = Pinger::Ping(IPAddress(8, 8, 8, 8));
delay(100);
// Print it
if(responseTime == -1)
{
Serial.println("Error pinging IP 8.8.8.8");
}
else
{
Serial.print("Echo response received from 8.8.8.8 in ");
Serial.print(responseTime);
Serial.print("ms.\n");
}

// Wait a while
delay(1000);
}

Please let me know at the end of the ping, how do I get the details of "Approximate round trip times in milli-seconds: Minimum, Maximum and Average

Thanks in advance.

Timeout on last Ping corrupts AvgResponseTime

If the last ping received times out, the AvgResponseTime variable does not get properly calculated. It remains as the sum of all the previous response times and is never divided by the TotalReceivedResponses. This calculation is done in PingReceived() but needs to be duplicated in RequestTimeoutOccurred()

Observed issues with multiple IPs when the u32_t requests > 9

Hi bluemurder,

While checking the ping with multiple IP I observed that when u32_t requests > 9, I face issues with Ping summary, seqno, Reply from IP. I have attached the file for your reference.

  1. LOG_PING_requests=9.txt - The results observed were OK as expected.

  2. LOG_PING_requests=10.txt - Observed issues with the printing of Ping summary. (Not available for all the IPs)

  3. LOG_PING_requests=50.txt - Observed issues with the printing of Ping summary and the icmp_sequence no.

  4. LOG_PING_requests=110.txt - Observed issues with the Reply from 192.168.31.1, printing of Ping summary, icmp_sequence no, and the number of pings initiated.

The above conditions were tested by changing the value of requests = XX in the Pinger.h.

LOG_PING_requests = 9.txt
LOG_PING_requests = 10.txt
LOG_PING_requests = 50.txt
LOG_PING_requests = 110.txt

Thanks in advance.

Add comments compatible with doxygen

Hello,

This issue is not related to the code itself but to the documentation. Would it be possible to add comments doxygen compatible to ease the generation of documentation?

Of course, I will contribute my best.

Anyway, is this problem still alive?

Thank you.

Compile errors

.piolibdeps/ESP8266-ping/src/Pinger.cpp: In member function 'bool Pinger::Ping(IPAddress, u32_t, u32_t)':
.piolibdeps/ESP8266-ping/src/Pinger.cpp:108:19: error: invalid conversion from 'u8_t ()(void, raw_pcb*, pbuf*, const ip_addr_t*) {aka unsigned char ()(void, raw_pcb*, pbuf*, const ip_addr*)}' to 'raw_recv_fn {aka unsigned char ()(void, raw_pcb*, pbuf*, ip_addr*)}' [-fpermissive]
(void )this);
^
In file included from .piolibdeps/ESP8266-ping/src/Pinger.h:38:0,
from .piolibdeps/ESP8266-ping/src/Pinger.cpp:28:
/Users/daniele/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip/include/lwip/raw.h:84:18: error: initializing argument 2 of 'void raw_recv(raw_pcb
, raw_recv_fn, void*)' [-fpermissive]
void raw_recv (struct raw_pcb pcb, raw_recv_fn recv, void recv_arg)ICACHE_FLASH_ATTR;
^
.piolibdeps/ESP8266-ping/src/Pinger.cpp: In member function 'u8_t Pinger::PingReceived(pbuf
, const ip_addr_t
)':
.piolibdeps/ESP8266-ping/src/Pinger.cpp:280:78: error: invalid conversion from 'const ip_addr_t* {aka const ip_addr*}' to 'ip_addr_t* {aka ip_addr*}' [-fpermissive]
etharp_find_addr(NULL, addr, &m_pingResponse.DestMacAddress, &unused_ipaddr);
^
In file included from .piolibdeps/ESP8266-ping/src/PingerResponse.h:34:0,
from .piolibdeps/ESP8266-ping/src/Pinger.h:32,
from .piolibdeps/ESP8266-ping/src/Pinger.cpp:28:
/Users/daniele/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip/include/netif/etharp.h:186:6: error: initializing argument 2 of 's8_t etharp_find_addr(netif*, ip_addr_t*, eth_addr**, ip_addr_t**)' [-fpermissive]
s8_t etharp_find_addr(struct netif netif, ip_addr_t ipaddr,
^
.piolibdeps/ESP8266-ping/src/Pinger.cpp:280:78: error: invalid conversion from 'const ip_addr_t
{aka const ip_addr**}' to 'ip_addr_t** {aka ip_addr**}' [-fpermissive]
etharp_find_addr(NULL, addr, &m_pingResponse.DestMacAddress, &unused_ipaddr);
^
In file included from .piolibdeps/ESP8266-ping/src/PingerResponse.h:34:0,
from .piolibdeps/ESP8266-ping/src/Pinger.h:32,
from .piolibdeps/ESP8266-ping/src/Pinger.cpp:28:
/Users/daniele/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip/include/netif/etharp.h:186:6: error: initializing argument 4 of 's8_t etharp_find_addr(netif*, ip_addr_t*, eth_addr**, ip_addr_t**)' [-fpermissive]
s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr,
^

Pinging Local Network to get Device Names

Hi
I was searching so long for library like this, and maybe I find it.
There is any way, you can help me to able to scan my local network and get all connected/attached Device Names, with ESP8266.
Thank you in advance

pinger.Ping() always returns true

In the example sketch, the "Error during ping command." message is never seen, as pinger.Ping() always == true, even if the website/IP address is unreachable.

// Ping technologytourist.com
  Serial.printf("\n\nPinging technologytourist.com\n");
  if(pinger.Ping("technologytourist.com") == false)
  {
    Serial.println("Error during ping command.");
  }

A similar issue was raised here: #2
which applied to version 1.0.0 and was supposedly fixed in version 1.1.0
In the 1.x versions the return value was meant to be 0 or -1 rather than true or false.
I tested version 1.1.0 and I couldn't get that to work correctly either.

I suspect that changes to the ESP core may be responsible for these issue, but I've not tested that theory.

Port to ESP32?

Is it possible someone could port this over to utilize the ESP32?
Exactly with the same features this one has.

With callbacks and specifying the timeout value??

Wishful thinking,
Thank you.

Multiple ping requests to several hosts in parallel

I need to ping several hosts in parallel from an event callback function. I cannot figure out how to do this. I created an array:

Pinger pinger[5]; // as global, [0] is unused

And tried to issue the pings in a loop within an event callback:

IPAddress IPtoPing(172,16,172,0);
for(i = 1; i <= 4; i++) {`
    IPtoPing[3] = i;
    pinger[i].OnEnd([](const PingerResponse& response)
    {
        Serial.printf("IP address: %s\n",  response.DestIPAddress.toString().c_str());
        return(true);
    });
    
    if(pinger[i].Ping(IPtoPing) == false) {
        // Error
    }
}

I would expect a ping being issued to ip's 192.168.0.1 thru 192.168.0.4, each leading to it's own callback and it's ip address being printed upon Serial. I do see the ARP and ICMP frames correctly in Wireshark. The OnEnd callback, however, is called only once, only for the last ip in the loop.

Am I doing something wrong? Am I missing something?

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.