Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Ping command

    Scheduled Pinned Locked Moved GPy
    17 Posts 3 Posters 1.7k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kjm @robert-hh
      last edited by

      @robert-hh Bit over my head Rob, any advice on how to get ping working on my GPY?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @kjm
        last edited by robert-hh

        @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.

        K F 3 Replies Last reply Reply Quote 0
        • K Offline
          kjm @robert-hh
          last edited by

          @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?

          1 Reply Last reply Reply Quote 0
          • K Offline
            kjm @robert-hh
            last edited by

            @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
            
            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @kjm
              last edited by robert-hh

              @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()) / 1000

              UPDATE: 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)

              K 1 Reply Last reply Reply Quote 0
              • K Offline
                kjm @robert-hh
                last edited by

                @robert-hh understood tnx

                1 Reply Last reply Reply Quote 0
                • F Offline
                  fruiz1113 @robert-hh
                  last edited by

                  @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.
                  6b139b4f-20a0-4534-94d5-d0257440bc25-image.png

                  1 Reply Last reply Reply Quote 0
                  • F Offline
                    fruiz1113
                    last edited by

                    @robert-hh

                    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

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @fruiz1113
                      last edited by

                      @fruiz1113 Probably it is a security setting of your PC to refuse ping requests.

                      F 1 Reply Last reply Reply Quote 0
                      • F Offline
                        fruiz1113 @robert-hh
                        last edited by

                        @robert-hh Thanks !

                        1 Reply Last reply Reply Quote 0

                        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
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom