Ping command
-
@robert-hh Bit over my head Rob, any advice on how to get ping working on my GPY?
-
@kjm Try changing this line (about line 49):
sock = usocket.socket(usocket.AF_INET, usocket.SOCK_RAW, 1)
into
sock = usocket.socket(usocket.AF_INET, 3, 1)It is just the symbolic constant usocket.SOCK_RAW, which is not defined.
-
@robert-hh said in Ping command:
sock = usocket.socket(usocket.AF_INET, 3, 1)
Ahh, excellent! Wish I had your flair for this stuff squire. I couldn't interest you in having a look at my other stumbling block(https://forum.pycom.io/topic/4932/urequests-timeouts/3) by any chance?
-
@robert-hh Any ideas what could cause a large negative result?
PING google.com (172.217.167.78): 64 data bytes 84 bytes from 172.217.167.78: icmp_seq=1, ttl=56, time=-5859553813934326.171875 ms 84 bytes from 172.217.167.78: icmp_seq=2, ttl=56, time=-5859553813934326.171875 ms 84 bytes from 172.217.167.78: icmp_seq=3, ttl=56, time=-5859553813934326.171875 ms 84 bytes from 172.217.167.78: icmp_seq=4, ttl=56, time=-5859553813934326.171875 ms 4 packets transmitted, 4 packets received -
@kjm This line:
t_elasped = (utime.ticks_us()-h2.timestamp) / 1000
Instead of utime.ticks_diff(), the code uses simple subtraction. The ticks_cpu(), ticks_us() and ticks_ms() timers wrap around, and therefore ticks_diff() must bes used for time differences. See also the documentation at https://docs.pycom.io/firmwareapi/micropython/utime.html. So the line in questions should be:
t_elasped = utime.ticks_diff(h2.timestamp, utime.ticks_us()) / 1000UPDATE: since the order of arguments for ticks_diff() was changed between the master branch and the release-candidate, a safe change is:
t_elasped = abs(utime.ticks_diff(utime.ticks_us(), h2.timestamp) / 1000) -
@robert-hh understood tnx
-
@robert-hh said in Ping command:
sock = usocket.socket(usocket.AF_INET, 3, 1)
Thanks Robert ! It works ! Finally I can use the ping command to see other HW on the same network !
It is my first step with GPY board and necessary to try network
It is hard to find the way to use micropython ESP32 scripts compatible with pycom and there is lack of information , micropython sentences for pycom differs.

-
Another question , I succedeed when I ping to external pages , and to the gateway of the router I am connected but I can not get other machines , for example router IP is 192.168.1.1 , GPY IP 192.168.1.8 , my laptop is at 192.168.1.9 , when I type uping.ping ('192.168.1.9) , I got no packets reply , may be a router set up ?
Thanks again -
@fruiz1113 Probably it is a security setting of your PC to refuse ping requests.
-
@robert-hh Thanks !
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login