🤖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

    UiFlow 2.0
    2
    4
    532
    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
      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
        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
          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
            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
            • First post
              Last post