Uart Buffer too small/slow?

  • Hi!

    I'm using a Lopy1 with the latest 1.18.1 firmware for a little work project, where i'm reading doserate and spectral data from a measuring device.
    The probe is connected via UART, with 19200 baud. Every 10 seconds it sends a data string with 80 bytes and every 5 minutes i get spectral data in binary format, which is 2048bytes long.

    The small data packages are no problem, but when i receive a big message, only part of the message, about 500bytes, is read.
    I've tried several ways, using

    • readline
    • readinto using a bytearray
    • read every byte at once with read(1)
    • ....

    This seems to be also connected somehow to but i'm not sure. Nevertheless, uart.any() does not seem to report the correct values.

    I also read, that in micropython it's possible to define the read_into_buf for a uart connection, but this does not seem possible with the current pycom firmware.

    With another adafruit microcontroller and connected to the PC the probe works fine. Can you give me any hints on solving this problem or is this a limitiation of this board?


  • Big Thanks for the hint!

    I compiled the firmware with a buffer_len of 4096 instead of 512 and it seems to be working now.
    At least it says it reads the correct number of bytes. I still have to verify the data ;)

  • I am just guessing now, but maybe this is worth a try...

    In there is a constant that looks like the UART RX buffer size and the value is 512. Don´t know if changing this value will solve your problem, but I think it is worth a try!


Log in to reply

Pycom on Twitter