Page 3 of 3
Re: uPing - Ping library for MicroPython
Posted: Fri Nov 15, 2019 7:04 am
by Roberthh
Please update your firmware to the daily build. Then, SOCK_RAW should be working.
Re: uPing - Ping library for MicroPython
Posted: Mon Nov 18, 2019 10:17 pm
by uxhamby
Please update your firmware to the daily build. Then, SOCK_RAW should be working.
Nice! Thanks.
Re: uPing - Ping library for MicroPython
Posted: Fri Sep 10, 2021 5:43 am
by ebolisa
It fails on nano rp2040 connect with:
Code: Select all
network config: ('192.168.1.230', '255.255.255.0', '192.168.1.1', '192.168.1.1')
Traceback (most recent call last):
File "<stdin>", line 126, in <module>
File "<stdin>", line 66, in ping
OSError: [Errno 128] ENOTCONN
Re: uPing - Ping library for MicroPython
Posted: Fri Sep 10, 2021 6:26 pm
by Roberthh
Did you connect to your AP before calling uping()?
Does the nano connect respond to ping?
Is uping the only code that fails?
And does it fail on every address?
Does the following small udptest code work? The connected server returns a message with an aphorism.
Code: Select all
import socket
UDP_IP = "68.228.188.226"
UDP_PORT = 17
MESSAGE = b' '
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(5)
def run():
print(s.sendto(MESSAGE, (UDP_IP, UDP_PORT)))
data, address = s.recvfrom(1024)
print(data.decode())
run()
Re: uPing - Ping library for MicroPython
Posted: Thu May 12, 2022 6:24 am
by Wind-stormger
When uping today on an esp32s2 with the latest nightly build firmware:
Code: Select all
>>> import uping
>>> uping.ping(host='192.168.11.143', count=50, timeout=5000, interval=10, quiet=False, size=64)
PING 192.168.11.143 (192.168.11.143): 64 data bytes
50 packets transmitted, 0 packets received
(50, 0)
0 packets received
——————————————————————————
I may have found that the reason is the problem of the IP device. Restart it to solve the problem.
Re: uPing - Ping library for MicroPython
Posted: Thu May 12, 2022 7:09 am
by Roberthh
Just look into the python code of uping,py. This is straight code, where the print() statement definitely do not depend on a version.
Re: uPing - Ping library for MicroPython
Posted: Thu May 12, 2022 8:32 am
by Wind-stormger
Roberthh wrote: ↑Thu May 12, 2022 7:09 am
Just look into the python code of uping,py. This is straight code, where the print() statement definitely do not depend on a version.
Thanks.
By the way,recently merged features are helpful in improving wifi stability.
https://github.com/micropython/micropython/pull/8518
Code: Select all
import network
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.config(txpower=8.5) #set to 8.5dBm
print(sta_if.config("txpower")) # txpower=8.5dBm
Reducing power helps improve stability,especially some boards that use PCB onboard antennas.
Re: uPing - Ping library for MicroPython
Posted: Sat Oct 15, 2022 4:56 am
by fishjoe
Is this the correct way to catch the result???
Code: Select all
results = []
for result in uping.ping('google.com'):
results.append(result)
if results[1] != 0:
print(f"\n\nUping successfull, returned {results[1]} of {results[0]} packets sent.") # or do_something()
else:
print(f"\n\nUping UNSUCCESSFULL, cannot reach target.") # or do_something()
Re: uPing - Ping library for MicroPython
Posted: Sat Oct 15, 2022 6:35 am
by Roberthh
Hardly. The returned value is a tuple. So not need to append. You can directly index into it.
Code: Select all
result = uping.ping('google.com', quiet=True)
if result[1] != 0:
print(f"\n\nUping successfull, returned {result[1]} of {result[0]} packets sent.") # or do_something()
else:
print(f"\n\nUping UNSUCCESSFULL, cannot reach target.") # or do_something()
I added the quiet=True argument to suppress the interim debug messages.
Re: uPing - Ping library for MicroPython
Posted: Sat Oct 15, 2022 11:53 pm
by fishjoe
This is why this forum is helpful. Many thanks.