logo elektroda
logo elektroda
X
logo elektroda

ESP8266 - How to reduce the number of bytes in the "Serial port" buffer;

madiz08 507 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17942892
    madiz08
    Level 14  
    Hello
    I am trying to make an RFID card reader using the RMD6300 module, which sends bytes to the ESP8266 over the UART. The whole byte reading goes without a problem, I wait for a byte of value 2 starting the data transfer and on receiving a byte of value 3 I terminate the reading.

    The problem is that the RMD6300, when an RFID card is applied to it, does the reading several times. As many times as it reads the card it sends 14 bytes each.
    The correct reading occurs after the first data transfer, but because the read buffer of the serial port has charged to probably 64 bytes, the reading loops several times.

    Where can I reduce the number of bytes of the Serial Port read buffer? I remember doing something like this once before, it was written in some library and the value was 64 bytes. I can't find it, and I would just like to limit this value to 14 bytes. Or maybe there is an option to:
    1. read the RFID card code
    2. wait a second
    3. erase the remaining contents of the read buffer
  • ADVERTISEMENT
  • Helpful post
    #2 17942914
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #3 17943030
    khoam
    Level 42  
    madiz08 wrote:
    Correct reading occurs after the first data transfer, but because the serial port read buffer has loaded to perhaps 64 bytes, the reading loops several times.
    .
    On the ESP8266 the hardware RX/TX FIFO is 128 bytes, you won't go lower than that :) .
  • #4 17943293
    kaczakat
    Level 34  
    A larger buffer size than you need is an advantage, not a disadvantage, you can always read the whole buffer and use the last value read. If you want to take shortcuts then you can call the function associated with that buffer "flush" and start collecting the data again.
    Helpful post? Buy me a coffee.
ADVERTISEMENT