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

    Reliable transfer using UART

    Scheduled Pinned Locked Moved FiPy
    4 Posts 2 Posters 43 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.
    • B Offline
      bitvijays
      last edited by

      Hello, Pycom Team,

      Hope you are doing well. So, I am able to transfer 4000 bytes using UART. Need few suggestions. I want reliable transfer from Rasberry Pi and FiPy using UART

      Currently,

      1. I put a newline \n at the end of the message and also attach a header with the message length :ML:50, . 50 is the length of the whole message.
      2. It works fine mostly for small message and if the message are sent are slowly on the UART. However, there are the cases where the UART message can be
      • :ML:50,EEEEE\n
      • :ML:50,DDDD\n:ML:50:EEEE\n or
      • :ML:50,FFFFFFFFFFFF and then in the next read FFFFF\n .

      Not being able to debug the FiPy side makes this more difficult. Knowing that transfer over UART has always been a issue. Is there a library which can be used on both side? Any suggestions are really appreciated.

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

        @bitvijays >I do not know which uart call you are using. You might use uart.read() or uart.readline().

        uart.read() returns whatever is in the receive buffer at the time of the call. That may be None.

        uart.readline() returns data up to a \n character. If there is not \n character, it returns what's there,

        Both calls are nonblocking by default. You can make them wait for a timeout, using the timeout_chars parameter or uart.init() or the instantiation of the uart object. When used with uart.readline(), the call returns up data up to a \n character and if it's not there, waits until the timeout expires for \n to show up.
        See also: https://docs.pycom.io/firmwareapi/pycom/machine/uart/#app

        1 Reply Last reply Reply Quote 0
        • B Offline
          bitvijays
          last edited by

          Hi @robert-hh

          Currently, I have tried using both. The scenario is that UART buffer is defined as 512 bytes and I am trying to transfer large amount of data. (40000 bytes). I came across a old thread of UART RX buffer issue after buffer overflow. Where the data we are transferring is large.

          Where you mentioned that " You were able to do a test with a baud rate of 115200 and 2048 byte and 10k data. With flow control enabled, nothing is lost. Without flow control, data is lost. ".

          So, probably, I should just utilise hardware flow control and things probably should be fine? Also, if it is possible, would it be possible for you to tell a little about your setup? Does P22and P23 port in FiPy refers to RTS and CTS? It seems you used 'P8', 'P9' for RTS and CTS on LoPy4.

          Is there a way to find out which ports can be used for hardware control for FiPy. FiPy Datasheet

          Thank you for your support.

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

            @bitvijays You can use any port for RTS and CTS which is not otherwise used. On FiPy, P5 to P7, P15, P17-P20 are used by the various modems. P4, P8 and P23 are used for the SD card, P12 for the WiFi Antenna switch.

            CTS is an input and so P13, P14 or P16 can be used for it.

            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