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

    send hexa number to sigfox

    Scheduled Pinned Locked Moved SiPy
    3 Posts 3 Posters 164 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.
    • Q Offline
      quentho
      last edited by

      Hello,
      I would like to send a 12 bytes hex number via sigfox.
      But I need to transform this into bytes via the package (stuck.pack) and I can't because the biggest one is: double with 8 bytes.
      this is my code :

      
          def bytes_trame(self):
              """cette fonction divise la trame de 12 octets en 3 trames de 4 octets
              pour ensuite les enpaqueter en bytes"""
              self.trame()
              trame_bytes=pack('>Q',int(self.trame_bin))
              print("trame_bytes",trame_bytes)
              return trame_bytes
      

      and this is the result :

      rame_dec [0, 6, 1, 217, 2, 394]
      bin: 0b1000000001100001110110010010110001010
      trame hex 0x100c3b258a
      trame_bytes b'\x00\x00\x00\x10\x0c;%\x8a'
      

      It is not the same value between trame hex and trame_bytes

      thank you for your reply

      E robert-hhR 2 Replies Last reply Reply Quote 0
      • E Offline
        Eric73 @quentho
        last edited by

        @quentho It is not the same value between trame hex and trame_bytes

        For me it's the same value, it's only the printed output that differ
        Have a Look
        0x100c3b258a
        is same as
        0x000000100c3b258a (with all 0)

        b'\x00\x00\x00\x10\x0c;%\x8a'
        so until \x10,\x0c no visible difference
        then we have ";%", let look a the hexadecimal value in ascii code ';'=0x3B and '%'=0x25 , so it exactly the same number.
        Try
        import ubinascii
        print(ubinascii.hexlify(trame_bytes)
        if you have any doubt

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

          This post is deleted!
          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