Minor bug? rxbuf/read_buf_len argument in machine.UART #12392
-
Board: NUCLEO F446RE In my age old projects, I used Today, I mistakenly used the following code. MicroPython v1.20.0 on 2023-08-19; NUCLEO-F446RE with STM32F446xx
Type "help()" for more information.
>>> from machine import UART
>>> uart = UART(2, 115200, rxbuf=1000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: UART is static and rxbuf can't be changed
>>> The error was caused by UART2 assigned to REPL in mpconfigboard.h as follows:
However, the following code using the older argument does not show an error. >>> uart = UART(2, 115200, read_buf_len=1000)
>>> Is this an expected behaviour? What would happen if I changed the buffer length |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I can't explain the argument name issue and would want to check if the old arg had actually worked.
This is an instance of the more general case of calling |
Beta Was this translation helpful? Give feedback.
-
Looking into the code, there is only one small difference in the handling of |
Beta Was this translation helpful? Give feedback.
-
@robert-hh |
Beta Was this translation helpful? Give feedback.
Looking into the code, there is only one small difference in the handling of
rxbuf
vs.read_buf_len
, if the UART is static. According to the error message, that seems to be the case for UART2 in your tests. For static UARTs, setting the buffer size viarxbuf
raises en error, while any setting forread_buf_len
seems to be ignored silently. For non-static UARTs the values forrxbuf
andread_buf_len
are treated identical.