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

    string edit

    Scheduled Pinned Locked Moved FiPy
    7 Posts 2 Posters 295 Views 2 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.
    • R Offline
      radossslaw
      last edited by robert-hh

      This post is deleted!
      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @radossslaw
        last edited by robert-hh

        @radossslaw Please give an example of what the content of data is.
        And does it simply not work, or do you get an error message?
        Edit: And shouldn't you print int_x and int_y?

        1 Reply Last reply Reply Quote 0
        • R Offline
          radossslaw
          last edited by

          string is b'22' error is 2 line in this code

          1 Reply Last reply Reply Quote 0
          • R Offline
            radossslaw
            last edited by

            This post is deleted!
            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @radossslaw
              last edited by

              @radossslaw a few comments, not related to the error message:

              • The code piece you show has no line 54.
              • the indentation of the first line seems to be wrong

              But this starting section is odd:

                  num=data
                  num=int(num)
                  num=str(num)
                  x=num[0]
                  y=num[1:3]
              

              It starts with data, which is a bytearray. Converting it to int() and back to str() makes it a string with whitespace stripped. You would get the same with: num = data.strip().decode(). Then you take two substrings, x and y.
              These are not numbers. And I guess, that you uses these later in the code, e.g. in line 54, in a comparison with a number, which fails.

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                radossslaw @robert-hh
                last edited by

                This post is deleted!
                R 1 Reply Last reply Reply Quote 0
                • R Offline
                  radossslaw @radossslaw
                  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