Reliable transfer using UART
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
- I put a newline
\nat the end of the message and also attach a header with the message length
:ML:50,. 50 is the length of the whole message.
- 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
UARTmessage can be
:ML:50,FFFFFFFFFFFFand then in the next read
Not being able to debug the
FiPyside 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.
- I put a newline
robert-hh 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.
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
CTS? It seems you used
'P8', 'P9'for RTS and CTS on
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-hh 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