🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to set end of line character in UART

    Scheduled Pinned Locked Moved UiFlow 2.0
    4 Posts 2 Posters 2.6k Views 1 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.
    • D Offline
      digiajay
      last edited by

      I'm using UI flow 2.0. My UART device has special ascii char for end of line (0x7E). I believe EOL is detected using line feed by default 0x0A.. Is there a way to set custom end of line character in the UART initialization?

      uart1 = UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=32, rx=26, txbuf=256, rxbuf=256, timeout=0, timeout_char=0, invert=0, flow=0)
      
      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF Offline
        felmue @digiajay
        last edited by

        Hello @digiajay

        you can use UART x write "" block which will send data without line end and then use UART x write raw Data 0x7E to send the special line end.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        D 1 Reply Last reply Reply Quote 0
        • D Offline
          digiajay @felmue
          last edited by

          @felmue Sorry, this is for reading from UART device.. It's UHF RFID reader device that sends newly read tag data with 7E at the end.

          felmueF 1 Reply Last reply Reply Quote 0
          • felmueF Offline
            felmue @digiajay
            last edited by

            Hello @digiajay

            ok, understood.

            Well, you cannot set a different EOL character and therefore you cannot use UART block read line.

            However you can use block count of available and read 1 bytes etc. to read chars sent from your device. As long as the char received is not your EOL char, append them into a buffer. And when you receive your EOL char do something with the chars accumulated in the buffer, then clear the buffer and start over.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

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