uPing - Ping library for MicroPython
Re: uPing - Ping library for MicroPython
Please update your firmware to the daily build. Then, SOCK_RAW should be working.
Re: uPing - Ping library for MicroPython
Nice! Thanks.Please update your firmware to the daily build. Then, SOCK_RAW should be working.
Re: uPing - Ping library for MicroPython
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
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.
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()
- Wind-stormger
- Posts: 17
- Joined: Fri Nov 05, 2021 6:59 am
Re: uPing - Ping library for MicroPython
When uping today on an esp32s2 with the latest nightly build firmware:
0 packets received
——————————————————————————
I may have found that the reason is the problem of the IP device. Restart it to solve the problem.
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)
——————————————————————————
I may have found that the reason is the problem of the IP device. Restart it to solve the problem.
Last edited by Wind-stormger on Thu May 12, 2022 7:41 am, edited 1 time in total.
Re: uPing - Ping library for MicroPython
Just look into the python code of uping,py. This is straight code, where the print() statement definitely do not depend on a version.
- Wind-stormger
- Posts: 17
- Joined: Fri Nov 05, 2021 6:59 am
Re: uPing - Ping library for MicroPython
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
Re: uPing - Ping library for MicroPython
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
Hardly. The returned value is a tuple. So not need to append. You can directly index into it.
I added the quiet=True argument to suppress the interim debug messages.
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()
Re: uPing - Ping library for MicroPython
This is why this forum is helpful. Many thanks.